From 45ad2ed21e01ccc235f3675cb5ad22cfe15daaa3 Mon Sep 17 00:00:00 2001 From: Martijn Walraven Date: Thu, 17 Mar 2016 16:47:48 +0100 Subject: [PATCH] Make Cordova self tests pass --- tools/tests/cordova-builds.js | 10 ++--- tools/tests/cordova-hcp.js | 8 ++-- tools/tests/cordova-plugins.js | 11 ++---- tools/tests/cordova-run.js | 22 ++--------- tools/tests/cordova-windows-errors.js | 56 --------------------------- 5 files changed, 16 insertions(+), 91 deletions(-) delete mode 100644 tools/tests/cordova-windows-errors.js diff --git a/tools/tests/cordova-builds.js b/tools/tests/cordova-builds.js index d2b2211141..a888121a0a 100644 --- a/tools/tests/cordova-builds.js +++ b/tools/tests/cordova-builds.js @@ -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); }); diff --git a/tools/tests/cordova-hcp.js b/tools/tests/cordova-hcp.js index 4403c1bc6d..1a15ec88b8 100644 --- a/tools/tests/cordova-hcp.js +++ b/tools/tests/cordova-hcp.js @@ -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(); }); diff --git a/tools/tests/cordova-plugins.js b/tools/tests/cordova-plugins.js index 609f6bd62b..796e1740b9 100644 --- a/tools/tests/cordova-plugins.js +++ b/tools/tests/cordova-plugins.js @@ -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"); diff --git a/tools/tests/cordova-run.js b/tools/tests/cordova-run.js index daa7e94ccf..5fb7a19817 100644 --- a/tools/tests/cordova-run.js +++ b/tools/tests/cordova-run.js @@ -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 :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 :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 :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 diff --git a/tools/tests/cordova-windows-errors.js b/tools/tests/cordova-windows-errors.js deleted file mode 100644 index 6350b6f77d..0000000000 --- a/tools/tests/cordova-windows-errors.js +++ /dev/null @@ -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'); - }); -});