Commit 66a880f9 66a880f9d31607afd92142549ebddde479a6a461 by Nicolas Perriault

better exit status code handling on failed test suite

1 parent 3ffc42fa
......@@ -433,6 +433,7 @@ var Tester = function(casper, options) {
this.renderResults = function renderResults(exit, status, save) {
save = utils.isString(save) ? save : this.options.save;
var total = this.testResults.passed + this.testResults.failed, statusText, style, result;
var exitStatus = ~~(status || (this.testResults.failed > 0 ? 1 : 0));
if (total === 0) {
statusText = this.options.failText;
style = 'RED_BAR';
......@@ -461,7 +462,8 @@ var Tester = function(casper, options) {
}
}
if (exit === true) {
casper.exit(status || (this.testResults.failed > 0 ? 1 : 0));
console.log('exiting with status: ' + exitStatus);
casper.exit(~~exitStatus);
}
};
......@@ -494,7 +496,7 @@ var Tester = function(casper, options) {
return;
}
if (current === testFiles.length) {
self.renderResults(true);
self.emit('tests.complete');
clearInterval(interval);
} else {
self.runTest(testFiles[current]);
......
......@@ -29,4 +29,8 @@ if (casper.cli.args.length) {
casper.exit(1);
}
casper.test.on('tests.complete', function() {
this.renderResults(true);
});
casper.test.runSuites.apply(casper.test, tests);
......