diff options
author | Wyatt Preul <wpreul@gmail.com> | 2016-09-29 10:56:15 -0500 |
---|---|---|
committer | Jeremiah Senkpiel <fishrock123@rocketmail.com> | 2016-10-11 12:33:08 -0400 |
commit | 9b0733fd49e3b226f1e62b049ca98ac4ee6a91aa (patch) | |
tree | d994b211794d06852329d98ec9e96e217f4509c9 /test/fixtures | |
parent | 0bdc363205bc1d8f01e1a41de1f05aa393336db9 (diff) | |
download | node-new-9b0733fd49e3b226f1e62b049ca98ac4ee6a91aa.tar.gz |
test: run faster and cleanup after run
PR-URL: https://github.com/nodejs/node/pull/8848
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Reviewed-By: Matthew Loring <mattloring@google.com>
Reviewed-By: Ilkka Myller <ilkka.myller@nodefield.com>
Diffstat (limited to 'test/fixtures')
-rw-r--r-- | test/fixtures/tick-processor-base.js | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/test/fixtures/tick-processor-base.js b/test/fixtures/tick-processor-base.js index 8e0005ff7d..ca67a0f7e9 100644 --- a/test/fixtures/tick-processor-base.js +++ b/test/fixtures/tick-processor-base.js @@ -7,7 +7,7 @@ const path = require('path'); common.refreshTmpDir(); const LOG_FILE = path.join(common.tmpDir, 'tick-processor.log'); -const RETRY_TIMEOUT = 750; +const RETRY_TIMEOUT = 150; function runTest(test) { const proc = cp.spawn(process.execPath, [ @@ -16,7 +16,7 @@ function runTest(test) { '--prof', '-pe', test.code ], { - stdio: [ null, 'pipe', 'inherit' ] + stdio: [ 'ignore', 'pipe', 'inherit' ] }); let ticks = ''; @@ -37,19 +37,25 @@ function match(pattern, parent, ticks) { '--call-graph-size=10', LOG_FILE ], { - stdio: [ null, 'pipe', 'inherit' ] + stdio: [ 'ignore', 'pipe', 'inherit' ] }); let out = ''; proc.stdout.on('data', chunk => out += chunk); - proc.stdout.on('end', () => { - // Retry after timeout - if (!pattern.test(out)) - return setTimeout(() => match(pattern, parent, ticks), RETRY_TIMEOUT); + proc.stdout.once('end', () => { + proc.once('exit', () => { + fs.unlinkSync(LOG_FILE); - parent.kill('SIGTERM'); + // Retry after timeout + if (!pattern.test(out)) + return setTimeout(() => match(pattern, parent, ticks), RETRY_TIMEOUT); - fs.unlinkSync(LOG_FILE); + parent.stdout.removeAllListeners(); + parent.kill(); + }); + + proc.stdout.removeAllListeners(); + proc.kill(); }); } |