Skip to content

Commit 74c772c

Browse files
geekjasnell
authored andcommitted
test: run faster and cleanup after run
PR-URL: #8848 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Fedor Indutny <[email protected]> Reviewed-By: Matthew Loring <[email protected]> Reviewed-By: Ilkka Myller <[email protected]>
1 parent 8ec9582 commit 74c772c

File tree

1 file changed

+15
-9
lines changed

1 file changed

+15
-9
lines changed

test/fixtures/tick-processor-base.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ const path = require('path');
77
common.refreshTmpDir();
88

99
const LOG_FILE = path.join(common.tmpDir, 'tick-processor.log');
10-
const RETRY_TIMEOUT = 750;
10+
const RETRY_TIMEOUT = 150;
1111

1212
function 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

Comments
 (0)