forked from apiaryio/dredd
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Collecting coverage stats also in the Dredd binary.
Making sure coverage is picking up integration tests using ./bin/dredd.
- Loading branch information
1 parent
f4ad156
commit 11f5ca3
Showing
12 changed files
with
126 additions
and
55 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 |
---|---|---|
@@ -1,7 +1,9 @@ | ||
node_modules | ||
src-cov | ||
CHANGELOG-Generated.md | ||
/lib | ||
/src-cov | ||
/lcov | ||
cov.info | ||
cov.html | ||
.vagrant | ||
*.DS_Store | ||
|
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
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 | ||
|
||
// This is a special version of ./bin/dredd, which is used as Dredd binary | ||
// during integration tests. It collects coverage stats and saves them in file. | ||
|
||
var fs = require('fs'); | ||
|
||
var DreddCommand = require('../src/dredd-command'); | ||
|
||
|
||
var dreddCli = new DreddCommand({ | ||
custom: { | ||
cwd: process.cwd(), | ||
argv: process.argv.slice(2) | ||
}, | ||
exit: function(exitStatus) { | ||
// Before Dredd exits, we need to collect coverage stats and save them to | ||
// a file. We abuse 'mocha-lcov-reporter' to do this. | ||
|
||
// Pretending there is Mocha runner | ||
var EventEmitter = require('events').EventEmitter; | ||
var runner = new EventEmitter(); | ||
|
||
// Monkey-patching 'process.stdout.write' to catch all stdout in a variable | ||
var content = ''; | ||
var write = process.stdout.write; | ||
process.stdout.write = function(stdout) { | ||
content += stdout; | ||
}; | ||
|
||
// Collecting the stats | ||
var LCov = require('mocha-lcov-reporter'); | ||
LCov(runner); | ||
runner.emit('end'); | ||
|
||
// Undo the monkey-patching | ||
process.stdout.write = write; | ||
|
||
// Save stats as lcov file | ||
fs.appendFile('./lcov/dredd-bin.info', content, function (err) { | ||
if (err) { console.error(err); } | ||
process.exit(exitStatus); | ||
}); | ||
} | ||
}); | ||
|
||
|
||
dreddCli.run(); |
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
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
This file was deleted.
Oops, something went wrong.
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
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
Oops, something went wrong.