Make Cordova self tests pass

This commit is contained in:
Martijn Walraven
2016-03-17 16:47:48 +01:00
parent 46c9823acd
commit 45ad2ed21e
5 changed files with 16 additions and 91 deletions

View File

@@ -39,31 +39,31 @@ selftest.define("cordova builds with server options", ["cordova", "slow"], funct
run = s.run("build", ".", "--server", "https://example.com:5000");
run.waitSecs(300);
run.expectExit(0);
checkMobileServer(s, "https://example.com:5000");
checkMobileServer(s, "https://example.com:5000/");
cleanUpBuild(s);
run = s.run("build", ".", "--server", "example.com:5000");
run.waitSecs(90);
run.expectExit(0);
checkMobileServer(s, "http://example.com:5000");
checkMobileServer(s, "http://example.com:5000/");
cleanUpBuild(s);
run = s.run("build", ".", "--server", "example.com");
run.waitSecs(90);
run.expectExit(0);
checkMobileServer(s, "http://example.com");
checkMobileServer(s, "http://example.com/");
cleanUpBuild(s);
run = s.run("build", ".", "--server", "https://example.com");
run.waitSecs(90);
run.expectExit(0);
checkMobileServer(s, "https://example.com");
checkMobileServer(s, "https://example.com/");
cleanUpBuild(s);
// XXX COMPAT WITH 0.9.2.2
run = s.run("build", ".", "--mobile-port", "example.com:5000");
run.waitSecs(90);
run.expectExit(0);
checkMobileServer(s, "http://example.com:5000");
checkMobileServer(s, "http://example.com:5000/");
cleanUpBuild(s);
});

View File

