43e811c17afad126df2ffa8c47e53852f486bfe3
1 var page
= require('webpage').create();
3 // NOTE: Cannot include '#' or '?' in this URL.
4 var url
= 'auto_tests/misc/local.html';
6 // NOTE: changing the line below to this:
7 // page.open(url, function(status)) {
8 // makes phantomjs hang.
9 page
.open(url
, function(status
) {
10 if (status
!== 'success') {
11 console
.warn('Page status: ' + status
);
17 if (phantom
.args
.length
== 1) {
18 var parts
= phantom
.args
[0].split('.');
19 if (2 != parts
.length
) {
20 console
.warn('Usage: phantomjs phantom-driver.js [testCase.test]');
27 var loggingOn
= false;
28 page
.onConsoleMessage
= function (msg
) {
29 if (msg
== 'Running ' + test
) {
31 } else if (msg
.substr(0, 'Running'.length
) == 'Running') {
34 if (loggingOn
) console
.log(msg
);
37 page
.onError
= function (msg
, trace
) {
39 trace
.forEach(function(item
) {
40 console
.log(' ', item
.file
, ':', item
.line
);
47 results
= page
.evaluate(function() {
48 // Phantom doesn't like stacktrace.js using the "arguments" object
49 // in stacktrace.js, which it interprets in strict mode.
50 printStackTrace
= undefined
;
52 var testCases
= getAllTestCases();
54 for (var idx
in testCases
) {
55 var entry
= testCases
[idx
];
57 var prototype = entry
.testCase
;
58 var tc
= new entry
.testCase();
59 var result
= tc
.runAllTests();
60 results
[entry
.name
] = result
;
65 var num_passing
= 0, num_failing
= 0;
66 for (var testCase
in results
) {
67 var caseResults
= results
[testCase
];
68 for (var test
in caseResults
) {
69 if (caseResults
[test
] !== true) {
70 // TODO(danvk): print an auto_test/misc/local URL that runs
this test
.
72 console
.log(testCase
+ '.' + test
+ ' failed');
74 // console.log(testCase + '.' + test + ' passed');
79 console
.log(num_passing
+ ' test(s) passed');
80 console
.log(num_failing
+ ' test(s) failed');
82 if (num_failing
== 0) {