-
Notifications
You must be signed in to change notification settings - Fork 64
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #218 from hammerlab/restore-coverage
Generate coverage data using Istanbul
- Loading branch information
Showing
4 changed files
with
43 additions
and
2 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
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,36 @@ | ||
#!/bin/bash | ||
# Generate code coverage data for posting to Coveralls. | ||
# This requires dist/*.js to be in place. | ||
# Output is coverage/lcov.info | ||
|
||
set -o errexit | ||
set -x | ||
|
||
# Instrument the source code with Istanbul's __coverage__ variable. | ||
rm -rf coverage/* # Clear out everything to ensure a hermetic run. | ||
istanbul instrument --output coverage/main dist/main | ||
cp -r dist/test coverage/test # test code needn't be covered | ||
|
||
# Build a combined file for running the tests in-browser | ||
browserify coverage/**/*.js -o coverage/tests.js | ||
|
||
# Run http-server and save its PID for cleanup | ||
npm run http-server > /dev/null & | ||
SERVER_PID=$! | ||
function finish() { | ||
pkill -TERM -P $SERVER_PID | ||
} | ||
trap finish EXIT | ||
|
||
# Run the tests using mocha-phantomjs & mocha-phantomjs-istanbul | ||
# This produces coverage/coverage.json | ||
phantomjs \ | ||
./node_modules/mocha-phantomjs/lib/mocha-phantomjs.coffee \ | ||
http://localhost:8080/src/test/coverage.html \ | ||
spec '{"hooks": "mocha-phantomjs-istanbul", "coverageFile": "coverage/coverage.json"}' | ||
|
||
# Convert the JSON coverage to LCOV for coveralls. | ||
istanbul report --include coverage/*.json lcovonly | ||
|
||
# Monkey patch in the untransformed source paths. | ||
perl -i -pe 's,dist/main,src/main,' coverage/lcov.info |
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