better exit status code handling on failed test suite
Showing
2 changed files
with
8 additions
and
2 deletions
... | @@ -433,6 +433,7 @@ var Tester = function(casper, options) { | ... | @@ -433,6 +433,7 @@ var Tester = function(casper, options) { |
433 | this.renderResults = function renderResults(exit, status, save) { | 433 | this.renderResults = function renderResults(exit, status, save) { |
434 | save = utils.isString(save) ? save : this.options.save; | 434 | save = utils.isString(save) ? save : this.options.save; |
435 | var total = this.testResults.passed + this.testResults.failed, statusText, style, result; | 435 | var total = this.testResults.passed + this.testResults.failed, statusText, style, result; |
436 | var exitStatus = ~~(status || (this.testResults.failed > 0 ? 1 : 0)); | ||
436 | if (total === 0) { | 437 | if (total === 0) { |
437 | statusText = this.options.failText; | 438 | statusText = this.options.failText; |
438 | style = 'RED_BAR'; | 439 | style = 'RED_BAR'; |
... | @@ -461,7 +462,8 @@ var Tester = function(casper, options) { | ... | @@ -461,7 +462,8 @@ var Tester = function(casper, options) { |
461 | } | 462 | } |
462 | } | 463 | } |
463 | if (exit === true) { | 464 | if (exit === true) { |
464 | casper.exit(status || (this.testResults.failed > 0 ? 1 : 0)); | 465 | console.log('exiting with status: ' + exitStatus); |
466 | casper.exit(~~exitStatus); | ||
465 | } | 467 | } |
466 | }; | 468 | }; |
467 | 469 | ||
... | @@ -494,7 +496,7 @@ var Tester = function(casper, options) { | ... | @@ -494,7 +496,7 @@ var Tester = function(casper, options) { |
494 | return; | 496 | return; |
495 | } | 497 | } |
496 | if (current === testFiles.length) { | 498 | if (current === testFiles.length) { |
497 | self.renderResults(true); | 499 | self.emit('tests.complete'); |
498 | clearInterval(interval); | 500 | clearInterval(interval); |
499 | } else { | 501 | } else { |
500 | self.runTest(testFiles[current]); | 502 | self.runTest(testFiles[current]); | ... | ... |
... | @@ -29,4 +29,8 @@ if (casper.cli.args.length) { | ... | @@ -29,4 +29,8 @@ if (casper.cli.args.length) { |
29 | casper.exit(1); | 29 | casper.exit(1); |
30 | } | 30 | } |
31 | 31 | ||
32 | casper.test.on('tests.complete', function() { | ||
33 | this.renderResults(true); | ||
34 | }); | ||
35 | |||
32 | casper.test.runSuites.apply(casper.test, tests); | 36 | casper.test.runSuites.apply(casper.test, tests); | ... | ... |
-
Please register or sign in to post a comment