@@ -2,6 +2,15 @@ BROWSERIFY := "node_modules/.bin/browserify"
2
2
ESLINT := "node_modules/.bin/eslint"
3
3
KARMA := "node_modules/.bin/karma"
4
4
MOCHA := "bin/mocha"
5
+ NYC := "node_modules/.bin/nyc"
6
+
7
+ ifdef COVERAGE
8
+ define test_node
9
+ $(NYC ) --report-dir coverage/reports/$(1 ) $(MOCHA )
10
+ endef
11
+ else
12
+ test_node := $(MOCHA)
13
+ endif
5
14
6
15
TM_BUNDLE = JavaScript\ mocha.tmbundle
7
16
SRC = $(shell find lib -name "* .js" -type f | sort)
@@ -54,24 +63,24 @@ test-jsapi:
54
63
55
64
test-unit :
56
65
@printf " ==> [Test :: Unit]\n"
57
- $(MOCHA ) test/acceptance/* .js \
66
+ $(call test_node,unit ) test/acceptance/* .js \
58
67
--growl \
59
68
test/* .js
60
69
61
70
test-integration :
62
71
@printf " ==> [Test :: Integrations]\n"
63
- $(MOCHA ) --timeout 5000 \
72
+ $(call test_node,integration ) --timeout 5000 \
64
73
test/integration/* .js
65
74
66
75
test-compilers :
67
76
@printf " ==> [Test :: Compilers]\n"
68
- $(MOCHA ) --compilers coffee:coffee-script/register,foo:./test/compiler/foo \
77
+ $(call test_node,compilers ) --compilers coffee:coffee-script/register,foo:./test/compiler/foo \
69
78
test/acceptance/test.coffee \
70
79
test/acceptance/test.foo
71
80
72
81
test-requires :
73
82
@printf " ==> [Test :: Requires]\n"
74
- $(MOCHA ) --compilers coffee:coffee-script/register \
83
+ $(call test_node,requires ) --compilers coffee:coffee-script/register \
75
84
--require test/acceptance/require/a.js \
76
85
--require test/acceptance/require/b.coffee \
77
86
--require test/acceptance/require/c.js \
@@ -80,22 +89,22 @@ test-requires:
80
89
81
90
test-bdd :
82
91
@printf " ==> [Test :: BDD]\n"
83
- $(MOCHA ) --ui bdd \
92
+ $(call test_node,bdd ) --ui bdd \
84
93
test/acceptance/interfaces/bdd.spec
85
94
86
95
test-tdd :
87
96
@printf " ==> [Test :: TDD]\n"
88
- $(MOCHA ) --ui tdd \
97
+ $(call test_node,tdd ) --ui tdd \
89
98
test/acceptance/interfaces/tdd.spec
90
99
91
100
test-qunit :
92
101
@printf " ==> [Test :: QUnit]\n"
93
- $(MOCHA ) --ui qunit \
102
+ $(call test_node,qunit ) --ui qunit \
94
103
test/acceptance/interfaces/qunit.spec
95
104
96
105
test-exports :
97
106
@printf " ==> [Test :: Exports]\n"
98
- $(MOCHA ) --ui exports \
107
+ $(call test_node,exports ) --ui exports \
99
108
test/acceptance/interfaces/exports.spec
100
109
101
110
test-glob :
@@ -104,49 +113,49 @@ test-glob:
104
113
105
114
test-reporters :
106
115
@printf " ==> [Test :: Reporters]\n"
107
- $(MOCHA ) test/reporters/* .js
116
+ $(call test_node,reporters ) test/reporters/* .js
108
117
109
118
test-only :
110
119
@printf " ==> [Test :: Only]\n"
111
- $(MOCHA ) --ui tdd \
120
+ $(call test_node,only-tdd ) --ui tdd \
112
121
test/acceptance/misc/only/tdd.spec
113
122
114
- $(MOCHA ) --ui bdd \
123
+ $(call test_node,only-bdd ) --ui bdd \
115
124
test/acceptance/misc/only/bdd.spec
116
125
117
- $(MOCHA ) --ui qunit \
126
+ $(call test_node,only-bdd-require ) --ui qunit \
118
127
test/acceptance/misc/only/bdd-require.spec
119
128
120
129
test-global-only :
121
130
@printf " ==> [Test :: Global Only]\n"
122
- $(MOCHA ) --ui tdd \
131
+ $(call test_node,global-only-tdd ) --ui tdd \
123
132
test/acceptance/misc/only/global/tdd.spec
124
133
125
- $(MOCHA ) --ui bdd \
134
+ $(call test_node,global-only-bdd ) --ui bdd \
126
135
test/acceptance/misc/only/global/bdd.spec
127
136
128
- $(MOCHA ) --ui qunit \
137
+ $(call test_node,global-only-qunit ) --ui qunit \
129
138
test/acceptance/misc/only/global/qunit.spec
130
139
131
140
test-mocha :
132
141
@printf " ==> [Test :: Mocha]\n"
133
- $(MOCHA ) test/mocha
142
+ $(call test_node,mocha ) test/mocha
134
143
135
144
non-tty :
136
145
@printf " ==> [Test :: Non-TTY]\n"
137
- $(MOCHA ) --reporter dot \
146
+ $(call test_node,non-tty-dot ) --reporter dot \
138
147
test/acceptance/interfaces/bdd.spec 2>&1 > /tmp/dot.out
139
148
140
149
@echo dot:
141
150
@cat /tmp/dot.out
142
151
143
- $(MOCHA ) --reporter list \
152
+ $(call test_node,non-tty-list ) --reporter list \
144
153
test/acceptance/interfaces/bdd.spec 2>&1 > /tmp/list.out
145
154
146
155
@echo list:
147
156
@cat /tmp/list.out
148
157
149
- $(MOCHA ) --reporter spec \
158
+ $(call test_node,non-tty-spec ) --reporter spec \
150
159
test/acceptance/interfaces/bdd.spec 2>&1 > /tmp/spec.out
151
160
152
161
@echo spec:
0 commit comments