mirror of
https://github.com/nodejs/node.git
synced 2026-10-28 18:25:13 +08:00
Wait for the target to finish starting before attaching the debugger. Capture the CLI close event when it is spawned so quit() also completes after an early exit, and terminate the target before awaiting cleanup. Add a regression test for quitting an already exited CLI and remove the Windows flaky entry. Refs: https://github.com/nodejs/node/issues/63212 Signed-off-by: Filip Skokan <panva.ip@gmail.com> Assisted-by: Codex PR-URL: https://github.com/nodejs/node/pull/66320 Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com>
37 lines
988 B
JavaScript
37 lines
988 B
JavaScript
'use strict';
|
|
const common = require('../common');
|
|
|
|
common.skipIfInspectorDisabled();
|
|
|
|
const fixtures = require('../common/fixtures');
|
|
const startCLI = require('../common/debugger');
|
|
|
|
const assert = require('assert');
|
|
const { spawn } = require('child_process');
|
|
const { once } = require('events');
|
|
|
|
const script = fixtures.path('debugger', 'alive.js');
|
|
|
|
(async () => {
|
|
const target = spawn(process.execPath, [script], {
|
|
stdio: ['ignore', 'pipe', 'pipe', 'ipc'],
|
|
});
|
|
await once(target, 'message');
|
|
const cli = startCLI(['-p', `${target.pid}`], [], {}, { randomPort: false });
|
|
|
|
try {
|
|
await cli.waitForPrompt();
|
|
await cli.command('sb("alive.js", 3)');
|
|
await cli.waitFor(/break/);
|
|
await cli.waitForPrompt();
|
|
assert.match(
|
|
cli.output,
|
|
/> 3 {3}\+\+x;/,
|
|
'marks the 3rd line');
|
|
} finally {
|
|
const targetClosed = once(target, 'close');
|
|
target.kill();
|
|
await Promise.all([cli.quit(), targetClosed]);
|
|
}
|
|
})().then(common.mustCall());
|