You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by we...@apache.org on 2013/04/05 20:47:52 UTC
[4/6] git commit: updated
refs/heads/COUCHDB-1762-fix-javascript-tests to 9dfddaa
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/0ada3431
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/0ada3431
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/0ada3431
Branch: refs/heads/COUCHDB-1762-fix-javascript-tests
Commit: 0ada3431ac286298c06f103f5eebc978b7173a2b
Parents: df011f7
Author: Wendall Cada <we...@apache.org>
Authored: Fri Apr 5 11:43:46 2013 -0700
Committer: Wendall Cada <we...@apache.org>
Committed: Fri Apr 5 11:43:46 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/0ada3431/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();