Skip to content

Commit 073e875

Browse files
author
cloudhead
committed
ability to reset batch/suite
1 parent bd8a4f8 commit 073e875

File tree

1 file changed

+24
-9
lines changed

1 file changed

+24
-9
lines changed

lib/vows/suite.js

+24-9
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,40 @@
11
var events = require('events'),
22
path = require('path');
33

4-
var vows = require(path.join(__dirname, '..', 'vows'));
4+
require.paths.unshift(path.join(__dirname, '..'));
5+
6+
var vows = require('vows');
57
var Context = require('vows/context').Context;
68
var tryEnd = vows.tryEnd;
79

8-
this.Suite = function () {
9-
this.results = {
10-
honored: 0,
11-
broken: 0,
12-
errored: 0,
13-
total: 0,
14-
time: null
15-
};
10+
this.Suite = function (subject) {
11+
this.subject = subject;
1612
this.batches = [];
13+
this.reset();
1714
};
1815

1916
this.Suite.prototype = new(function () {
17+
this.reset = function () {
18+
this.results = {
19+
honored: 0,
20+
broken: 0,
21+
errored: 0,
22+
total: 0,
23+
time: null
24+
};
25+
this.batches.forEach(function (b) {
26+
b.lastContext = null;
27+
b.remaining = b._remaining;
28+
b.honored = b.broken = b.errored = b.total = 0;
29+
});
30+
};
31+
2032
this.addVows = function (tests) {
2133
var batch = {
2234
tests: tests,
2335
suite: this,
2436
remaining: 0,
37+
_remaining: 0,
2538
honored: 0,
2639
broken: 0,
2740
errored: 0,
@@ -55,6 +68,7 @@ this.Suite.prototype = new(function () {
5568
return match;
5669
})(tests);
5770
}
71+
batch._remaining = batch.remaining;
5872

5973
return this;
6074
};
@@ -189,6 +203,7 @@ this.Suite.prototype = new(function () {
189203
process.stdout.addListener('drain', function () {
190204
process.exit(that.results.broken || that.results.errored ? 1 : 0);
191205
});
206+
that.reset();
192207
}
193208
})(this.batches.slice(0));
194209
};

0 commit comments

Comments
 (0)