2 # Generate code coverage data for posting to Coveralls.
3 # This requires dist/*.js to be in place.
4 # Output is coverage/lcov.info
9 # Generate per-file ES6 --> ES5 transpilations
10 babel
--retain-lines src
--out-dir dist
/src
11 babel
--retain-lines auto_tests
/tests
--out-dir dist
/auto_tests
/tests
13 # Instrument the source code with Istanbul's __coverage__ variable.
14 rm -rf coverage
/* # Clear out everything to ensure a hermetic run.
16 istanbul instrument
--output coverage
/src dist
/src
17 cp -r dist
/auto_tests coverage
/
19 # Build a combined file for running the tests in-browser
20 browserify coverage
/auto_tests
/tests
/*.js
-o coverage
/tests.js
22 # Run http-server and save its PID for cleanup
23 http-server
> /dev
/null
&
26 kill -TERM
$SERVER_PID
30 # Give the server a chance to start up
33 # Run the tests using mocha-phantomjs & mocha-phantomjs-istanbul
34 # This produces coverage/coverage.json
36 .
/node_modules
/mocha-phantomjs
/lib
/mocha-phantomjs.coffee \
37 http
://localhost
:8080/auto_tests
/coverage.html \
38 spec
'{"hooks": "mocha-phantomjs-istanbul", "coverageFile": "coverage/coverage.json"}'
41 # Convert the JSON coverage to LCOV for coveralls.
42 istanbul report
--include coverage
/*.json lcovonly
44 # Monkey patch in the untransformed source paths.
45 perl
-i
-pe
's,dist/,,' coverage
/lcov.info
46 echo '' # reset exit code -- failure to post coverage shouldn't be an error.
50 # Convert the JSON coverage to HTML for viewing
51 istanbul report
--include coverage
/*.json html
54 echo 'To browse coverage, run:'
56 echo ' open coverage/index.html'