couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From wenda...@apache.org
Subject [2/6] git commit: updated refs/heads/1.3.x to 5e64395
Date Wed, 10 Apr 2013 01:52:54 GMT
Remove setup functions from test runner, only allow a single test to be run at a time.


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

Branch: refs/heads/1.3.x
Commit: 6bbb1cc06ddad4b35cb55c2a73e4f269eb06a0ec
Parents: e1bfac2
Author: Wendall Cada <wendallc@apache.org>
Authored: Fri Apr 5 11:43:46 2013 -0700
Committer: Wendall Cada <wendallc@apache.org>
Committed: Mon Apr 8 16:39:10 2013 -0700

----------------------------------------------------------------------
 test/javascript/cli_runner.js |   84 ++++++++++--------------------------
 1 files changed, 23 insertions(+), 61 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/6bbb1cc0/test/javascript/cli_runner.js
----------------------------------------------------------------------
diff --git a/test/javascript/cli_runner.js b/test/javascript/cli_runner.js
index fcb4633..e8ebd2e 100644
--- a/test/javascript/cli_runner.js
+++ b/test/javascript/cli_runner.js
@@ -9,77 +9,39 @@
 // WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
 // License for the specific language governing permissions and limitations under
 // the License.
+//
 
-var console = {
-  log: function(arg) {
-    var msg = (arg.toString()).replace(/\n/g, "\n    ");
-    print(msg, true);
-  }
-};
+/*
+ * Futon test suite was designed to be able to run all tests populated into
+ * couchTests. Here we should only be loading one test, so we'll pop the first
+ * test off the list and run the test. If more than one item is loaded in the
+ * test object, return an error.
+ */
+function runTest() {
+  var count = 0;
+  var start = new Date().getTime();
 
-var fmtStack = function(stack) {
-  if(!stack) {
-    console.log("No stack information");
-    return;
-  }
-  console.log("Trace back (most recent call first):\n");
-  var re = new RegExp("(.*?)@([^:]*):(.*)$");
-  var lines = stack.split("\n");
-  for(var i = 0; i < lines.length; i++) {
-    var line = lines[i];
-    if(!line.length) continue;
-    var match = re.exec(line);
-    if(!match) continue
-    var source = match[1].substr(0, 70);
-    var file = match[2];
-    var lnum = match[3];
-    while(lnum.length < 3) lnum = " " + lnum;
-    console.log(" " + lnum + ": " + file);
-    console.log("      " + source);
+  for(var name in couchTests) {
+      count++;
   }
-}
-
 
-function T(arg1, arg2) {
-  if(!arg1) {
-    var result = (arg2 ? arg2 : arg1);
-    throw((result instanceof Error ? result : Error(result)));
+  if (count !== 1) {
+      console.log('Only one test per file is allowed.');
+      quit(1);
   }
-}
 
-function runTestConsole(num, name, func) {
-  var passed = false;
   try {
-    func();
-    passed = true;
-    print("ok " + num + " " + name);
+    // Add artificial wait for each test of 1 sec
+    while (new Date().getTime() < start + 1200);
+    couchTests[name]();
+    print('OK');
   } catch(e) {
-    print("not ok " + num + " " + name);
-    console.log("Reason: " + e.message);
+    console.log("FAIL\nReason: " + e.message);
     fmtStack(e.stack);
+    quit(1);
   }
-  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;
-    if(runTestConsole(testId, t, couchTests[t])) {
-      numPassed++;
-    }
-  }
-  if(numPassed != numTests) {
-    console.log("Test failures: " + (numTests - numPassed));
-    quit(1);
-  } else {
-    console.log("All tests passed");
-  }
-};
+waitForSuccess(CouchDB.isRunning, 'isRunning');
 
-waitForSuccess(CouchDB.getVersion);
-runAllTestsConsole();
+runTest();


Mime
View raw message