Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 750037e
Showing
3 changed files
with
89 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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); |