You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by al...@apache.org on 2016/09/30 16:15:05 UTC

cordova-paramedic git commit: You can now specify a target to run tests on

Repository: cordova-paramedic
Updated Branches:
  refs/heads/master 859d02c7e -> ffa40f80b


You can now specify a target to run tests on


Project: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/commit/ffa40f80
Tree: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/tree/ffa40f80
Diff: http://git-wip-us.apache.org/repos/asf/cordova-paramedic/diff/ffa40f80

Branch: refs/heads/master
Commit: ffa40f80b12341ae82244ce2a92e80308c43d42b
Parents: 859d02c
Author: Alexander Sorokin <al...@akvelon.com>
Authored: Fri Sep 30 19:14:52 2016 +0300
Committer: Alexander Sorokin <al...@akvelon.com>
Committed: Fri Sep 30 19:14:52 2016 +0300

----------------------------------------------------------------------
 lib/ParamedicConfig.js        | 15 ++++++++++++++-
 lib/ParamedicTargetChooser.js | 31 +++++++++++++++++++-----------
 lib/paramedic.js              |  7 ++++++-
 lib/utils/utilities.js        |  9 +++++++--
 main.js                       | 39 ++++++++++++++++++++++++--------------
 5 files changed, 72 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/ffa40f80/lib/ParamedicConfig.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicConfig.js b/lib/ParamedicConfig.js
index 620b5b8..12d781c 100644
--- a/lib/ParamedicConfig.js
+++ b/lib/ParamedicConfig.js
@@ -65,7 +65,8 @@ ParamedicConfig.parseFromArguments = function (argv) {
         sauceAppiumVersion:   argv.sauceAppiumVersion && argv.sauceAppiumVersion.toString(),
         skipAppiumTests:      argv.skipAppium,
         skipMainTests:        argv.skipMainTests,
-        ci:                   argv.ci
+        ci:                   argv.ci,
+        target:               argv.target
     });
 };
 
@@ -248,4 +249,16 @@ ParamedicConfig.prototype.isCI = function () {
     return this._config.ci;
 };
 
+ParamedicConfig.prototype.setCI = function (isCI) {
+    this._config.ci = isCI;
+};
+
+ParamedicConfig.prototype.getTarget = function () {
+    return this._config.target;
+};
+
+ParamedicConfig.prototype.setTarget = function (target) {
+    this._config.target = target;
+};
+
 module.exports = ParamedicConfig;

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/ffa40f80/lib/ParamedicTargetChooser.js
----------------------------------------------------------------------
diff --git a/lib/ParamedicTargetChooser.js b/lib/ParamedicTargetChooser.js
index 0d5ffcd..a343411 100644
--- a/lib/ParamedicTargetChooser.js
+++ b/lib/ParamedicTargetChooser.js
@@ -32,17 +32,17 @@ function ParamedicTargetChooser(appPath, platform) {
     this.platform = platform;
 }
 
