Skip to content
This repository has been archived by the owner on Jul 29, 2024. It is now read-only.

Commit

Permalink
fix(launcher): report summary when specs fail
Browse files Browse the repository at this point in the history
  • Loading branch information
hankduan committed Jun 19, 2014
1 parent c892c2a commit 6641c81
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions lib/launcher.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var child = require('child_process'),
TaskScheduler = require('./taskScheduler');

var launcherPrefix = '[launcher] ';
var RUNNERS_FAILED_EXIT_CODE = 100;

var log_ = function(stuff) {
console.log(launcherPrefix + stuff);
Expand All @@ -22,7 +23,7 @@ var log_ = function(stuff) {
*/
var init = function(configFile, additionalConfig) {

var launcherExitCode = 0;
var runnerErrorCount = 0;

var configParser = new ConfigParser();
if (configFile) {
Expand Down Expand Up @@ -95,14 +96,14 @@ var init = function(configFile, additionalConfig) {
this.process.on('error', function(err) {
self.reporter.flush();
log_('Runner Process(' + self.process.pid + ') Error: ' + err);
launcherExitCode = 1;
runnerErrorCount += 1;
});

this.process.on('exit', function(code) {
self.reporter.flush();
if (code) {
log_('Runner Process Exited With Error Code: ' + code);
launcherExitCode = 1;
runnerErrorCount += 1;
}
log_(scheduler.countActiveTasks() +
' instance(s) of WebDriver still running');
Expand Down Expand Up @@ -161,17 +162,20 @@ var init = function(configFile, additionalConfig) {
log_('Running ' + scheduler.countActiveTasks() + ' instances of WebDriver');

process.on('exit', function(code) {
launcherExitCode = code ? code : launcherExitCode;
if (launcherExitCode) {
log_('Process exited with error code ' + launcherExitCode);
if (code) {
log_('Process exited with error code ' + code);
process.exit(code);
} else if (runnerErrorCount > 0) {
reporter.reportSummary();
process.exit(RUNNERS_FAILED_EXIT_CODE);
} else {
if (scheduler.numTasksRemaining() > 0) {
throw new Error('BUG: launcher exited with ' +
scheduler.numTasksRemaining() + ' tasks remaining');
scheduler.numTasksRemaining() + ' tasks remaining');
}
reporter.reportSummary();
process.exit(0);
}
process.exit(launcherExitCode);
});
}
};
Expand Down

0 comments on commit 6641c81

Please sign in to comment.