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/06/06 18:08:30 UTC

cordova-paramedic git commit: Flattened promise chain, fixed exit code (again)

Repository: cordova-paramedic
Updated Branches:
  refs/heads/master c3cb0defa -> dc8d56fc3


Flattened promise chain, fixed exit code (again)


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

Branch: refs/heads/master
Commit: dc8d56fc38fdab8dcf890cda53f724746f99bb64
Parents: c3cb0de
Author: Alexander Sorokin <al...@akvelon.com>
Authored: Mon Jun 6 21:08:20 2016 +0300
Committer: Alexander Sorokin <al...@akvelon.com>
Committed: Mon Jun 6 21:08:20 2016 +0300

----------------------------------------------------------------------
 lib/paramedic.js | 101 +++++++++++++++++++++++++++-----------------------
 1 file changed, 55 insertions(+), 46 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/cordova-paramedic/blob/dc8d56fc/lib/paramedic.js
----------------------------------------------------------------------
diff --git a/lib/paramedic.js b/lib/paramedic.js
index ecfad7f..11a4783 100644
--- a/lib/paramedic.js
+++ b/lib/paramedic.js
@@ -72,7 +72,7 @@ ParamedicRunner.prototype.run = function () {
         self.prepareProjectToRunTests();
         return Server.startServer(self.config.getPorts(), self.config.getExternalServerUrl(), self.config.getUseTunnel());
     })
-    .then(function(server) {
+    .then(function (server) {
         self.server = server;
 
         self.injectReporters();
@@ -84,7 +84,7 @@ ParamedicRunner.prototype.run = function () {
         logger.normal('Start running tests at ' + (new Date()).toLocaleTimeString());
         return self.runTests();
     })
-    .fin(function() {
+    .fin(function (result) {
         logger.normal('Completed tests at ' + (new Date()).toLocaleTimeString());
         // if we do --justbuild  or run on sauce,
         // we should NOT do actions below
@@ -94,6 +94,7 @@ ParamedicRunner.prototype.run = function () {
             self.killEmulatorProcess();
         }
         self.cleanUpProject();
+        return result;
     });
 };
 
@@ -193,7 +194,7 @@ ParamedicRunner.prototype.runTests = function () {
         logger.normal('cordova-paramedic: running command ' + command);
 
         return execPromise(command)
-        .then(this.runSauceTests.bind(this));
+        .then(self.runSauceTests.bind(self));
     } else {
         return self.getCommandForStartingTests()
         .then(function(command) {
@@ -476,6 +477,9 @@ ParamedicRunner.prototype.getAppName = function () {
 ParamedicRunner.prototype.runSauceTests = function () {
     logger.info('cordova-paramedic: running sauce tests');
     var self = this;
+    var isTestPassed = false;
+    var pollForResults;
+    var driver;
 
     return self.packageApp()
     .then(self.uploadApp.bind(self))
@@ -515,50 +519,55 @@ ParamedicRunner.prototype.runSauceTests = function () {
 
         logger.normal('cordova-paramedic: connecting webdriver');
 
-        var driver = wd.promiseChainRemote(SAUCE_HOST, SAUCE_PORT, user, key);
-        return driver.init(caps)
-        .then(function () {
-            if (self.config.getUseTunnel()) {
-                return driver;
-            }
-            return driver
-            .getWebviewContext()
-            .then(function (webview) {
-                return driver.context(webview);
-            });
-        })
-        .then(function () {
-            logger.normal('cordova-paramedic: connecting to app');
-
-            if (!self.config.getUseTunnel()) {
-                var pollForResults = setInterval(function () {
-                    // polling for new events
-                    driver.execute(function () {
-                        var result = window._jasmineParamedicProxyCache;
-                        window._jasmineParamedicProxyCache = [];
-                        return result;
-                    }, [])
-                    .then(function (events) {
-                        for (var i = 0; i < events.length; i++) {
-                            self.server.emit(events[i].eventName, events[i].eventObject);
-                        }
-                    });
-                }, 5000);
-            }
-
-            return self.waitForTests()
-            .then(function (result) {
-                logger.normal('cordova-paramedic: tests finished');
-            }, function () {
-                logger.normal('cordova-paramedic: tests failed to complete; ending appium session');
-            })
-            .fin(function () {
-                if (pollForResults) {
-                    clearInterval(pollForResults);
-                }
-                return driver.quit();
-            });
+        driver = wd.promiseChainRemote(SAUCE_HOST, SAUCE_PORT, user, key);
+        return driver.init(caps);
+    })
+    .then(function () {
+        if (self.config.getUseTunnel()) {
+            return driver;
+        }
+        return driver
+        .getWebviewContext()
+        .then(function (webview) {
+            return driver.context(webview);
         });
+    })
+    .then(function () {
+        logger.normal('cordova-paramedic: connecting to app');
+
+        if (!self.config.getUseTunnel()) {
+            pollForResults = setInterval(function () {
+                // polling for new events
+                driver.execute(function () {
+                    var result = window._jasmineParamedicProxyCache;
+                    window._jasmineParamedicProxyCache = [];
+                    return result;
+                }, [])
+                .then(function (events) {
+                    for (var i = 0; i < events.length; i++) {
+                        self.server.emit(events[i].eventName, events[i].eventObject);
+                    }
+                });
+            }, 5000);
+        }
+
+        return self.waitForTests();
+    })
+    .then(function (result) {
+        logger.normal('cordova-paramedic: tests finished');
+        isTestPassed = result;
+    }, function () {
+        logger.normal('cordova-paramedic: tests failed to complete; ending appium session');
+    })
+    .fin(function () {
+        if (pollForResults) {
+            clearInterval(pollForResults);
+        }
+        return driver.quit();
+    })
+    .then(function () {
+        console.log('isTestPassed is ' + isTestPassed);
+        return isTestPassed;
     });
 };
 


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