@@ -360,6 +360,11 @@ function getSleepCmd() {
360
360
return isWin ( ) ? 'timeout' : 'sleep'
361
361
}
362
362
363
+ async function stopAndWait ( cp : ChildProcess ) {
364
+ cp . stop ( true )
365
+ await waitUntil ( async ( ) => cp . stopped , { timeout : ChildProcess . stopTimeout * 2 , interval : 100 , truthy : true } )
366
+ }
367
+
363
368
describe ( 'ChildProcessTracker' , function ( ) {
364
369
let tracker : ChildProcessTracker
365
370
let clock : FakeTimers . InstalledClock
@@ -389,7 +394,7 @@ describe('ChildProcessTracker', function () {
389
394
390
395
await clock . tickAsync ( ChildProcessTracker . pollingInterval )
391
396
assert . strictEqual ( tracker . has ( childProcess ) , true , 'process was mistakenly removed' )
392
- childProcess . stop ( true )
397
+ await stopAndWait ( childProcess )
393
398
394
399
await clock . tickAsync ( ChildProcessTracker . pollingInterval )
395
400
assert . strictEqual ( tracker . has ( childProcess ) , false , 'process was not removed after stopping' )
@@ -406,8 +411,7 @@ describe('ChildProcessTracker', function () {
406
411
assert . strictEqual ( tracker . has ( childProcess1 ) , true , 'Missing first process' )
407
412
assert . strictEqual ( tracker . has ( childProcess2 ) , true , 'Missing second process' )
408
413
409
- childProcess1 . stop ( )
410
- console . log ( 'child process 1 stopped' )
414
+ await stopAndWait ( childProcess1 )
411
415
await clock . tickAsync ( ChildProcessTracker . pollingInterval )
412
416
assert . strictEqual ( tracker . has ( childProcess2 ) , true , 'second process was mistakenly removed' )
413
417
assert . strictEqual ( tracker . has ( childProcess1 ) , false , 'first process was not removed after stopping it' )
0 commit comments