@@ -63,6 +63,7 @@ function spawnOne( assert, options ) {
63
63
}
64
64
65
65
theChild = options . spawn ( options . interpreter , commandLine ) ;
66
+ theChild . path = options . path ;
66
67
67
68
runningProcesses . push ( theChild ) ;
68
69
@@ -169,32 +170,50 @@ var actualOptions = {
169
170
_ . map ( options . tests , function ( item ) {
170
171
return path . join ( __dirname , "tests" , item ) ;
171
172
} ) :
172
- ( glob . sync ( path . join ( __dirname , "tests" , "*" ) ) ) )
173
+ ( glob . sync ( path . join ( __dirname , "tests" , "*" ) ) ) ) . map ( path . normalize )
173
174
} ;
174
175
175
176
if ( actualOptions . tests . length === 0 ) {
176
177
console . log ( "*** No tests were requested ***" ) ;
177
178
}
178
179
180
+ getQUnit ( ) . module ( "OCF tests" , {
181
+ beforeEach : function ( ) {
182
+ this . children = [ ] ;
183
+ } ,
184
+ afterEach : function ( ) {
185
+ this . children . forEach ( function ( childProcess ) {
186
+ console . log ( "Killing child process " + childProcess . path ) ;
187
+ childProcess . removeAllListeners ( ) ;
188
+ childProcess . kill ( "SIGKILL" ) ;
189
+ } ) ;
190
+ }
191
+ } ) ;
192
+
179
193
_ . each ( actualOptions . tests , function ( item ) {
180
194
var clientPathIndex ,
181
- clientPaths = glob . sync ( path . join ( item , "client*.js" ) ) ,
195
+ clientPaths = glob . sync ( path . join ( item , "client*.js" ) ) . map ( path . normalize ) ,
182
196
serverPath = path . join ( item , "server.js" ) ;
183
197
184
198
if ( fs . lstatSync ( item ) . isFile ( ) && ! actualOptions . single . skip ) {
185
199
getQUnit ( )
186
200
. test ( path . basename ( item ) . replace ( / \. j s $ / , "" ) , function ( assert ) {
187
- spawnOne ( assert ,
201
+ var done = assert . async ( ) ;
202
+ var children = this . children ;
203
+ children . push ( spawnOne ( assert ,
188
204
_ . extend ( { } , actualOptions . single , {
189
205
uuid : uuid . v4 ( ) ,
190
206
name : "Test" ,
191
207
path : item ,
192
208
teardown : function ( error , sourceProcess ) {
193
209
sourceProcess . kill ( "SIGINT" ) ;
194
210
} ,
195
- maybeQuit : assert . async ( ) ,
211
+ maybeQuit : function ( ) {
212
+ children . pop ( ) ;
213
+ done ( ) ;
214
+ } ,
196
215
reportAssertions : _ . bind ( assert . expect , assert )
197
- } ) ) ;
216
+ } ) ) ) ;
198
217
} ) ;
199
218
return ;
200
219
}
@@ -217,7 +236,7 @@ _.each( actualOptions.tests, function( item ) {
217
236
var totalChildren = clientPaths . length + 1 ,
218
237
219
238
// Track the child processes involved in this test in this array
220
- children = [ ] ,
239
+ children = this . children ,
221
240
222
241
// Turn this test async
223
242
done = assert . async ( ) ,
0 commit comments