Skip to content

Commit 96bdfae

Browse files
santigimenoMyles Borins
authored and
Myles Borins
committed
test: improve test-debugger-util-regression
Avoid the `exit` command to be sent more than once. It prevents from undesired errors emitted on `proc.stdin`. Remove the watchdog timer so the test does not fail in case it takes longer to complete. PR-URL: #9490 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: James Snell <[email protected]>
1 parent c5181ed commit 96bdfae

File tree

1 file changed

+3
-17
lines changed

1 file changed

+3
-17
lines changed

test/parallel/test-debugger-util-regression.js

+3-17
Original file line numberDiff line numberDiff line change
@@ -19,16 +19,11 @@ const proc = spawn(process.execPath, args, { stdio: 'pipe' });
1919
proc.stdout.setEncoding('utf8');
2020
proc.stderr.setEncoding('utf8');
2121

22-
function fail() {
23-
common.fail('the program should not hang');
24-
}
25-
26-
const timer = setTimeout(fail, common.platformTimeout(4000));
27-
2822
let stdout = '';
2923
let stderr = '';
3024

3125
let nextCount = 0;
26+
let exit = false;
3227

3328
proc.stdout.on('data', (data) => {
3429
stdout += data;
@@ -38,8 +33,8 @@ proc.stdout.on('data', (data) => {
3833
stdout.includes('> 4') && nextCount < 4) {
3934
nextCount++;
4035
proc.stdin.write('n\n');
41-
} else if (stdout.includes('{ a: \'b\' }')) {
42-
clearTimeout(timer);
36+
} else if (!exit && (stdout.includes('< { a: \'b\' }'))) {
37+
exit = true;
4338
proc.stdin.write('.exit\n');
4439
} else if (stdout.includes('program terminated')) {
4540
// Catch edge case present in v4.x
@@ -50,15 +45,6 @@ proc.stdout.on('data', (data) => {
5045

5146
proc.stderr.on('data', (data) => stderr += data);
5247

53-
// FIXME
54-
// This test has been periodically failing on certain systems due to
55-
// uncaught errors on proc.stdin. This will stop the process from
56-
// exploding but is still not an elegant solution. Likely a deeper bug
57-
// causing this problem.
58-
proc.stdin.on('error', (err) => {
59-
console.error(err);
60-
});
61-
6248
process.on('exit', (code) => {
6349
assert.equal(code, 0, 'the program should exit cleanly');
6450
assert.equal(stdout.includes('{ a: \'b\' }'), true,

0 commit comments

Comments
 (0)