diff options
| author | Paul J. Davis <paul.joseph.davis@gmail.com> | 2014-02-04 21:47:09 -0600 |
|---|---|---|
| committer | Paul J. Davis <paul.joseph.davis@gmail.com> | 2014-02-05 08:34:52 -0600 |
| commit | 03ea534c0366164055560cc93d8fc32ceb27bf1f (patch) | |
| tree | 3584ccb648828405eae86cf6fc862f51b9c329a5 /test/javascript/cli_runner.js | |
| parent | a204d0a891281b0c2b9b9382312dc78b7f9f7a66 (diff) | |
| download | couchdb-03ea534c0366164055560cc93d8fc32ceb27bf1f.tar.gz | |
Import JavaScript test runner changes
This is the basis for some temporary work to be able to run the
JavaScript test suite as during the merge transition.
Diffstat (limited to 'test/javascript/cli_runner.js')
| -rw-r--r-- | test/javascript/cli_runner.js | 85 |
1 files changed, 23 insertions, 62 deletions
diff --git a/test/javascript/cli_runner.js b/test/javascript/cli_runner.js index 5d82a516f..e8ebd2e92 100644 --- a/test/javascript/cli_runner.js +++ b/test/javascript/cli_runner.js @@ -9,78 +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) { - CouchDB.reloadConfig(); - 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(); |
