Skip to content

Commit

Permalink
detect un-fired vows on exit, and report error
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Jun 17, 2010
1 parent e1d1ea5 commit 3d1217a
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
22 changes: 21 additions & 1 deletion lib/vows.js
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,31 @@ process.addListener('exit', function () {
vows.reporter.report(['error', { error: "Asynchronous Error", suite: s }]);
}
s.batches.forEach(function (b) {
var unFired = [];

b.vows.forEach(function (vow) {
if (! vow.status) {
if (unFired.indexOf(vow.context) === -1) {
unFired.push(vow.context);
}
}
});

if (unFired.length > 0) { sys.print('\n') }

unFired.forEach(function (title) {
sys.puts(console.error({
error: "not fired!",
context: title,
batch: b,
suite: s
}));
});

if (b.status === 'begin') {
failure = true;
results.errored ++;
results.total ++;
vows.reporter.report(['error', { error: "A callback hasn't fired", batch: b, suite: s }]);
}
Object.keys(results).forEach(function (k) { results[k] += b[k] });
});
Expand Down
5 changes: 5 additions & 0 deletions lib/vows/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,3 +72,8 @@ this.result = function (event) {
this.inspect = function inspect(val) {
return '\033[1m' + eyes(val) + '\033[22m';
};

this.error = function (obj) {
return '✗ ' + $('Errored ').red + '» '
+ $('' + $(obj.context).italic + ' ∙ ' + obj.error).red;
};

0 comments on commit 3d1217a

Please sign in to comment.