Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: run faster and cleanup after run #8848

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 15 additions & 9 deletions test/fixtures/tick-processor-base.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, [
Expand All @@ -16,7 +16,7 @@ function runTest(test) {
'--prof',
'-pe', test.code
], {
stdio: [ null, 'pipe', 'inherit' ]
stdio: [ 'ignore', 'pipe', 'inherit' ]
});

let ticks = '';
Expand All @@ -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();
});
}

Expand Down