-ParamedicTargetChooser.prototype.chooseTarget = function (emulator) {
+ParamedicTargetChooser.prototype.chooseTarget = function (emulator, target) {
     var targetObj = '';
     switch(this.platform) {
         case util.ANDROID:
-            targetObj = this.chooseTargetForAndroid(emulator);
+            targetObj = this.chooseTargetForAndroid(emulator, target);
             break;
         case util.IOS:
-            targetObj = this.chooseTargetForIOS(emulator);
+            targetObj = this.chooseTargetForIOS(emulator, target);
             break;
         case util.WINDOWS:
-            targetObj = this.chooseTargetForWindows(emulator);
+            targetObj = this.chooseTargetForWindows(emulator, target);
             break;
         default:
             break;
@@ -50,23 +50,23 @@ ParamedicTargetChooser.prototype.chooseTarget = function (emulator) {
     return targetObj;
 };
 
-ParamedicTargetChooser.prototype.chooseTargetForAndroid = function (emulator) {
+ParamedicTargetChooser.prototype.chooseTargetForAndroid = function (emulator, target) {
     logger.info('cordova-paramedic: Choosing Target for Android');
-    return this.startAnAndroidEmulator().then(function(emulatorId) {
+    return this.startAnAndroidEmulator(target).then(function(emulatorId) {
         var obj = {};
         obj.target = emulatorId;
         return obj;
     });
 };
 
-ParamedicTargetChooser.prototype.startAnAndroidEmulator = function () {
+ParamedicTargetChooser.prototype.startAnAndroidEmulator = function (target) {
     logger.info('cordova-paramedic: Starting an Android emulator');
 
     var emuPath = path.join(this.appPath, 'platforms', 'android', 'cordova', 'lib', 'emulator');
     var emulator = require(emuPath);
 
     var tryStart = function(numberTriesRemaining) {
-        return emulator.start(null, ANDROID_TIME_OUT)
+        return emulator.start(target, ANDROID_TIME_OUT)
         .then(function(emulatorId) {
             if (emulatorId) {
                 return emulatorId;
@@ -92,7 +92,7 @@ ParamedicTargetChooser.prototype.startAnAndroidEmulator = function () {
     });
 };
 
-ParamedicTargetChooser.prototype.chooseTargetForWindows = function (emulator) {
+ParamedicTargetChooser.prototype.chooseTargetForWindows = function (emulator, target) {
     logger.info('cordova-paramedic: Choosing Target for Windows');
     var windowsCommand = 'cordova run --list --emulator';
 
@@ -113,12 +113,21 @@ ParamedicTargetChooser.prototype.chooseTargetForWindows = function (emulator) {
         return /^\d+\.\s+/.test(line);
     });
 
+    if (target) {
+        for (var t in targets) {
+            if (targets.hasOwnProperty(t) && t.indexOf(target) >= 0) {
+                targets = [ t ];
+                break;
+            }
+        }
+    }
+
     return Q({target: targets[0].split('. ')[0].trim()});
 };
 
-ParamedicTargetChooser.prototype.chooseTargetForIOS = function (emulator) {
+ParamedicTargetChooser.prototype.chooseTargetForIOS = function (emulator, target) {
     logger.info('cordova-paramedic: Choosing Target for iOS');
-    var simulatorModelId = util.getSimulatorModelId();
+    var simulatorModelId = util.getSimulatorModelId(target);
     var split            = simulatorModelId.split(', ');
     var device           = split[0].trim();
     var simId            = util.getSimulatorId(simulatorModelId);

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/ffa40f80/lib/paramedic.js
----------------------------------------------------------------------
diff --git a/lib/paramedic.js b/lib/paramedic.js
index fef99b2..689d89f 100644
--- a/lib/paramedic.js
+++ b/lib/paramedic.js
@@ -241,6 +241,8 @@ ParamedicRunner.prototype.maybeRunFileTransferServer = function () {
 ParamedicRunner.prototype.runLocalTests = function () {
     var self = this;
 
+    // checking for Android platform here because in this case we still need to start an emulator
+    // will check again a bit lower
     if (!self.config.runMainTests() && self.config.getPlatformId() !== 'android') {
         logger.normal('Skipping main tests...');
         return Q(util.TEST_PASSED);
@@ -406,7 +408,10 @@ ParamedicRunner.prototype.getCommandForStartingTests = function () {
     }
 
     // For now we always trying to run test app on emulator
-    return paramedicTargetChooser.chooseTarget(/*useEmulator=*/true)
+    return Q().then(function () {
+        var configTarget = self.config.getTarget();
+        return paramedicTargetChooser.chooseTarget(/*useEmulator=*/true, /*preferredTarget=*/configTarget);
+    })
     .then(function(targetObj){
         self.targetObj = targetObj;
         cmd += ' --target ' + self.targetObj.target;

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/ffa40f80/lib/utils/utilities.js
----------------------------------------------------------------------
diff --git a/lib/utils/utilities.js b/lib/utils/utilities.js
index ea2ae1a..e91279f 100644
--- a/lib/utils/utilities.js
+++ b/lib/utils/utilities.js
@@ -61,8 +61,13 @@ function getSimulatorsFolder() {
     return simulatorsFolderPath;
 }
 
-function getSimulatorModelId() {
-    var findSimCommand = 'cordova run --list --emulator | grep ^iPhone | tail -n1';
+function getSimulatorModelId(target) {
+    var findSimCommand;
+    if (target) {
+        findSimCommand = 'cordova run --list --emulator | grep ' + target + ' | tail -n1';
+    } else {
+        findSimCommand = 'cordova run --list --emulator | grep ^iPhone | tail -n1';
+    }
 
     logger.info('running:');
     logger.info('    ' + findSimCommand);

http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/ffa40f80/main.js
----------------------------------------------------------------------
diff --git a/main.js b/main.js
index 011930e..4846db8 100755
--- a/main.js
+++ b/main.js
@@ -38,24 +38,27 @@ var USAGE           = "Error missing args. \n" +
     "`MSECS` : (optional) time in millisecs to wait for tests to pass|fail \n" +
               "\t(defaults to 10 minutes) \n" +
     "`PORTNUM` : (optional) ports to find available and use for posting results from emulator back to paramedic server(default is from 8008 to 8009)\n" +
+    "--target : (optional) target to deploy to\n" +
     "--justbuild : (optional) just builds the project, without running the tests \n" +
     "--browserify : (optional) plugins are browserified into cordova.js \n" +
     "--verbose : (optional) verbose mode. Display more information output\n" +
-    "--useTunnel : (optional) use tunneling instead of local address. default is false\n" +
+    "--useTunnel: (optional) use tunneling instead of local address. default is false\n" +
     "--config : (optional) read configuration from paramedic configuration file\n" +
-    "--outputDir: (optional) path to save Junit results file & Device logs\n" +
-    "--cleanUpAfterRun: (optional) cleans up the application after the run\n" +
-    "--logMins: (optional) Windows only - specifies number of minutes to get logs\n" +
-    "--tccDb: (optional) iOS only - specifies the path for the TCC.db file to be copied.\n" +
-    "--shouldUseSauce: (optional) run tests on Saucelabs\n" +
-    "--buildName: (optional) Build name to show in Saucelabs dashboard\n" +
-    "--sauceUser: (optional) Saucelabs username\n" +
-    "--sauceKey: (optional) Saucelabs access key\n" +
-    "--sauceDeviceName: (optional) Name of the SauceLabs emulator. For example, \"iPhone Simulator\"\n" +
-    "--saucePlatformVersion: (optional) Platform version of the SauceLabs emulator. For example, \"9.3\"\n" +
-    "--sauceAppiumVersion: (optional) Appium version to use when running on Saucelabs. For example, \"1.5.3\"\n" +
-    "--skipMainTests: (optional) Do not run main (cordova-test-framework) tests\n" +
-    "--skipAppiumTests: (optional) Do not run Appium tests";
+    "--outputDir : (optional) path to save Junit results file & Device logs\n" +
+    "--cleanUpAfterRun : (optional) cleans up the application after the run\n" +
+    "--logMins : (optional) Windows only - specifies number of minutes to get logs\n" +
+    "--tccDb : (optional) iOS only - specifies the path for the TCC.db file to be copied.\n" +
+    "--shouldUseSauce : (optional) run tests on Saucelabs\n" +
+    "--buildName : (optional) Build name to show in Saucelabs dashboard\n" +
+    "--sauceUser : (optional) Saucelabs username\n" +
+    "--sauceKey : (optional) Saucelabs access key\n" +
+    "--sauceDeviceName : (optional) Name of the SauceLabs emulator. For example, \"iPhone Simulator\"\n" +
+    "--saucePlatformVersion : (optional) Platform version of the SauceLabs emulator. For example, \"9.3\"\n" +
+    "--sauceAppiumVersion : (optional) Appium version to use when running on Saucelabs. For example, \"1.5.3\"\n" +
+    "--skipMainTests : (optional) Do not run main (cordova-test-framework) tests\n" +
+    "--skipAppiumTests : (optional) Do not run Appium tests\n" +
+    "--ci : (optional) Skip tests that require user interaction\n" +
+    "";
 
 var argv = parseArgs(process.argv.slice(2));
 var pathToParamedicConfig = argv.config && path.resolve(argv.config);
@@ -141,6 +144,14 @@ if (pathToParamedicConfig || // --config
         paramedicConfig.setSkipAppiumTests(argv.skipAppiumTests);
     }
 
+    if (argv.ci) {
+        paramedicConfig.setCI(argv.ci);
+    }
+
+    if (argv.target) {
+        paramedicConfig.setTarget(argv.target);
+    }
+
     paramedic.run(paramedicConfig)
     .catch(function (error) {
         if (error && error.stack) {


---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org