Skip to content

Commit

Permalink
Add back to do not call exit() if error semantics.
Browse files Browse the repository at this point in the history
The previous commit removed the uncaught exception interception.
However that code was needed to get the process to write the
uncaught stack trace on failures.

Since messing with uncaught exception messes with the way we
exit the only way to know if exit is called from uncaught exception
is to monkey patch node core and keep track of the state
  • Loading branch information
Raynos committed Dec 14, 2014
1 parent dd661b0 commit 9c60d32
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,8 +64,20 @@ function createExitHarness (conf) {
if (conf.exit === false) return harness;
if (!canEmitExit || !canExit) return harness;

var inErrorState = false;

var $_fatalException = process._fatalException
process._fatalException = function fakeFatalException() {
inErrorState = true;
$_fatalException.apply(this, arguments)
}

process.on('exit', function (code) {
// let the process exit cleanly.
if (inErrorState) {
return
}

if (!ended) {
var only = harness._results._only;
for (var i = 0; i < harness._tests.length; i++) {
Expand Down

0 comments on commit 9c60d32

Please sign in to comment.