Skip to content

Commit

Permalink
improved the process exit handler
Browse files Browse the repository at this point in the history
  • Loading branch information
beatfactor committed Jul 21, 2014
1 parent 6afd273 commit 6d414cd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 7 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,4 @@
node_modules
npm-debug.log
selenium-debug.log
phantomjsdriver.log
9 changes: 4 additions & 5 deletions bin/_clirunner.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,17 @@ CliRunner.prototype = {
// use default nightwatch.json file if we haven't received another value
if (this.cli.command('config').isDefault(this.argv.c)) {
var defaultValue = this.cli.command('config').defaults();
var deprecatedValue = SETTINGS_DEPRECTED_VAL;

if (fs.existsSync(defaultValue)) {
this.argv.c = path.join(path.resolve('./'), this.argv.c);
} else if (fs.existsSync(deprecatedValue)) {
this.argv.c = path.join(path.resolve('./'), deprecatedValue);
} else if (fs.existsSync(SETTINGS_DEPRECTED_VAL)) {
this.argv.c = path.join(path.resolve('./'), SETTINGS_DEPRECTED_VAL);
} else {
var defaultFile = path.join(__dirname, this.argv.c);
if (fs.existsSync(defaultFile)) {
this.argv.c = defaultFile;
} else {
this.argv.c = path.join(__dirname, deprecatedValue);
this.argv.c = path.join(__dirname, SETTINGS_DEPRECTED_VAL);
}
}
} else {
Expand Down Expand Up @@ -498,7 +497,7 @@ CliRunner.prototype = {
var cliArgs = self.getChildProcessArgs(mainModule);
cliArgs.push('-e', item, '__parallel-mode');
var env = process.env;

setTimeout(function() {
env.__NIGHTWATCH_PARALLEL_MODE = 1;
env.__NIGHTWATCH_ENV = item;
Expand Down
2 changes: 1 addition & 1 deletion bin/nightwatch.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"output_folder" : "./examples/reports",
"custom_commands_path" : "./examples/custom-commands",
"custom_assertions_path" : "",
"globals_path" : "./examples/globals.json",
"globals_path" : "",
"live_output" : false,

"selenium" : {
Expand Down
1 change: 1 addition & 0 deletions bin/runner.js
Original file line number Diff line number Diff line change
Expand Up @@ -93,4 +93,5 @@ try {
} catch (ex) {
Logger.error('There was an error while starting the test runner:\n');
console.log(ex.stack);
process.exit(2);
}
5 changes: 4 additions & 1 deletion lib/runner/run.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ module.exports = new (function() {
}

if (client.terminated) {
moduleCallback(null, keys);
process.exit(2);
// moduleCallback(null, keys);
} else {
setTimeout(next, 0);
}
Expand Down Expand Up @@ -234,6 +235,7 @@ module.exports = new (function() {
var use_plural = testresults.errors > 1 ? 's' : '';
errorsMsg += Logger.colors.red(testresults.errors) + ' error' + use_plural + ' during execution, ';
}

console.log(Logger.colors.light_red('\nTEST FAILURE:'), errorsMsg + Logger.colors.red(testresults.failed) +
' assertions failed, ' + Logger.colors.green(testresults.passed) + ' passed' + skipped + '.', '(' + elapsedTime + ' ms)');
}
Expand All @@ -245,6 +247,7 @@ module.exports = new (function() {
if (exitCode === 0 && (globalResults.errors > 0 || globalResults.failed > 0)) {
exitCode = 1;
}

process.exit(exitCode);
});

Expand Down

0 comments on commit 6d414cd

Please sign in to comment.