You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by ra...@apache.org on 2012/01/27 02:37:12 UTC

[3/7] git commit: Propogate failures from JS CLI tests to exit codes

Propogate failures from JS CLI tests to exit codes

Assert that all tests pass and save the error code from the couchjs
invocation. Make check will actually fail when JS CLI tests fail.


Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/257eb522
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/257eb522
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/257eb522

Branch: refs/heads/master
Commit: 257eb522c753ae39a5333938ec1856acd8451ec2
Parents: 14ac709
Author: Randall Leeds <ra...@apache.org>
Authored: Wed Jan 18 23:15:53 2012 -0800
Committer: Randall Leeds <ra...@apache.org>
Committed: Thu Jan 26 17:03:10 2012 -0800

----------------------------------------------------------------------
 test/javascript/cli_runner.js |    9 ++++++++-
 test/javascript/run.tpl       |    5 ++++-
 2 files changed, 12 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/257eb522/test/javascript/cli_runner.js
----------------------------------------------------------------------
diff --git a/test/javascript/cli_runner.js b/test/javascript/cli_runner.js
index dec8803..f53ffe8 100644
--- a/test/javascript/cli_runner.js
+++ b/test/javascript/cli_runner.js
@@ -25,8 +25,10 @@ function T(arg1, arg2) {
 }
 
 function runTestConsole(num, name, func) {
+  var passed = false;
   try {
     func();
+    passed = true;
     print("ok " + num + " " + name);
   } catch(e) {
     print("not ok " + num + " " + name);
@@ -35,17 +37,22 @@ function runTestConsole(num, name, func) {
       console.log("Stacktrace:\n" + e.stack.replace(/^/gm, "\t"));
     }
   }
+  return passed;
 }
 
 function runAllTestsConsole() {
   var numTests = 0;
+  var numPassed = 0;
   for(var t in couchTests) { numTests += 1; }
   print("1.." + numTests);
   var testId = 0;
   for(var t in couchTests) {
     testId += 1;
-    runTestConsole(testId, t, couchTests[t]);
+    if(runTestConsole(testId, t, couchTests[t])) {
+      numPassed++;
+    }
   }
+  T(numPassed == numTests, "All JS CLI tests should pass.");
 };
 
 waitForSuccess(CouchDB.getVersion);

http://git-wip-us.apache.org/repos/asf/couchdb/blob/257eb522/test/javascript/run.tpl
----------------------------------------------------------------------
diff --git a/test/javascript/run.tpl b/test/javascript/run.tpl
index 35ff531..47d2f6e 100644
--- a/test/javascript/run.tpl
+++ b/test/javascript/run.tpl
@@ -29,7 +29,7 @@ else
             TEST_SRC="$SCRIPT_DIR/test/$1.js"
             if [ ! -f $TEST_SRC ]; then
                 echo "file $1 does not exist"
-                exit
+                exit 1
             fi
         fi
     fi
@@ -62,9 +62,12 @@ $COUCHJS -H \
 	$TEST_SRC \
 	$JS_TEST_DIR/couch_http.js \
 	$JS_TEST_DIR/cli_runner.js
+RESULT=$?
 
 if [ -z $COUCHDB_NO_START ]; then
 	# stop CouchDB
 	./utils/run -d
 	trap - 0
 fi
+
+exit $RESULT