Skip to content

Commit

Permalink
passing one more of the exit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed May 3, 2013
1 parent 876930e commit 5ec8f42
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ exports = module.exports = (function () {
if (!harness) {
harness = createHarness();
harness.createStream().pipe(createDefaultStream());

if (process.exit && process._getActiveHandles) {
var iv = setInterval(function () {
if (process._getActiveHandles().length > 1) return;
clearInterval(iv);
setTimeout(function () {
process.exit(harness._exitCode);
}, 100);
});
}
}
return harness.apply(this, arguments);
};
Expand All @@ -32,7 +42,6 @@ exports.test = exports; // tap compat
var exitInterval;

function createHarness (conf_) {
var exitCode = 0;
var results;

var test = function (name, conf, cb) {
Expand All @@ -47,7 +56,7 @@ function createHarness (conf_) {
inspectCode(st_);
});
st.on('result', function (r) {
if (!r.ok) exitCode = 1
if (!r.ok) test._exitCode = 1
});
})(t);

Expand All @@ -68,6 +77,7 @@ function createHarness (conf_) {
only = true;
return test.apply(null, arguments);
};
test._exitCode = 0;

return test;
}

0 comments on commit 5ec8f42

Please sign in to comment.