Skip to content

Commit

Permalink
clean up the global harness exit interval
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Mar 25, 2013
1 parent c85294a commit 361ecb6
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ exports = module.exports = createHarness();
exports.createHarness = createHarness;
exports.Test = Test;

var exitInterval;

function createHarness (conf_) {
var pending = [];
var running = false;
Expand All @@ -32,7 +34,9 @@ function createHarness (conf_) {
if (!conf_) conf_ = {};

var tests = [];
var exitInterval = conf_.exitInterval !== false && canEmitExit
if (conf_.exit === false && exitInterval) clearInterval(exitInterval);

exitInterval = !exitInterval && conf_.exit !== false && canEmitExit
&& typeof process._getActiveHandles === 'function'
&& setInterval(function () {
if (process._getActiveHandles().length === 1) {
Expand All @@ -45,7 +49,7 @@ function createHarness (conf_) {

out.on('end', function () {
clearInterval(exitInterval);
process.exit(exitCode);
if (conf_.exit !== false) process.exit(exitCode);
});

var test = function (name, conf, cb) {
Expand Down Expand Up @@ -94,6 +98,7 @@ function createHarness (conf_) {
st.on('test', sub);
st.on('end', onend);
});
t.on('result', function (r) { if (!r.ok) exitCode = 1 });

t.on('end', onend);

Expand Down

0 comments on commit 361ecb6

Please sign in to comment.