You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cordova.apache.org by sg...@apache.org on 2014/11/13 06:24:51 UTC
[11/14] cordova-medic git commit: Fix step displaying results of
mobilespec tests
Fix step displaying results of mobilespec tests
Project: http://git-wip-us.apache.org/repos/asf/cordova-medic/repo
Commit: http://git-wip-us.apache.org/repos/asf/cordova-medic/commit/9783c6f4
Tree: http://git-wip-us.apache.org/repos/asf/cordova-medic/tree/9783c6f4
Diff: http://git-wip-us.apache.org/repos/asf/cordova-medic/diff/9783c6f4
Branch: refs/heads/master
Commit: 9783c6f4cfe397bd97542d7415d6be4eafa86bd9
Parents: 98e3d2b
Author: dmitriy-barkalov <v-...@microsoft.com>
Authored: Tue Nov 11 02:19:51 2014 -0800
Committer: dmitriy-barkalov <v-...@microsoft.com>
Committed: Tue Nov 11 02:19:51 2014 -0800
----------------------------------------------------------------------
build_android.js | 2 +-
build_blackberry10.js | 2 +-
build_ios.js | 2 +-
build_windows.js | 11 +++--
build_wp8.js | 15 ++++---
testchecker.js | 106 +++++++++++++++++++++++++--------------------
6 files changed, 80 insertions(+), 58 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/9783c6f4/build_android.js
----------------------------------------------------------------------
diff --git a/build_android.js b/build_android.js
index 5057ca0..038e95e 100644
--- a/build_android.js
+++ b/build_android.js
@@ -29,7 +29,7 @@ buildinfo('Android', BRANCH, function (error, sha ) {
TEST_OK=false;
} else {
console.log('Android tests complete');
- TEST_OK = testcheck.checkTestResults(sha, config.couchdb.host) == 0 ? true : false;
+ TEST_OK = true;
}
});
}
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/9783c6f4/build_blackberry10.js
----------------------------------------------------------------------
diff --git a/build_blackberry10.js b/build_blackberry10.js
index 651ae32..8442adc 100644
--- a/build_blackberry10.js
+++ b/build_blackberry10.js
@@ -29,7 +29,7 @@ buildinfo('BlackBerry', BRANCH, function (error, sha ) {
TEST_OK=false;
} else {
console.log('BlackBerry tests complete');
- TEST_OK = testcheck.checkTestResults(sha, config.couchdb.host) == 0 ? true : false;
+ TEST_OK = true;
}
});
}
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/9783c6f4/build_ios.js
----------------------------------------------------------------------
diff --git a/build_ios.js b/build_ios.js
index c6f5eb1..8eba73c 100644
--- a/build_ios.js
+++ b/build_ios.js
@@ -29,7 +29,7 @@ buildinfo('ios', BRANCH, function (error, sha ) {
TEST_OK=false;
} else {
console.log('iOS tests complete')
- TEST_OK = testcheck.checkTestResults(sha, config.couchdb.host) == 0 ? true : false;
+ TEST_OK = true;
}
});
}
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/9783c6f4/build_windows.js
----------------------------------------------------------------------
diff --git a/build_windows.js b/build_windows.js
index 3425726..1ab94a9 100644
--- a/build_windows.js
+++ b/build_windows.js
@@ -57,9 +57,14 @@ buildinfo('Windows', BRANCH, function (error, sha ) {
}
windows(output_location, sha, config.app.entry, config.couchdb.host, test_timeout, build_target).then(function() {
- console.log('Windows test execution completed');
- TEST_OK = testcheck.checkTestResults(sha, config.couchdb.host) == 0 ? true : false;
- }, function(err) {
+ return testcheck(sha, config.couchdb.host);
+ }).then(function (testCheckResult) {
+ TEST_OK = testCheckResult;
+
+ if (TEST_OK) {
+ console.log('Windows test execution completed');
+ }
+ }).catch(function (err) {
TEST_OK=false;
error_writer('windows', sha, 'Windows tests execution failed.', err);
});
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/9783c6f4/build_wp8.js
----------------------------------------------------------------------
diff --git a/build_wp8.js b/build_wp8.js
index f700471..0b3c00c 100644
--- a/build_wp8.js
+++ b/build_wp8.js
@@ -28,12 +28,17 @@ buildinfo('WP8', BRANCH, function (error, sha ) {
var test_timeout = config.app.timeout ? config.app.timeout : 10 * 60;
wp8(output_location, sha, config.wp8.target, config.app.entry, config.couchdb.host, test_timeout).then(function() {
+ return testcheck(sha, config.couchdb.host);
+ }).then(function (testCheckResult) {
+ TEST_OK = testCheckResult;
+
+ if (TEST_OK) {
console.log('WP8 test execution completed');
- TEST_OK = testcheck.checkTestResults(sha, config.couchdb.host) == 0 ? true : false;
- }, function(err) {
- TEST_OK=false;
- error_writer('wp8', sha, 'WP8 tests execution failed.', err);
- });
+ }
+ }).catch(function (err) {
+ TEST_OK=false;
+ error_writer('wp8', sha, 'WP8 tests execution failed.', err);
+ });
}
});
http://git-wip-us.apache.org/repos/asf/cordova-medic/blob/9783c6f4/testchecker.js
----------------------------------------------------------------------
diff --git a/testchecker.js b/testchecker.js
index e9c8ccf..5e7d3ff 100644
--- a/testchecker.js
+++ b/testchecker.js
@@ -1,60 +1,72 @@
-var http = require('http');
-var url = require('url');
+var http = require('http'),
+ url = require('url');
+ q = require('q'),
-var checkTestResults = function(sha, dbHost) {
- console.log('Starting results verification for ' + sha);
+module.exports = function(sha, dbHost) {
- var options = {
- host: url.parse(dbHost).hostname,
- port: url.parse(dbHost).port,
- path: '/mobilespec_results/_all_docs?start_key="' + sha + '"&limit=1'
- };
+ function getDocumentIdBySha() {
+ var options = {
+ host: url.parse(dbHost).hostname,
+ port: url.parse(dbHost).port,
+ path: '/mobilespec_results/_all_docs?start_key="' + sha + '"&limit=1'
+ },
+ resultsDoc = '',
+ d = q.defer();
- var resultsDoc = "";
+ http.get(options, function(result) {
+ result.on("data", function(chunk) {
+ resultsDoc += chunk.toString();
+ });
- // get current document id by sha
- var req = http.get(options, function(result) {
- result.on("data", function(chunk) {
- resultsDoc += chunk.toString();
+ result.on('end', function () {
+ d.resolve(JSON.parse(resultsDoc).rows[0].id);
+ });
+ }).on('error', function(e) {
+ console.log("Got error: " + e.message);
+ d.reject(e);
});
+
+ return d.promise;
+ };
+
+ function getTestResult(resultId) {
- result.on('end', function () {
- var resultId = JSON.parse(resultsDoc).rows[0].id;
-
- var requestOptions = {
+ var options = {
host: url.parse(dbHost).hostname,
port: url.parse(dbHost).port,
path: '/mobilespec_results/' + resultId
- };
-
- var resultsJSON = "";
- var failure;
+ },
+ d = q.defer(),
+ resultsJSON = "",
+ failure;
- // get failures by document id
- var resultsRequest = http.get(requestOptions, function(res) {
- res.on("data", function(chunk) {
- resultsJSON += chunk;
- });
+ http.get(options, function(res) {
+ res.on("data", function(chunk) {
+ resultsJSON += chunk;
+ });
- res.on('end', function() {
- failure = JSON.parse(resultsJSON);
- if(typeof failure.mobilespec.failures == "undefined") {
- console.log("No failures were detected");
- return 0;
- } else {
- console.log('Test failures were detected. Open ' +
- dbHost + '/_utils/document.html?mobilespec_results/' +
- resultId + ' for details');
- return -1;
- }
- });
- }).on('error', function(e) {
- console.log("Got error: " + e.message);
+ res.on('end', function() {
+ d.resolve(JSON.parse(resultsJSON));
});
+ }).on('error', function(e) {
+ console.log("Got error: " + e.message);
+ d.reject(e)
});
- }).on('error', function(e) {
- console.log("Got error: " + e.message);
- });
-}
-
-module.exports.checkTestResults = checkTestResults;
\ No newline at end of file
+
+ return d.promise;
+ };
+
+ function checkFailure(testResult) {
+ if(typeof testResult.mobilespec.failures == "undefined") {
+ console.log("No failures were detected");
+ return true;
+ } else {
+ console.log('Test failures were detected. Open ' + dbHost + '/_utils/document.html?mobilespec_results/' + testResult._id + ' for details');
+ return false;
+ }
+ };
+
+ console.log('Starting results verification for ' + sha);
+
+ return getDocumentIdBySha().then(getTestResult).then(checkFailure);
+};
\ No newline at end of file
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@cordova.apache.org
For additional commands, e-mail: commits-help@cordova.apache.org