Skip to content

Commit 361ecb6

Browse files
author
James Halliday
committed
clean up the global harness exit interval
1 parent c85294a commit 361ecb6

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

index.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ exports = module.exports = createHarness();
2020
exports.createHarness = createHarness;
2121
exports.Test = Test;
2222

23+
var exitInterval;
24+
2325
function createHarness (conf_) {
2426
var pending = [];
2527
var running = false;
@@ -32,7 +34,9 @@ function createHarness (conf_) {
3234
if (!conf_) conf_ = {};
3335

3436
var tests = [];
35-
var exitInterval = conf_.exitInterval !== false && canEmitExit
37+
if (conf_.exit === false && exitInterval) clearInterval(exitInterval);
38+
39+
exitInterval = !exitInterval && conf_.exit !== false && canEmitExit
3640
&& typeof process._getActiveHandles === 'function'
3741
&& setInterval(function () {
3842
if (process._getActiveHandles().length === 1) {
@@ -45,7 +49,7 @@ function createHarness (conf_) {
4549

4650
out.on('end', function () {
4751
clearInterval(exitInterval);
48-
process.exit(exitCode);
52+
if (conf_.exit !== false) process.exit(exitCode);
4953
});
5054

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

98103
t.on('end', onend);
99104

0 commit comments

Comments
 (0)