@@ -7,7 +7,7 @@ const path = require('path');
77common . refreshTmpDir ( ) ;
88
99const LOG_FILE = path . join ( common . tmpDir , 'tick-processor.log' ) ;
10- const RETRY_TIMEOUT = 750 ;
10+ const RETRY_TIMEOUT = 150 ;
1111
1212function runTest ( test ) {
1313 const proc = cp . spawn ( process . execPath , [
@@ -16,7 +16,7 @@ function runTest(test) {
1616 '--prof' ,
1717 '-pe' , test . code
1818 ] , {
19- stdio : [ null , 'pipe' , 'inherit' ]
19+ stdio : [ 'ignore' , 'pipe' , 'inherit' ]
2020 } ) ;
2121
2222 let ticks = '' ;
@@ -37,19 +37,25 @@ function match(pattern, parent, ticks) {
3737 '--call-graph-size=10' ,
3838 LOG_FILE
3939 ] , {
40- stdio : [ null , 'pipe' , 'inherit' ]
40+ stdio : [ 'ignore' , 'pipe' , 'inherit' ]
4141 } ) ;
4242
4343 let out = '' ;
4444 proc . stdout . on ( 'data' , chunk => out += chunk ) ;
45- proc . stdout . on ( 'end' , ( ) => {
46- // Retry after timeout
47- if ( ! pattern . test ( out ) )
48- return setTimeout ( ( ) => match ( pattern , parent , ticks ) , RETRY_TIMEOUT ) ;
45+ proc . stdout . once ( 'end' , ( ) => {
46+ proc . once ( 'exit' , ( ) => {
47+ fs . unlinkSync ( LOG_FILE ) ;
4948
50- parent . kill ( 'SIGTERM' ) ;
49+ // Retry after timeout
50+ if ( ! pattern . test ( out ) )
51+ return setTimeout ( ( ) => match ( pattern , parent , ticks ) , RETRY_TIMEOUT ) ;
5152
52- fs . unlinkSync ( LOG_FILE ) ;
53+ parent . stdout . removeAllListeners ( ) ;
54+ parent . kill ( ) ;
55+ } ) ;
56+
57+ proc . stdout . removeAllListeners ( ) ;
58+ proc . kill ( ) ;
5359 } ) ;
5460}
5561
0 commit comments