@@ -400,6 +400,7 @@ describe('ChildProcessTracker', function () {
400400
401401 after ( function ( ) {
402402 clock . uninstall ( )
403+ usageMock . restore ( )
403404 } )
404405
405406 it ( `removes stopped processes every ${ ChildProcessTracker . pollingInterval / 1000 } seconds` , async function ( ) {
@@ -500,3 +501,38 @@ describe('ChildProcessTracker', function () {
500501 await stopAndWait ( runningProcess )
501502 } )
502503} )
504+
505+ describe ( 'ChildProcessTracker.logAllUsage' , function ( ) {
506+ let tracker : ChildProcessTracker
507+
508+ before ( function ( ) {
509+ tracker = ChildProcessTracker . instance
510+ } )
511+
512+ afterEach ( function ( ) {
513+ tracker . clear ( )
514+ } )
515+
516+ it ( 'logAllUsage includes only active processes' , async function ( ) {
517+ const runningProcess1 = startSleepProcess ( )
518+ const runningProcess2 = startSleepProcess ( )
519+
520+ tracker . add ( runningProcess1 . childProcess )
521+ tracker . add ( runningProcess2 . childProcess )
522+
523+ assert . ok ( tracker . has ( runningProcess1 . childProcess ) , 'Missing first process' )
524+ assert . ok ( tracker . has ( runningProcess2 . childProcess ) , 'Missing seconds process' )
525+
526+ await stopAndWait ( runningProcess1 )
527+
528+ await tracker . logAllUsage ( )
529+
530+ assert . throws ( ( ) => assertLogsContain ( runningProcess1 . childProcess . pid ( ) . toString ( ) , false , 'info' ) )
531+ assertLogsContain ( runningProcess2 . childProcess . pid ( ) . toString ( ) , false , 'info' )
532+ } )
533+
534+ it ( 'logAllUsage defaults to empty message when empty' , async function ( ) {
535+ await tracker . logAllUsage ( )
536+ assertLogsContain ( 'No Active Subprocesses' , false , 'info' )
537+ } )
538+ } )
0 commit comments