Signed-off-by: inoway46 <inoueyuya416@gmail.com> PR-URL: https://github.com/nodejs/node/pull/62060 Refs: https://github.com/nodejs/node/issues/61762 Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com>
43 lines
1.2 KiB
JavaScript
43 lines
1.2 KiB
JavaScript
'use strict';
|
|
|
|
const common = require('../common');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const assert = require('assert');
|
|
|
|
const RESTARTS = 10;
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
const startCLI = require('../common/debugger');
|
|
|
|
// Using `restart` should result in only one "Connect/For help" message.
|
|
{
|
|
const script = fixtures.path('debugger', 'three-lines.js');
|
|
const cli = startCLI([script]);
|
|
|
|
const listeningRegExp = /Debugger listening on/g;
|
|
|
|
async function onWaitForInitialBreak() {
|
|
try {
|
|
await cli.waitFor(/ ok\n/);
|
|
await cli.waitForPrompt();
|
|
assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
|
|
|
|
for (let i = 0; i < RESTARTS; i++) {
|
|
// For `restart`, sync on attach/prompt instead of BREAK_MESSAGE to avoid flaky races.
|
|
// https://github.com/nodejs/node/issues/61762
|
|
await cli.command('restart');
|
|
await cli.waitFor(/Debugger attached\./);
|
|
await cli.waitForPrompt();
|
|
assert.strictEqual(cli.output.match(listeningRegExp).length, 1);
|
|
}
|
|
} finally {
|
|
await cli.quit();
|
|
}
|
|
|
|
assert.doesNotMatch(cli.stderrOutput, /MaxListenersExceededWarning/);
|
|
}
|
|
|
|
onWaitForInitialBreak();
|
|
}
|