From 1c771aefc31ed391b8fffc776180256ff3e5683e Mon Sep 17 00:00:00 2001 From: Rich Trott Date: Wed, 9 Nov 2022 12:27:20 -0800 Subject: [PATCH] fixup! test: fix flaky test-repl-sigint-nested-eval --- test/parallel/test-repl-sigint-nested-eval.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/test/parallel/test-repl-sigint-nested-eval.js b/test/parallel/test-repl-sigint-nested-eval.js index acf21a0abbc524..5830e08629b999 100644 --- a/test/parallel/test-repl-sigint-nested-eval.js +++ b/test/parallel/test-repl-sigint-nested-eval.js @@ -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 = ''; @@ -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) {