@@ -7,7 +7,7 @@ const path = require('path');
7
7
common . refreshTmpDir ( ) ;
8
8
9
9
const LOG_FILE = path . join ( common . tmpDir , 'tick-processor.log' ) ;
10
- const RETRY_TIMEOUT = 750 ;
10
+ const RETRY_TIMEOUT = 150 ;
11
11
12
12
function runTest ( test ) {
13
13
const proc = cp . spawn ( process . execPath , [
@@ -16,7 +16,7 @@ function runTest(test) {
16
16
'--prof' ,
17
17
'-pe' , test . code
18
18
] , {
19
- stdio : [ null , 'pipe' , 'inherit' ]
19
+ stdio : [ 'ignore' , 'pipe' , 'inherit' ]
20
20
} ) ;
21
21
22
22
let ticks = '' ;
@@ -37,19 +37,25 @@ function match(pattern, parent, ticks) {
37
37
'--call-graph-size=10' ,
38
38
LOG_FILE
39
39
] , {
40
- stdio : [ null , 'pipe' , 'inherit' ]
40
+ stdio : [ 'ignore' , 'pipe' , 'inherit' ]
41
41
} ) ;
42
42
43
43
let out = '' ;
44
44
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 ) ;
49
48
50
- parent . kill ( 'SIGTERM' ) ;
49
+ // Retry after timeout
50
+ if ( ! pattern . test ( out ) )
51
+ return setTimeout ( ( ) => match ( pattern , parent , ticks ) , RETRY_TIMEOUT ) ;
51
52
52
- fs . unlinkSync ( LOG_FILE ) ;
53
+ parent . stdout . removeAllListeners ( ) ;
54
+ parent . kill ( ) ;
55
+ } ) ;
56
+
57
+ proc . stdout . removeAllListeners ( ) ;
58
+ proc . kill ( ) ;
53
59
} ) ;
54
60
}
55
61
0 commit comments