Skip to content

Commit

Permalink
basic tap output works
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Nov 25, 2012
1 parent 31dae7d commit 53ab0e8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 8 deletions.
5 changes: 5 additions & 0 deletions lib/defined.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
module.exports = function () {
for (var i = 0; i < arguments.length; i++) {
if (arguments[i] !== undefined) return arguments[i];
}
};
19 changes: 17 additions & 2 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ module.exports = Render;
function Render () {
Stream.call(this);
this.readable = true;
this.count = 0;
}

Render.prototype = new Stream;
Expand All @@ -14,11 +15,25 @@ Render.prototype.begin = function () {
};

Render.prototype.push = function (t) {
var self = this;
t.on('result', function (res) {
console.dir(res);
self.emit('data', encodeResult(res, self.count + 1));
self.count ++;
});
};

Render.prototype.close = function () {
console.log('__END__');
this.emit('end');
};

function encodeResult (res, count) {
var output = '';
output += (res.ok ? 'ok ' : 'not ok ') + count;
output += res.name ? ' ' + res.name.replace(/\s+/g, ' ') : '';

if (res.skip) output += ' # SKIP';
else if (res.todo) output += ' # TODO';

output += '\n';
return output;
}
7 changes: 1 addition & 6 deletions lib/test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var EventEmitter = require('events').EventEmitter;
var deepEqual = require('deep-equal');
var defined = require('./defined');

module.exports = Test;

Expand Down Expand Up @@ -227,9 +228,3 @@ Test.prototype.doesNotThrow = function (fn, expected, msg, extra) {
extra : extra
});
};

function defined () {
for (var i = 0; i < arguments.length; i++) {
if (arguments[i] !== undefined) return arguments[i];
}
}

0 comments on commit 53ab0e8

Please sign in to comment.