Browse Source

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: https://github.com/nodejs/node/pull/9490
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: James Snell <jasnell@gmail.com>
v6
Santiago Gimeno 8 years ago
parent
commit
1b889894ce
No known key found for this signature in database GPG Key ID: F28C3C8DA33C03BE
  1. 20
      test/parallel/test-debugger-util-regression.js

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

@ -19,16 +19,11 @@ const proc = spawn(process.execPath, args, { stdio: 'pipe' });
proc.stdout.setEncoding('utf8'); proc.stdout.setEncoding('utf8');
proc.stderr.setEncoding('utf8'); proc.stderr.setEncoding('utf8');
function fail() {
common.fail('the program should not hang');
}
const timer = setTimeout(fail, common.platformTimeout(4000));
let stdout = ''; let stdout = '';
let stderr = ''; let stderr = '';
let nextCount = 0; let nextCount = 0;
let exit = false;
proc.stdout.on('data', (data) => { proc.stdout.on('data', (data) => {
stdout += data; stdout += data;
@ -38,8 +33,8 @@ proc.stdout.on('data', (data) => {
stdout.includes('> 4') && nextCount < 4) { stdout.includes('> 4') && nextCount < 4) {
nextCount++; nextCount++;
proc.stdin.write('n\n'); proc.stdin.write('n\n');
} else if (stdout.includes('{ a: \'b\' }')) { } else if (!exit && (stdout.includes('< { a: \'b\' }'))) {
clearTimeout(timer); exit = true;
proc.stdin.write('.exit\n'); proc.stdin.write('.exit\n');
} else if (stdout.includes('program terminated')) { } else if (stdout.includes('program terminated')) {
// Catch edge case present in v4.x // Catch edge case present in v4.x
@ -50,15 +45,6 @@ proc.stdout.on('data', (data) => {
proc.stderr.on('data', (data) => stderr += data); proc.stderr.on('data', (data) => stderr += data);
// FIXME
// This test has been periodically failing on certain systems due to
// uncaught errors on proc.stdin. This will stop the process from
// exploding but is still not an elegant solution. Likely a deeper bug
// causing this problem.
proc.stdin.on('error', (err) => {
console.error(err);
});
process.on('exit', (code) => { process.on('exit', (code) => {
assert.equal(code, 0, 'the program should exit cleanly'); assert.equal(code, 0, 'the program should exit cleanly');
assert.equal(stdout.includes('{ a: \'b\' }'), true, assert.equal(stdout.includes('{ a: \'b\' }'), true,

Loading…
Cancel
Save