7
7
8
8
var ARGV = require ( "yargs" ) .
9
9
usage ( "$0 [options] task [task ...]" ) .
10
+ option ( "coverage" , {
11
+ type : "boolean" ,
12
+ describe : "include coverage" ,
13
+ default : false
14
+ } ) .
10
15
option ( "browsers" , {
11
16
type : "string" ,
12
17
describe : "browsers to run tests in" ,
@@ -84,22 +89,29 @@ function doTestsNodejs() {
84
89
}
85
90
86
91
gulp . task ( "test:nodejs:single" , function ( ) {
92
+ // Constructing the environment descriptor
93
+ var environ = require ( "util" ) . format (
94
+ "%s %s (%s %s)" ,
95
+ ( process . release && process . release . name ) || "node" ,
96
+ process . version ,
97
+ process . platform ,
98
+ process . arch
99
+ ) ;
100
+ if ( ARGV . coverage ) {
101
+ return gulp . src ( SOURCES ) .
102
+ pipe ( istanbul ( ) ) .
103
+ pipe ( istanbul . hookRequire ( ) ) .
104
+ on ( "finish" , function ( ) {
105
+ doTestsNodejs ( ) .
106
+ pipe ( istanbul . writeReports ( {
107
+ dir : "./coverage/" + environ ,
108
+ reporters : [ "html" , "text-summary" ]
109
+ } ) ) ;
110
+ } ) ;
111
+ }
87
112
return doTestsNodejs ( ) ;
88
113
} ) ;
89
114
90
- gulp . task ( "cover:nodejs" , function ( ) {
91
- return gulp . src ( SOURCES ) .
92
- pipe ( istanbul ( ) ) .
93
- pipe ( istanbul . hookRequire ( ) ) .
94
- on ( "finish" , function ( ) {
95
- doTestsNodejs ( ) .
96
- pipe ( istanbul . writeReports ( {
97
- dir : "./coverage/nodejs" ,
98
- reporters : [ "html" , "text-summary" ]
99
- } ) ) ;
100
- } ) ;
101
- } ) ;
102
-
103
115
gulp . task ( "test:nodejs" , function ( cb ) {
104
116
runSequence ( "test:lint" ,
105
117
"test:nodejs:single" ,
@@ -252,6 +264,25 @@ gulp.task("test:browser:single", function(done) {
252
264
return found ;
253
265
} ) ;
254
266
}
267
+ if ( ARGV . coverage ) {
268
+ config . browserify . transform = [
269
+ require ( "browserify-istanbul" ) ( {
270
+ ignore : [
271
+ "**/node_modules/**" ,
272
+ "**/test/**" ,
273
+ "**/env/**"
274
+ ]
275
+ } )
276
+ ] ;
277
+ config . reporters . push ( "coverage" ) ;
278
+ config . coverageReporter = {
279
+ dir : "./coverage" ,
280
+ reporters : [
281
+ { type : "html" } ,
282
+ { type : "text-summary" }
283
+ ]
284
+ } ;
285
+ }
255
286
256
287
karma . server . start ( config , done ) ;
257
288
} ) ;
@@ -275,11 +306,6 @@ gulp.task("test", function(cb) {
275
306
"test:nodejs:single" ,
276
307
cb ) ;
277
308
} ) ;
278
- gulp . task ( "coverage" , function ( cb ) {
279
- runSequence ( "test:lint" ,
280
- "cover:nodejs" ,
281
- cb ) ;
282
- } ) ;
283
309
gulp . task ( "clean" , [ "clean:coverage" , "clean:dist" ] ) ;
284
310
gulp . task ( "dist" , function ( cb ) {
285
311
runSequence ( "clean:dist" ,
0 commit comments