Skip to content

Commit

Permalink
ability to reset batch/suite
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Jun 4, 2010
1 parent bd8a4f8 commit 073e875
Showing 1 changed file with 24 additions and 9 deletions.
33 changes: 24 additions & 9 deletions lib/vows/suite.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,40 @@
var events = require('events'),
path = require('path');

var vows = require(path.join(__dirname, '..', 'vows'));
require.paths.unshift(path.join(__dirname, '..'));

var vows = require('vows');
var Context = require('vows/context').Context;
var tryEnd = vows.tryEnd;

this.Suite = function () {
this.results = {
honored: 0,
broken: 0,
errored: 0,
total: 0,
time: null
};
this.Suite = function (subject) {
this.subject = subject;
this.batches = [];
this.reset();
};

this.Suite.prototype = new(function () {
this.reset = function () {
this.results = {
honored: 0,
broken: 0,
errored: 0,
total: 0,
time: null
};
this.batches.forEach(function (b) {
b.lastContext = null;
b.remaining = b._remaining;
b.honored = b.broken = b.errored = b.total = 0;
});
};

this.addVows = function (tests) {
var batch = {
tests: tests,
suite: this,
remaining: 0,
_remaining: 0,
honored: 0,
broken: 0,
errored: 0,
Expand Down Expand Up @@ -55,6 +68,7 @@ this.Suite.prototype = new(function () {
return match;
})(tests);
}
batch._remaining = batch.remaining;

return this;
};
Expand Down Expand Up @@ -189,6 +203,7 @@ this.Suite.prototype = new(function () {
process.stdout.addListener('drain', function () {
process.exit(that.results.broken || that.results.errored ? 1 : 0);
});
that.reset();
}
})(this.batches.slice(0));
};
Expand Down

0 comments on commit 073e875

Please sign in to comment.