From b494b188dc4f909ec7ca085e299fefe247d7b1c0 Mon Sep 17 00:00:00 2001 From: Bill Ticehurst Date: Thu, 27 Apr 2017 12:14:04 -0700 Subject: [PATCH 1/2] [Fix] Stop createStream for creating additional test runner loops --- lib/results.js | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/lib/results.js b/lib/results.js index 56fdc4ba..0531a101 100644 --- a/lib/results.js +++ b/lib/results.js @@ -24,6 +24,7 @@ function Results () { this._stream = through(); this.tests = []; this._only = null; + this._isRunning = false; } Results.prototype.createStream = function (opts) { @@ -65,14 +66,17 @@ Results.prototype.createStream = function (opts) { self._stream.pipe(output); } - nextTick(function next() { - var t; - while (t = getNextTest(self)) { - t.run(); - if (!t.ended) return t.once('end', function(){ nextTick(next); }); - } - self.emit('done'); - }); + if (!this._isRunning) { + this._isRunning = true; + nextTick(function next() { + var t; + while (t = getNextTest(self)) { + t.run(); + if (!t.ended) return t.once('end', function(){ nextTick(next); }); + } + self.emit('done'); + }); + } return output; }; From fa586b445cef771d688ee6287f07b19cae30ca19 Mon Sep 17 00:00:00 2001 From: Norman Date: Sun, 15 Oct 2017 13:24:05 -0700 Subject: [PATCH 2/2] [Test]: only use one test runner for results, even if multiple streams are created Fixes #105. --- test/create_multiple_streams.js | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 test/create_multiple_streams.js diff --git a/test/create_multiple_streams.js b/test/create_multiple_streams.js new file mode 100644 index 00000000..4b87d044 --- /dev/null +++ b/test/create_multiple_streams.js @@ -0,0 +1,31 @@ +var tape = require('../'); + +tape.test('createMultipleStreams', function(tt) { + tt.plan(2); + + var th = tape.createHarness(); + th.createStream() + th.createStream() + + var testOneComplete = false; + + th('test one', function (tht) { + tht.plan(1); + setTimeout( function() { + tht.pass(); + testOneComplete = true; + }, 100); + }); + + th('test two', function (tht) { + tht.ok(testOneComplete, 'test 1 completed before test 2'); + tht.end(); + }); + + th.onFinish(function() { + tt.equal(th._results.count, 2, "harness test ran"); + tt.equal(th._results.fail, 0, "harness test didn't fail"); + }); +}); + +