From: Dan Vanderkam Date: Sat, 31 Mar 2012 21:57:25 +0000 (-0400) Subject: more docs in phantom-driver.js; log speed X-Git-Tag: v1.0.0~294 X-Git-Url: https://adrianiainlam.tk/git/?a=commitdiff_plain;h=08fcae0c57695c6e337352f0f97e589bee5ab97c;p=dygraphs.git more docs in phantom-driver.js; log speed --- diff --git a/phantom-driver.js b/phantom-driver.js index 43e811c..3b2ae67 100644 --- a/phantom-driver.js +++ b/phantom-driver.js @@ -1,3 +1,9 @@ +// Invoke via: ./test.sh +// +// or phantomjs phantom-driver.js [testCase.test] +// +// For more on phantomjs, visit www.phantomjs.org. + var page = require('webpage').create(); // NOTE: Cannot include '#' or '?' in this URL. @@ -44,6 +50,7 @@ page.open(url, function(status) { var results; // Run all tests. + var start = new Date().getTime(); results = page.evaluate(function() { // Phantom doesn't like stacktrace.js using the "arguments" object // in stacktrace.js, which it interprets in strict mode. @@ -61,23 +68,31 @@ page.open(url, function(status) { } return results; }); + var end = new Date().getTime(); + var elapsed = (end - start) / 1000; var num_passing = 0, num_failing = 0; + var failures = []; for (var testCase in results) { var caseResults = results[testCase]; for (var test in caseResults) { if (caseResults[test] !== true) { - // TODO(danvk): print an auto_test/misc/local URL that runs this test. num_failing++; - console.log(testCase + '.' + test + ' failed'); + failures.push(testCase + '.' + test + ' failed'); } else { // console.log(testCase + '.' + test + ' passed'); num_passing++; } } } + + console.log('Ran ' + (num_passing + num_failing) + ' tests in ' + elapsed + 's.'); console.log(num_passing + ' test(s) passed'); - console.log(num_failing + ' test(s) failed'); + console.log(num_failing + ' test(s) failed:'); + for (var i = 0; i < failures.length; i++) { + // TODO(danvk): print an auto_test/misc/local URL that runs this test. + console.log(' ' + failures[i] + ' failed.'); + } if (num_failing == 0) { console.log('PASS');