Skip to content

Commit

Permalink
trailing tap data
Browse files Browse the repository at this point in the history
  • Loading branch information
James Halliday committed Nov 25, 2012
1 parent 53ab0e8 commit 463afd2
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 2 deletions.
4 changes: 2 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@ function createHarness () {
conf = {};
}
var t = new Test;
out.push(t);

t.name = name;
var piped = false;

t.pipe = function () {
Expand All @@ -35,6 +34,7 @@ function createHarness () {

var run = function () {
running = true;
out.push(t);
cb(t);
};

Expand Down
17 changes: 17 additions & 0 deletions lib/render.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ function Render () {
Stream.call(this);
this.readable = true;
this.count = 0;
this.fail = 0;
this.pass = 0;
}

Render.prototype = new Stream;
Expand All @@ -16,13 +18,28 @@ Render.prototype.begin = function () {

Render.prototype.push = function (t) {
var self = this;
this.emit('data', '# ' + t.name + '\n');

t.on('result', function (res) {
self.emit('data', encodeResult(res, self.count + 1));
self.count ++;

if (res.ok) self.pass ++
else self.fail ++
});
};

Render.prototype.close = function () {
this.emit('data', '\n1..' + this.count + '\n');
this.emit('data', '# tests ' + this.count + '\n');
this.emit('data', '# pass ' + this.pass + '\n');
if (this.fail) {
this.emit('data', '# fail ' + this.fail + '\n');
}
else {
this.emit('data', '\n# ok\n');
}

this.emit('end');
};

Expand Down

0 comments on commit 463afd2

Please sign in to comment.