0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/sequential/test-debug-prompt.js
Rich Trott df97126173 test: fix flaky test-debug-prompt
Be sure to send `.exit` only once to avoid spurious EPIPE and possibly
other errors.

Fixes: https://github.com/nodejs/node/issues/21724

PR-URL: https://github.com/nodejs/node/pull/21826
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Anatoli Papirovski <apapirovski@mac.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Minwoo Jung <minwoo@nodesource.com>
Reviewed-By: Jon Moss <me@jonathanmoss.me>
2018-07-15 22:50:16 -07:00

19 lines
445 B
JavaScript

'use strict';
const common = require('../common');
common.skipIfInspectorDisabled();
const spawn = require('child_process').spawn;
const proc = spawn(process.execPath, ['inspect', 'foo']);
proc.stdout.setEncoding('utf8');
let needToSendExit = true;
let output = '';
proc.stdout.on('data', (data) => {
output += data;
if (output.includes('debug> ') && needToSendExit) {
proc.stdin.write('.exit\n');
needToSendExit = false;
}
});