Skip to content

Commit

Permalink
fixup! test: fix flaky test-repl-sigint-nested-eval
Browse files Browse the repository at this point in the history
  • Loading branch information
Trott committed Nov 9, 2022
1 parent 3f3bb43 commit 1c771ae
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions test/parallel/test-repl-sigint-nested-eval.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ const spawn = require('child_process').spawn;

process.env.REPL_TEST_PPID = process.pid;
const child = spawn(process.execPath, [ '-i' ], {
stdio: [null, null, 2]
stdio: [null, null, 2, 'ipc']
});

let stdout = '';
Expand All @@ -22,17 +22,19 @@ child.stdout.on('data', function(c) {
});

child.stdout.once('data', common.mustCall(() => {
process.on('SIGUSR2', common.mustCall(() => {
setTimeout(() => { process.kill(child.pid, 'SIGINT'); }, 10);
child.on('message', common.mustCall((msg) => {
assert.strictEqual(msg, 'repl is busy');
process.kill(child.pid, 'SIGINT');
child.stdout.once('data', common.mustCall(() => {
// Make sure REPL still works.
child.stdin.end('"foobar"\n');
}));
}));

child.stdin.write('process.kill(+process.env.REPL_TEST_PPID, "SIGUSR2");' +
'vm.runInThisContext("while(true){}", ' +
'{ breakOnSigint: true });\n');
child.stdin.write(
'vm.runInThisContext("process.send(\'repl is busy\'); while(true){}", ' +
'{ breakOnSigint: true });\n'
);
}));

child.on('close', function(code) {
Expand Down

0 comments on commit 1c771ae

Please sign in to comment.