@@ -2,6 +2,13 @@ BROWSERIFY := "node_modules/.bin/browserify"
22ESLINT := "node_modules/.bin/eslint"
33KARMA := "node_modules/.bin/karma"
44MOCHA := "bin/mocha"
5+ NYC := "node_modules/.bin/nyc"
6+ ISTANBUL_COMBINE := "node_modules/.bin/istanbul-combine"
7+ COVERAGE_DIR := "coverage/"
8+
9+ define test_node
10+ $(NYC ) --report-dir coverage/$(1 ) --reporter json --exclude browser $(MOCHA )
11+ endef
512
613TM_BUNDLE = JavaScript\ mocha.tmbundle
714SRC = $(shell find lib -name "* .js" -type f | sort)
@@ -26,11 +33,17 @@ lint:
2633 @printf " ==> [Test :: Lint]\n"
2734 $(ESLINT ) . bin/*
2835
36+ COVERAGE_TMP_DIR: =$(shell mktemp -d)
37+ generate-coverage-report :
38+ $(ISTANBUL_COMBINE ) -d $(COVERAGE_TMP_DIR ) -r lcov -r html $(COVERAGE_DIR ) /* /* .json
39+ rm -rf $(COVERAGE_DIR )
40+ mv $(COVERAGE_TMP_DIR ) $(COVERAGE_DIR )
41+
2942test-node : test-bdd test-tdd test-qunit test-exports test-unit test-integration test-jsapi test-compilers test-glob test-requires test-reporters test-only test-global-only
3043
3144test-browser : clean mocha.js test-browser-unit test-browser-bdd test-browser-qunit test-browser-tdd test-browser-exports
3245
33- test : lint test-node test-browser
46+ test : lint test-node test-browser generate-coverage-report
3447
3548test-browser-unit :
3649 @printf " ==> [Test :: Browser]\n"
@@ -54,24 +67,24 @@ test-jsapi:
5467
5568test-unit :
5669 @printf " ==> [Test :: Unit]\n"
57- $(MOCHA ) test/acceptance/* .js \
70+ $(call test_node,unit ) test/acceptance/* .js \
5871 --growl \
5972 test/* .js
6073
6174test-integration :
6275 @printf " ==> [Test :: Integrations]\n"
63- $(MOCHA ) --timeout 5000 \
76+ $(call test_node,integration ) --timeout 5000 \
6477 test/integration/* .js
6578
6679test-compilers :
6780 @printf " ==> [Test :: Compilers]\n"
68- $(MOCHA ) --compilers coffee:coffee-script/register,foo:./test/compiler/foo \
81+ $(call test_node,compilers ) --compilers coffee:coffee-script/register,foo:./test/compiler/foo \
6982 test/acceptance/test.coffee \
7083 test/acceptance/test.foo
7184
7285test-requires :
7386 @printf " ==> [Test :: Requires]\n"
74- $(MOCHA ) --compilers coffee:coffee-script/register \
87+ $(call test_node,requires ) --compilers coffee:coffee-script/register \
7588 --require test/acceptance/require/a.js \
7689 --require test/acceptance/require/b.coffee \
7790 --require test/acceptance/require/c.js \
@@ -80,22 +93,22 @@ test-requires:
8093
8194test-bdd :
8295 @printf " ==> [Test :: BDD]\n"
83- $(MOCHA ) --ui bdd \
96+ $(call test_node,bdd ) --ui bdd \
8497 test/acceptance/interfaces/bdd.spec
8598
8699test-tdd :
87100 @printf " ==> [Test :: TDD]\n"
88- $(MOCHA ) --ui tdd \
101+ $(call test_node,tdd ) --ui tdd \
89102 test/acceptance/interfaces/tdd.spec
90103
91104test-qunit :
92105 @printf " ==> [Test :: QUnit]\n"
93- $(MOCHA ) --ui qunit \
106+ $(call test_node,qunit ) --ui qunit \
94107 test/acceptance/interfaces/qunit.spec
95108
96109test-exports :
97110 @printf " ==> [Test :: Exports]\n"
98- $(MOCHA ) --ui exports \
111+ $(call test_node,exports ) --ui exports \
99112 test/acceptance/interfaces/exports.spec
100113
101114test-glob :
@@ -104,49 +117,49 @@ test-glob:
104117
105118test-reporters :
106119 @printf " ==> [Test :: Reporters]\n"
107- $(MOCHA ) test/reporters/* .js
120+ $(call test_node,reporters ) test/reporters/* .js
108121
109122test-only :
110123 @printf " ==> [Test :: Only]\n"
111- $(MOCHA ) --ui tdd \
124+ $(call test_node,only-tdd ) --ui tdd \
112125 test/acceptance/misc/only/tdd.spec
113126
114- $(MOCHA ) --ui bdd \
127+ $(call test_node,only-bdd ) --ui bdd \
115128 test/acceptance/misc/only/bdd.spec
116129
117- $(MOCHA ) --ui qunit \
130+ $(call test_node,only-bdd-require ) --ui qunit \
118131 test/acceptance/misc/only/bdd-require.spec
119132
120133test-global-only :
121134 @printf " ==> [Test :: Global Only]\n"
122- $(MOCHA ) --ui tdd \
135+ $(call test_node,global-only-tdd ) --ui tdd \
123136 test/acceptance/misc/only/global/tdd.spec
124137
125- $(MOCHA ) --ui bdd \
138+ $(call test_node,global-only-bdd ) --ui bdd \
126139 test/acceptance/misc/only/global/bdd.spec
127140
128- $(MOCHA ) --ui qunit \
141+ $(call test_node,global-only-qunit ) --ui qunit \
129142 test/acceptance/misc/only/global/qunit.spec
130143
131144test-mocha :
132145 @printf " ==> [Test :: Mocha]\n"
133- $(MOCHA ) test/mocha
146+ $(call test_node,mocha ) test/mocha
134147
135148non-tty :
136149 @printf " ==> [Test :: Non-TTY]\n"
137- $(MOCHA ) --reporter dot \
150+ $(call test_node,non-tty-dot ) --reporter dot \
138151 test/acceptance/interfaces/bdd.spec 2>&1 > /tmp/dot.out
139152
140153 @echo dot:
141154 @cat /tmp/dot.out
142155
143- $(MOCHA ) --reporter list \
156+ $(call test_node,non-tty-list ) --reporter list \
144157 test/acceptance/interfaces/bdd.spec 2>&1 > /tmp/list.out
145158
146159 @echo list:
147160 @cat /tmp/list.out
148161
149- $(MOCHA ) --reporter spec \
162+ $(call test_node,non-tty-spec ) --reporter spec \
150163 test/acceptance/interfaces/bdd.spec 2>&1 > /tmp/spec.out
151164
152165 @echo spec:
0 commit comments