Skip to content

Commit c533efa

Browse files
author
cloudhead
committed
fix context reporting for dot-matrix
1 parent 3e67750 commit c533efa

File tree

4 files changed

+31
-16
lines changed

4 files changed

+31
-16
lines changed

bin/vows

+4
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,8 @@ if (args.length > 0) {
8383
options.verbose ? _reporter.print('\n') : _reporter.print(' ');
8484
}
8585
};
86+
reporter.reset = function () { _reporter.reset && _reporter.reset() };
87+
8688
suites = args.map(function (a) {
8789
a = path.join(process.cwd(), a.replace(/\.js$/, ''));
8890
msg('runner', "loading", a);
@@ -257,6 +259,8 @@ function runSuites(suites, callback) {
257259
total: 0,
258260
time: 0
259261
};
262+
reporter.reset();
263+
260264
(function run(suites, callback) {
261265
var suite = suites.shift();
262266
if (suite) {

lib/vows.js

+9-13
Original file line numberDiff line numberDiff line change
@@ -110,20 +110,16 @@ function addVow(vow) {
110110
}
111111

112112
function output(status, exception) {
113-
var context;
114-
115-
if (exception) {
116-
if (vow.context && batch.lastContext !== vow.context) {
117-
batch.lastContext = context = vow.context;
118-
batch.suite.report(['context', context]);
119-
}
120-
batch.suite.report(['vow', {
121-
title: vow.description,
122-
context: context,
123-
status: status,
124-
exception: exception || null
125-
}]);
113+
if (vow.context && batch.lastContext !== vow.context) {
114+
batch.lastContext = vow.context;
115+
batch.suite.report(['context', vow.context]);
126116
}
117+
batch.suite.report(['vow', {
118+
title: vow.description,
119+
context: vow.context,
120+
status: status,
121+
exception: exception || null
122+
}]);
127123
}
128124
};
129125

lib/vows/reporters/dot-matrix.js

+9-2
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@ var stylize = console.stylize,
88
//
99
// Console reporter
1010
//
11-
var stream, messages = [];
11+
var stream, messages = [], lastContext;
1212

1313
this.name = 'dot-matrix';
14+
this.reset = function () {
15+
messages = [];
16+
lastContext = null;
17+
};
1418
this.report = function (data, s) {
1519
var event = data[1];
1620

@@ -28,7 +32,10 @@ this.report = function (data, s) {
2832
} else if (event.status === 'pending') {
2933
sys.print(stylize('.', 'cyan'));
3034
} else {
31-
event.context && messages.push(event.context);
35+
if (lastContext !== event.context) {
36+
lastContext = event.context;
37+
messages.push(event.context);
38+
}
3239
if (event.status === 'broken') {
3340
sys.print(stylize('B', 'yellow'));
3441
messages.push(' - ' + stylize(event.title, 'yellow'));

lib/vows/reporters/watch.js

+9-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,12 @@ var stylize = console.stylize,
77
//
88
// Console reporter
99
//
10+
var lastContext;
11+
1012
this.name = 'watch';
13+
this.reset = function () {
14+
lastContext = null;
15+
};
1116
this.report = function (data) {
1217
var event = data[1];
1318

@@ -16,7 +21,10 @@ this.report = function (data) {
1621
switch (data[0]) {
1722
case 'vow':
1823
if (event.status !== 'honored') {
19-
event.context && puts(event.context);
24+
if (lastContext !== event.context) {
25+
lastContext = event.context;
26+
puts(event.context);
27+
}
2028
if (event.status === 'broken') {
2129
puts(' - ' + stylize(event.title, 'yellow'));
2230
puts(' ~ ' + event.exception);

0 commit comments

Comments
 (0)