Browse Source

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>
v7.x
Wyatt Preul 8 years ago
committed by James M Snell
parent
commit
74c772c3eb
  1. 18
      test/fixtures/tick-processor-base.js

18
test/fixtures/tick-processor-base.js

@ -7,7 +7,7 @@ const path = require('path');
common.refreshTmpDir(); common.refreshTmpDir();
const LOG_FILE = path.join(common.tmpDir, 'tick-processor.log'); const LOG_FILE = path.join(common.tmpDir, 'tick-processor.log');
const RETRY_TIMEOUT = 750; const RETRY_TIMEOUT = 150;
function runTest(test) { function runTest(test) {
const proc = cp.spawn(process.execPath, [ const proc = cp.spawn(process.execPath, [
@ -16,7 +16,7 @@ function runTest(test) {
'--prof', '--prof',
'-pe', test.code '-pe', test.code
], { ], {
stdio: [ null, 'pipe', 'inherit' ] stdio: [ 'ignore', 'pipe', 'inherit' ]
}); });
let ticks = ''; let ticks = '';
@ -37,19 +37,25 @@ function match(pattern, parent, ticks) {
'--call-graph-size=10', '--call-graph-size=10',
LOG_FILE LOG_FILE
], { ], {
stdio: [ null, 'pipe', 'inherit' ] stdio: [ 'ignore', 'pipe', 'inherit' ]
}); });
let out = ''; let out = '';
proc.stdout.on('data', chunk => out += chunk); proc.stdout.on('data', chunk => out += chunk);
proc.stdout.on('end', () => { proc.stdout.once('end', () => {
proc.once('exit', () => {
fs.unlinkSync(LOG_FILE);
// Retry after timeout // Retry after timeout
if (!pattern.test(out)) if (!pattern.test(out))
return setTimeout(() => match(pattern, parent, ticks), RETRY_TIMEOUT); return setTimeout(() => match(pattern, parent, ticks), RETRY_TIMEOUT);
parent.kill('SIGTERM'); parent.stdout.removeAllListeners();
parent.kill();
});
fs.unlinkSync(LOG_FILE); proc.stdout.removeAllListeners();
proc.kill();
}); });
} }

Loading…
Cancel
Save