@@ -22,7 +22,7 @@ var options = {
22
22
watch : false
23
23
} ;
24
24
25
- var suites = [ ] ;
25
+ var files = [ ] ;
26
26
27
27
// Get rid of process runner
28
28
// ('node' in most cases)
@@ -82,6 +82,7 @@ msg('bin', 'argv', args);
82
82
msg ( 'bin' , 'options' , { reporter : options . reporter . name , matcher : options . matcher } ) ;
83
83
84
84
if ( args . length === 0 ) {
85
+ msg ( 'bin' , 'discovering' , 'folder structure' ) ;
85
86
root = fs . readdirSync ( '.' ) ;
86
87
87
88
if ( root . indexOf ( 'test' ) !== - 1 ) {
@@ -91,6 +92,7 @@ if (args.length === 0) {
91
92
} else {
92
93
abort ( "runner" , "couldn't find test folder" ) ;
93
94
}
95
+ msg ( 'bin' , 'discovered' , "./" + testFolder ) ;
94
96
95
97
args = paths ( testFolder ) ;
96
98
}
@@ -114,12 +116,11 @@ if (! options.watch) {
114
116
} ;
115
117
reporter . reset = function ( ) { _reporter . reset && _reporter . reset ( ) } ;
116
118
117
- suites = args . map ( function ( a ) {
118
- a = path . join ( process . cwd ( ) , a . replace ( / \. j s $ / , '' ) ) ;
119
- msg ( 'runner' , "loading" , a ) ;
120
- return require ( a ) . vows ;
119
+ files = args . map ( function ( a ) {
120
+ return path . join ( process . cwd ( ) , a . replace ( / \. j s $ / , '' ) ) ;
121
121
} ) ;
122
- runSuites ( suites , function ( results ) {
122
+
123
+ runSuites ( importSuites ( files ) , function ( results ) {
123
124
! options . verbose && _reporter . print ( '\n' ) ;
124
125
msg ( 'runner' , 'finish' ) ;
125
126
_reporter . report ( [ 'finish' , results ] , {
@@ -210,17 +211,16 @@ if (! options.watch) {
210
211
file = null ;
211
212
}
212
213
213
- var suites = ( / - ( t e s t | s p e c ) \. j s $ / . test ( file ) ? [ file ] : paths ( testFolder ) ) . map ( function ( p ) {
214
+ var files = ( / - ( t e s t | s p e c ) \. j s $ / . test ( file ) ? [ file ] : paths ( testFolder ) ) . map ( function ( p ) {
214
215
return path . join ( process . cwd ( ) , p . replace ( / \. j s $ / , '' ) ) ;
215
216
} ) . map ( function ( p ) {
216
217
delete ( require . main . moduleCache [ p ] ) ;
217
218
return p ;
218
219
} ) ;
219
220
220
- msg ( 'watcher' , 'loading' , suites ) ;
221
221
running ++ ;
222
222
223
- runSuites ( suites . map ( function ( s ) { return require ( s ) . vows } ) , function ( results ) {
223
+ runSuites ( importSuites ( files ) , function ( results ) {
224
224
delete ( results . time ) ;
225
225
print ( console . result ( results ) . join ( '' ) + '\n\n' ) ;
226
226
lastRun = new ( Date ) ;
@@ -272,6 +272,17 @@ function runSuites(suites, callback) {
272
272
} ) ( suites , callback ) ;
273
273
}
274
274
275
+ function importSuites ( files ) {
276
+ msg ( options . watcher ? 'watcher' : 'runner' , 'loading' , files ) ;
277
+
278
+ return files . reduce ( function ( suites , f ) {
279
+ var obj = require ( f ) ;
280
+ return suites . concat ( Object . keys ( obj ) . map ( function ( s ) {
281
+ return obj [ s ] ;
282
+ } ) ) ;
283
+ } , [ ] )
284
+ }
285
+
275
286
//
276
287
// Recursively traverse a hierarchy, returning
277
288
// a list of all relevant .js files.
0 commit comments