Skip to content

Commit 96bdfae

Browse files
santigimenoMyles Borins
authored andcommitted
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‎

Lines changed: 3 additions & 17 deletions
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-
functionfail(){
23-
common.fail('the program should not hang');
24-
}
25-
26-
consttimer=setTimeout(fail,common.platformTimeout(4000));
27-
2822
letstdout='';
2923
letstderr='';
3024

3125
letnextCount=0;
26+
letexit=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-
}elseif(stdout.includes('{a: \'b\' }')){
42-
clearTimeout(timer);
36+
}elseif(!exit&&(stdout.includes('< {a: \'b\' }'))){
37+
exit=true;
4338
proc.stdin.write('.exit\n');
4439
}elseif(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)