Author: Gregg Lind [email protected]
example coverage report: http://gregglind.github.com/micropilot/coverreport.html
Quick Recipe:
# install node
# patch your addon-sdk to have coverObject in the globals.
curl https://github.com/gregglind/addon-sdk/commit/coverage.patch | git am --reject
cd youraddondir
npm install git://github.com/gregglind/CoverJS.git#moz
curl -o coverreport.js https://gist.github.com/raw/4455415/405fc842bdd813470b95611b2776bf2ab06695ed/coverreport.js
rm -rf fakey && mkdir -p fakey/lib && cp -r data doc test package.json fakey && \
./node_modules/coverjs-moz/bin/coverjs \
-o fakey/lib \
--escodegen-options '{"moz":{"starlessGenerator":true,"parenthesizedComprehensionBlock":true}}' \
`find lib -name '*js'`
cfx test --pkgdir=fakey
node coverreport.js < coverstats-*.json > coverreport.html
open coverreport.html
Approach:
-
parse moz js into AST
-
add 'incrementor' nodes to a
__$coverObject
using CoverJS -
generate new code using
escodegen
-
run tests, which dumps the cover object:
cfx test --pkgdir=fakey
-
turn cover object into an html or other report, using CoverJS or other mechanism.
Needed:
- esprima-moz https://github.com/gregglind/esprima#moz (
npm install esprima-moz
) - escodegen is slowly landing moz specific patches https://github.com/Constellation/escodegen/pulls
npm install CoverJS
Specific Requests / WIP:
- Where does the 'coverObject' live? Should
loader
during test havewindow
orglobal
? - Should all of this be included in CFX as a --coverage option (see https://bugzilla.mozilla.org/show_bug.cgi?id=789401)
- Please, someone from Moz should be maintaining our forks!
This is deprecated, and will not work.