0
0
mirror of https://github.com/nodejs/node.git synced 2024-12-01 16:10:02 +01:00
nodejs/test/sequential/test-debugger-launch.mjs
Joyee Cheung 967779b3a1
test: use --port=0 in debugger tests that do not have to work on 9229
To avoid failures when there is another running process occupying
the port 9229 which may happen if there is a stale process, use the
--port argument of node-inspect to use a random port in tests that
don't have to work on port 9229.

The following tests are not touched:

- test-debugger-custom-port: tests a specific port
- test-debugger-debug-brk: tests a specific port
- test-debugger-invalid-args: tests other inspect combinations
- test-debugger-pid: node-inspect does not support -p and --port
  together
- test-debugger-launch: tests that default port is 9229

PR-URL: https://github.com/nodejs/node/pull/47274
Refs: https://github.com/nodejs/node/issues/47146
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Michaël Zasso <targos@protonmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Moshe Atlow <moshe@atlow.co.il>
Reviewed-By: James M Snell <jasnell@gmail.com>
2023-04-05 00:49:44 +02:00

38 lines
1.0 KiB
JavaScript

import { skipIfInspectorDisabled } from '../common/index.mjs';
skipIfInspectorDisabled();
// This must be in sequential because we check that the default port is 9229.
import { path } from '../common/fixtures.mjs';
import startCLI from '../common/debugger.js';
import assert from 'assert';
const script = path('debugger', 'three-lines.js');
const cli = startCLI([script]);
try {
await cli.waitForInitialBreak();
await cli.waitForPrompt();
assert.match(cli.output, /debug>/, 'prints a prompt');
assert.match(
cli.output,
/< Debugger listening on [^\n]*9229/,
'forwards child output'
);
await cli.command('["hello", "world"].join(" ")');
assert.match(cli.output, /hello world/, 'prints the result');
await cli.command('');
assert.match(
cli.output,
/hello world/,
'repeats the last command on <enter>'
);
await cli.command('version');
assert.ok(
cli.output.includes(process.versions.v8),
'version prints the v8 version'
);
} finally {
const code = await cli.quit();
assert.strictEqual(code, 0);
}