Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
clux committed Jun 13, 2012
0 parents commit 750037e
Show file tree
Hide file tree
Showing 3 changed files with 89 additions and 0 deletions.
23 changes: 23 additions & 0 deletions Readme.md
@@ -0,0 +1,23 @@
# tap-pessimist
A small command line filtration tool for filtering some of the constant spam from node-tap.

## Usage

````bash
producerApp | tap-pessimist
````

or

````bash
cat log.txt | tap-pessimist
````

## Installation

````
npm install tap-pessimist
````

## License
MIT-Licensed. See license file for details.
18 changes: 18 additions & 0 deletions package.json
@@ -0,0 +1,18 @@
{
"author": "Eirik Albrigtsen <analsandblaster@gmail.com>",
"name": "tap-pessimist",
"description": "A tap consumer that filters out all the ok spam, and just focuses on the negatives : (",
"version": "0.0.0",
"repository": {
"url": ""
},
"main": "tapno.js",
"engines": {
"node": "~0.6.7"
},
"dependencies": {
"tap": "~0.2.5",
"logule": "~0.6.1"
},
"devDependencies": {}
}
48 changes: 48 additions & 0 deletions tapno.js
@@ -0,0 +1,48 @@
#!/usr/bin/env node

/**
* Consumer for TAP compliant output
*
* Usage:
* a) producerApp | tap-pessimist
* b) cat log.txt | tap-pessimist
*/

var tap = require('tap')
, log = require('logule')
, consumer = new tap.Consumer(); // inherits from Stream

var num = 0, fails = 0;

consumer.on('plan', function (end, comment) {
log.info('Test plan: [1..' + end + ']', (comment) ? ': ' + comment : '');
});

consumer.on('data', function (data) {
if (Object(data) === data) {
// comments get here, but not non-tap compliant stuff
num += 1;
if (!data.ok) {
fails += 1;
log.sub('#' + data.id).error(data.name); // might as well highlight id of failed tests
}
}
});

consumer.on('bailout', function (reason) {
log.error("Bailed out after", num, "messages,", fails, 'failures. because:', reason);
process.exit();
});

consumer.on('end', function () {
if (fails > 0) {
log.warn('output terminated - ' + fails + ' errors');
}
else {
log.info('output terminated - all ' + num + ' messages verified');
}
process.exit();
});

process.stdin.resume();
process.stdin.pipe(consumer);

0 comments on commit 750037e

Please sign in to comment.