Skip to content

Commit

Permalink
fix context reporting for dot-matrix
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Jun 9, 2010
1 parent 3e67750 commit c533efa
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 16 deletions.
4 changes: 4 additions & 0 deletions bin/vows
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ if (args.length > 0) {
options.verbose ? _reporter.print('\n') : _reporter.print(' ');
}
};
reporter.reset = function () { _reporter.reset && _reporter.reset() };

suites = args.map(function (a) {
a = path.join(process.cwd(), a.replace(/\.js$/, ''));
msg('runner', "loading", a);
Expand Down Expand Up @@ -257,6 +259,8 @@ function runSuites(suites, callback) {
total: 0,
time: 0
};
reporter.reset();

(function run(suites, callback) {
var suite = suites.shift();
if (suite) {
Expand Down
22 changes: 9 additions & 13 deletions lib/vows.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,20 +110,16 @@ function addVow(vow) {
}

function output(status, exception) {
var context;

if (exception) {
if (vow.context && batch.lastContext !== vow.context) {
batch.lastContext = context = vow.context;
batch.suite.report(['context', context]);
}
batch.suite.report(['vow', {
title: vow.description,
context: context,
status: status,
exception: exception || null
}]);
if (vow.context && batch.lastContext !== vow.context) {
batch.lastContext = vow.context;
batch.suite.report(['context', vow.context]);
}
batch.suite.report(['vow', {
title: vow.description,
context: vow.context,
status: status,
exception: exception || null
}]);
}
};

Expand Down
11 changes: 9 additions & 2 deletions lib/vows/reporters/dot-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,13 @@ var stylize = console.stylize,
//
// Console reporter
//
var stream, messages = [];
var stream, messages = [], lastContext;

this.name = 'dot-matrix';
this.reset = function () {
messages = [];
lastContext = null;
};
this.report = function (data, s) {
var event = data[1];

Expand All @@ -28,7 +32,10 @@ this.report = function (data, s) {
} else if (event.status === 'pending') {
sys.print(stylize('.', 'cyan'));
} else {
event.context && messages.push(event.context);
if (lastContext !== event.context) {
lastContext = event.context;
messages.push(event.context);
}
if (event.status === 'broken') {
sys.print(stylize('B', 'yellow'));
messages.push(' - ' + stylize(event.title, 'yellow'));
Expand Down
10 changes: 9 additions & 1 deletion lib/vows/reporters/watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ var stylize = console.stylize,
//
// Console reporter
//
var lastContext;

this.name = 'watch';
this.reset = function () {
lastContext = null;
};
this.report = function (data) {
var event = data[1];

Expand All @@ -16,7 +21,10 @@ this.report = function (data) {
switch (data[0]) {
case 'vow':
if (event.status !== 'honored') {
event.context && puts(event.context);
if (lastContext !== event.context) {
lastContext = event.context;
puts(event.context);
}
if (event.status === 'broken') {
puts(' - ' + stylize(event.title, 'yellow'));
puts(' ~ ' + event.exception);
Expand Down

0 comments on commit c533efa

Please sign in to comment.