Skip to content

Commit

Permalink
(new) tests can be 'pending'
Browse files Browse the repository at this point in the history
  • Loading branch information
cloudhead committed Jun 8, 2010
1 parent 062450c commit 11a1edd
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
3 changes: 2 additions & 1 deletion bin/vows
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ if (args.length > 0) {
// Run the matching tests and change the status.
//
function changed(file) {
status = { honored: 0, broken: 0, errored: 0 };
status = { honored: 0, broken: 0, errored: 0, pending: 0 };

msg('watcher', 'detected change in', file + '.js');

Expand Down Expand Up @@ -254,6 +254,7 @@ function runSuites(suites, callback) {
honored: 0,
broken: 0,
errored: 0,
pending: 0,
total: 0,
time: 0
};
Expand Down
5 changes: 5 additions & 0 deletions lib/vows.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ function addVow(vow) {
function runTest(args) {
var exception, topic, status;

if (vow.callback instanceof String) {
batch.pending ++;
return output('pending');
}

// Run the test, and try to catch `AssertionError`s and other exceptions;
// increment counters accordingly.
try {
Expand Down
8 changes: 5 additions & 3 deletions lib/vows/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ this.stylize = function stylize(str, style) {
'bold' : [1, 22],
'italic' : [3, 23],
'underline' : [4, 24],
'cyan' : [96, 39],
'yellow' : [33, 39],
'green' : [32, 39],
'red' : [31, 39],
Expand All @@ -30,9 +31,10 @@ this.puts = function (options) {
this.result = function (event) {
var result = event.honored + " honored, " +
event.broken + " broken, " +
event.errored + " errored",
style = event.honored === event.total ? ('green')
: (event.errored === 0 ? 'yellow' : 'red'),
event.errored + " errored, " +
event.pending + " pending",
style = event.honored === event.total ? ('green')
: (event.pending ? 'cyan' : (event.errored ? 'red' : 'yellow')),
buffer = [];


Expand Down
2 changes: 2 additions & 0 deletions lib/vows/reporters/dot-matrix.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ this.report = function (data, s) {
case 'vow':
if (event.status === 'honored') {
sys.print(stylize('.', 'green'));
} else if (event.status === 'pending') {
sys.print(stylize('.', 'cyan'));
} else {
event.context && messages.push(event.context);
if (event.status === 'broken') {
Expand Down
17 changes: 12 additions & 5 deletions lib/vows/suite.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ this.Suite.prototype = new(function () {
honored: 0,
broken: 0,
errored: 0,
pending: 0,
total: 0,
time: null
};
Expand All @@ -39,6 +40,7 @@ this.Suite.prototype = new(function () {
honored: 0,
broken: 0,
errored: 0,
pending: 0,
total: 0
});
return this;
Expand Down Expand Up @@ -71,8 +73,13 @@ this.Suite.prototype = new(function () {

if (typeof(tests[key]) === 'object') {
match = count(tests[key], match);
} else if (! match) {
tests[key]._skip = true;
} else {
if (typeof(tests[key]) === 'string') {
tests[key] = new(String)(tests[key]);
}
if (! match) {
tests[key]._skip = true;
}
}
}

Expand Down Expand Up @@ -170,7 +177,7 @@ this.Suite.prototype = new(function () {
// topic fires.
// If we encounter an object literal, we recurse, sending it
// our current context.
if (typeof(vow.callback) === 'function') {
if ((typeof(vow.callback) === 'function') || (vow.callback instanceof String)) {
topic.addVow(vow);
} else if (typeof(vow.callback) === 'object') {
// If there's a setup stage, we have to wait for it to fire,
Expand Down Expand Up @@ -267,14 +274,14 @@ this.Suite.prototype = new(function () {
this.tryEnd = function (batch) {
var result, style, time;

if (batch.honored + batch.broken + batch.errored === batch.total &&
if (batch.honored + batch.broken + batch.errored + batch.pending === batch.total &&
batch.remaining === 0) {

Object.keys(batch).forEach(function (k) {
(k in batch.suite.results) && (batch.suite.results[k] += batch[k]);
});

batch.suite.report(['end']);
batch.promise.emit('end', batch.honored, batch.broken, batch.errored);
batch.promise.emit('end', batch.honored, batch.broken, batch.errored, batch.pending);
}
};

0 comments on commit 11a1edd

Please sign in to comment.