Skip to content

Commit

Permalink
added support for TAP bail outs
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlapp authored and ljharb committed Aug 5, 2016
1 parent 0d7e916 commit fa3c290
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
4 changes: 2 additions & 2 deletions bin/cmd.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var jsFile = regexTester(/\.js$/i);

var faucetArgs = [];
var opts = [];
faucetArgs.forEach(function (arg) {
if (arg.length > 1 && arg.charAt(0) === '-') {
process.argv.slice(2).forEach(function(arg) {
if (arg !== '-' && arg[0] === '-') {
opts.push(arg);
} else {
faucetArgs.push(arg);
Expand Down
12 changes: 11 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ module.exports = function (opts) {
}

var test;
var bailout = null;

tap.on('comment', function (comment) {
if (comment === 'fail 0') { return; } // a mocha thing
Expand Down Expand Up @@ -87,6 +88,12 @@ module.exports = function (opts) {
});

tap.on('extra', function (extra) {
if (/^bail out!/i.test(extra)) {
// faucet is incompatible with tap-parser that supports bail out
bailout = extra;
return;
}

if (!test || test.assertions.length === 0) { return; }
var last = test.assertions[test.assertions.length - 1];
if (!last.ok) {
Expand Down Expand Up @@ -123,7 +130,10 @@ module.exports = function (opts) {
(res.errors.length + res.fail.length) || ''
));
}


if (bailout !== null) {
out.push('\r\x1b[1m\x1b[31m- '+ bailout + '\x1b[0m\x1b[K\n');
}
out.push(null);

dup.emit('results', res);
Expand Down

0 comments on commit fa3c290

Please sign in to comment.