(0. If you want to do code-coverage in an addon, AND are willing to live
with these restrictions:
a. no 'each' or other E4X extensions
b. no conditional 'let'
c. no conditional 'catch'
here is a method:
https://github.com/gregglind/lotsa_addons/tree/master/testy)
Below are some partial notes on my attempts to instrument the sdk itself.
I have tried two methods:
cfx test --pkg-dir=fakey # complains about duplicate module errors
As an alternative, I tried to make a complete copy of the `addon-sdk`.
There is some subset of modules that needs to be uninstrumented, so the
whole system can load, but I am not sure of what those are!
-> Bootstrap error: cannot find the global scope in
for:,addon-sdk/lib/sdk/system/events.js
```
# let's instrument the sdk itself!
## gross to use a for-loop, but couldn't get this working in xargs
# http://www.dwheeler.com/essays/filenames-in-shell.html
cd directory/above/addon-sdk
npm install git://github.com/gregglind/CoverJS.git#moz # installs
moz-aware dependencies [1]
rm -rf addon-sdk-test && cp -r addon-sdk addon-sdk-test &&
((cd addon-sdk && find lib -name '*js' -print0 && cd ..) | while IFS=""
read -r -d "" file ; do
./node_modules/coverjs-moz/bin/coverjs -o addon-sdk-test/`dirname
"$file"` --escodegen-options
'{"moz":{"starlessGenerator":true,"parenthesizedComprehensionBlock":true}}'
addon-sdk/"$file";
done ) &> addon-sdk-test/instrument.log
cd addon-sdk-test
# this list is incomplete
yes | cp {../addon-sdk/,}lib/sdk/deprecated/memory.js
yes | cp {../addon-sdk/,}lib/sdk/loader/cuddlefish.js
yes | cp {../addon-sdk/,}lib/toolkit/loader.js
yes | cp {../addon-sdk/,}lib/sdk/test/harness.js
yes | cp {../addon-sdk/,}lib/sdk/addon/runner.js
yes | cp {../addon-sdk/,}lib/sdk/system/events.js
yes | cp {../addon-sdk/,}lib/sdk/util/object.js
( ./bin/cfx test ) 2>&1 | less
```