@@ -13,7 +13,7 @@ var config = require('../meteor-services/config.js');
// it receives a hot code push, it would be connected to whatever
// ROOT_URL is on the server.
selftest.define(
"cordova --mobile-server argument persists across hot code pushes", ["cordova"], function () {
"cordova --mobile-server argument persists across hot code pushes", ["cordova", "slow"], function () {
var s = new Sandbox();
var run;
@@ -26,7 +26,7 @@ selftest.define(
var platforms = s.read(".meteor/platforms");
s.write(".meteor/platforms", platforms + "\nandroid\n");
run = s.run("--mobile-server", "example.com");
run = s.run("run", "android", "--mobile-server", "example.com");
run.waitSecs(30);
run.match("Started your app");
@@ -34,8 +34,8 @@ selftest.define(
"http://localhost:3000/__cordova/index.html");
var mrc = testUtils.getMeteorRuntimeConfigFromHTML(result);
selftest.expectEqual(mrc.DDP_DEFAULT_CONNECTION_URL, "http://example.com");
selftest.expectEqual(mrc.ROOT_URL, "http://example.com");
selftest.expectEqual(mrc.DDP_DEFAULT_CONNECTION_URL, "http://example.com/");
selftest.expectEqual(mrc.ROOT_URL, "http://example.com/");
run.stop();
});

View File

@@ -17,9 +17,6 @@ var copyFile = function(from, to, sand) {
sand.write(to, contents);
};
var localCordova = files.pathJoin(files.getDevBundle(), 'lib/node_modules/cordova/bin/cordova');
// Given a sandbox, that has the app as its currend cwd, read the versions file
// and read the plugins list.
//
@@ -28,7 +25,7 @@ var getCordovaPluginsList = function(sand) {
var env = files.currentEnvWithPathsAdded(files.getCurrentNodeBinDir());
env.METEOR_WAREHOUSE_DIR = sand.warehouse;
var lines = selftest.execFileSync(localCordova, ['plugins'],
var lines = selftest.execFileSync('cordova', ['plugins'],
{
cwd: files.pathJoin(sand.cwd, '.meteor', 'local', 'cordova-build'),
env: env
@@ -119,7 +116,7 @@ var checkUserPlugins = function(sand, plugins) {
var startAppOnAndroidEmulator = function (s) {
var run = s.run("run", "android");
// Building and running the app on the Android Emulator can take a long time.
run.waitSecs(240);
run.waitSecs(60);
run.match("Started app on Android Emulator");
return run;
}
@@ -191,7 +188,7 @@ selftest.define("add cordova plugins", ["slow", "cordova"], function () {
run.expectExit(0);
run = s.run("add", "cordova:cordova-plugin-file");
run.matchErr("valid version");
run.matchErr("exact version");
run.expectExit(1);
// The current behavior doesn't fail if a plugin is not in the registry until
@@ -258,7 +255,7 @@ selftest.define("add cordova plugins", ["slow", "cordova"], function () {
run.expectExit(0);
run = s.run("add", "cordova:com.example.plugin@file://");
run.matchErr("valid version");
run.matchErr("exact version");
run.expectExit(1);
run = s.run("add", "cordova:com.example.plugin@file://../../plugin_directory");

View File

@@ -3,33 +3,17 @@ import utils from '../utils/utils.js';
import { parseServerOptionsForRunCommand, parseRunTargets } from '../cli/commands.js';
selftest.define('get mobile server argument for meteor run', ['cordova'], function () {
// on emulator
// meteor run -p 3000
// => mobile server should be localhost:3000
// => mobile server should be <detected ip>:3000
selftest.expectEqual(parseServerOptionsForRunCommand({
port: "3000"
}).parsedMobileServerUrl, { host: "localhost", port: "3000", protocol: "http://" });
}).parsedMobileServerUrl, { host: utils.ipAddress(), port: "3000", protocol: "http://" });
// meteor run -p example.com:3000
// => mobile server should be localhost:3000
selftest.expectEqual(parseServerOptionsForRunCommand({
port: "example.com:3000"
}).parsedMobileServerUrl, { host: "localhost", port: "3000", protocol: "http://" });
// on device
// meteor run -p 3000 on device
// => mobile server should be <detected ip>:3000
selftest.expectEqual(parseServerOptionsForRunCommand({
port: "3000"
}, parseRunTargets(["ios-device"])).parsedMobileServerUrl, { host: utils.ipAddress(), port: "3000", protocol: "http://" });
// meteor run -p example.com:3000 on device
// => mobile server should be <detected ip>:3000
selftest.expectEqual(parseServerOptionsForRunCommand({
port: "example.com:3000"
}, parseRunTargets(["android-device"])).parsedMobileServerUrl, { host: utils.ipAddress(), port: "3000", protocol: "http://" });
}).parsedMobileServerUrl, { host: utils.ipAddress(), port: "3000", protocol: "http://" });
// meteor run -p example.com:3000 --mobile-server 4000 => error, mobile
// server must include a hostname

View File

@@ -1,56 +0,0 @@
var files = require('../fs/files.js');
var selftest = require('../tool-testing/selftest.js');
var _ = require('underscore');
var Sandbox = selftest.Sandbox;
selftest.define("windows prints correct message when it can't do mobile things - add-platform, install-sdk, configure-android", ["windows"], function () {
var s = new Sandbox();
var run;
s.createApp("myapp", "standard-app");
s.cd("myapp", function () {
_.each(['add-platform', 'install-sdk'], function (command) {
_.each(['ios', 'android'], function (platform) {
run = s.run(command, platform);
// We print some warning that involves saying you're on Windows
run.matchErr("Windows");
});
});
_.each(['configure-android'], function (command) {
run = s.run(command);
run.matchErr("Windows");
});
});
});
selftest.define("windows prints correct message when it can't do mobile things - build", ["windows"], function () {
var s = new Sandbox();
var run;
s.createApp("mobile-app", "mobile-platforms");
s.cd("mobile-app");
run = s.run("build", ".build", "--server", "https://foo.com");
run.waitSecs(20);
run.matchErr("Windows");
});
selftest.define("windows prints correct message when it can't do mobile things - run, remove-platform", ["windows"], function () {
var s = new Sandbox();
var run;
s.createApp("mobile-app", "mobile-platforms");
s.cd("mobile-app");
_.each(['ios', 'android', 'ios-device', 'android-device'], function (platform) {
run = s.run('run', platform);
// We print some warning that involves saying you're on Windows
run.matchErr("Windows");
});
_.each(['ios', 'android'], function (platform) {
run = s.run('remove-platform', platform);
run.match('removed platform');
});
});