Permalink
Browse files

Add code coverage with `make coverage`.

  • Loading branch information...
1 parent 6916c44 commit da6e8a842fe2fccfe76aed8198694613e7c889d9 @reid reid committed Feb 29, 2012
Showing with 35 additions and 0 deletions.
  1. +2 −0 .gitignore
  2. +2 −0 .npmignore
  3. +3 −0 Makefile
  4. +28 −0 scripts/coverage.sh
View
2 .gitignore
@@ -1,3 +1,5 @@
+tools
+coverage.*
node_modules
npm-*.log
test/vendor/yui*
View
2 .npmignore
@@ -1,3 +1,5 @@
+tools
+coverage.*
.git*
*.swp
test/vendor
View
3 Makefile
@@ -9,6 +9,9 @@ spec:
./node_modules/.bin/vows --spec test/*.js
.PHONY: spec
+coverage:
+ sh scripts/coverage.sh
+
install:
npm install .
.PHONY: install
View
28 scripts/coverage.sh
@@ -0,0 +1,28 @@
+#!/bin/sh
+
+if [ ! -d tools/jscoverage ]; then
+ mkdir -p tools/jscoverage
+fi
+
+if [ ! -x tools/jscoverage/jscoverage ]; then
+ echo "Installing JSCoverage for Node.js to tools/jscoverage."
+ rm -rf tools/jscoverage/*
+ git clone --quiet https://github.com/visionmedia/node-jscoverage.git tools/jscoverage
+ cd tools/jscoverage
+ ./configure
+ make
+ cd ../..
+fi
+
+rm -rf lib-raw
+cp -R lib lib-raw
+rm -rf lib
+tools/jscoverage/jscoverage lib-raw lib
+./node_modules/.bin/vows --cover-html test/*.js
+rm -rf lib
+mv lib-raw lib
+
+echo "Coverage report written to coverage.html."
+
+# Open the report on OS X.
+hash open 2>&- && open coverage.html

0 comments on commit da6e8a8

Please sign in to comment.