Skip to content

Commit

Permalink
better remaining vow detection and handling
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Jun 5, 2010
1 parent b3985d8 commit 09e31cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
4 changes: 3 additions & 1 deletion lib/vows.js
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,9 @@ function addVow(vow) {
// If not, report an error message.
//
process.addListener('exit', function () {
if (vows.suites.filter(function (s) { return s.results.time === null }).length > 0) {
if (vows.suites.filter(function (s) {
return (s.results.total > 0) && (s.results.time === null)
}).length > 0) {
vows.reporter.report(['error', { error: "An EventEmitter has failed to fire.", type: 'promise' }]);
}
});
Expand Down
22 changes: 16 additions & 6 deletions lib/vows/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,8 +171,10 @@ this.Suite.prototype = new(function () {
}
}
});
if (! ctx.tests._skip) {
batch.remaining --;
}
// Check if we're done running the tests
batch.remaining --;
exports.tryEnd(batch);
// This is our initial, empty context
})(new(Context)({ callback: tests, context: null, description: null }, {}));
Expand All @@ -197,15 +199,23 @@ this.Suite.prototype = new(function () {

start = new(Date);

this.report(['subject', this.subject]);
if (this.batches.filter(function (b) { return b.remaining > 0 }).length) {
this.report(['subject', this.subject]);
}

(function run(batches) {
var batch;
var batch = batches.shift();

if (batch = batches.shift()) {
that.runVows(batch).addListener('end', function () {
if (batch) {
// If the batch has no vows to run,
// go to the next one.
if (batch.remaining === 0) {
run(batches);
});
} else {
that.runVows(batch).addListener('end', function () {
run(batches);
});
}
} else {
that.results.time = (new(Date) - start) / 1000;

Expand Down

0 comments on commit 09e31cf

Please sign in to comment.