Skip to content

Commit

Permalink
getting further into the child ordering test
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed May 2, 2013
1 parent b1c1d6a commit 365ceab
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion lib/results.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,9 @@ module.exports = function (test) {

nextTick(function next () {
var t = results.tests.shift();
if (!t && results.subtests) return;
if (!t) return results.close();
t.on('end', function () { nextTick(next) });
t.on('end', next);
t.run();
});

Expand All @@ -30,6 +31,7 @@ function Results (stream) {
this.pass = 0;
this.stream = stream;
this.tests = [];
this.subtests = 0;
}

Results.prototype.push = function (t, parentT) {
Expand All @@ -50,8 +52,10 @@ Results.prototype.push = function (t, parentT) {
var subtests = 0;
t.on('test', function (st) {
subtests ++;
self.subtests ++;
st.on('end', function () {
subtests --;
self.subtests --;
if (subtests === 0 && !plan) t.emit('end');
nextTick(function () { onend.call(t) });
});
Expand Down

0 comments on commit 365ceab

Please sign in to comment.