diff options
author | Joyee Cheung <joyeec9h3@gmail.com> | 2023-03-28 00:03:40 +0200 |
---|---|---|
committer | Joyee Cheung <joyeec9h3@gmail.com> | 2023-04-05 00:49:44 +0200 |
commit | 967779b3a179d5cba1ff14a07a8c1f5772f0d75d (patch) | |
tree | 835cfdd9e047de94fe4d3e2eb9e10d7353114ddd /test | |
parent | dfbad862e0795957f63b57b507a1d89228588abc (diff) | |
download | node-new-967779b3a179d5cba1ff14a07a8c1f5772f0d75d.tar.gz |
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>
Diffstat (limited to 'test')
26 files changed, 26 insertions, 25 deletions
diff --git a/test/sequential/test-debugger-auto-resume.mjs b/test/sequential/test-debugger-auto-resume.mjs index e2f18d6e2b..077258907d 100644 --- a/test/sequential/test-debugger-auto-resume.mjs +++ b/test/sequential/test-debugger-auto-resume.mjs @@ -21,7 +21,7 @@ addLibraryPath(process.env); }; env.NODE_INSPECT_RESUME_ON_START = '1'; - const cli = startCLI([script], [], { + const cli = startCLI(['--port=0', script], [], { env, }); diff --git a/test/sequential/test-debugger-backtrace.js b/test/sequential/test-debugger-backtrace.js index c189cb3f5b..f66cc11d70 100644 --- a/test/sequential/test-debugger-backtrace.js +++ b/test/sequential/test-debugger-backtrace.js @@ -13,7 +13,7 @@ const path = require('path'); { const scriptFullPath = fixtures.path('debugger', 'backtrace.js'); const script = path.relative(process.cwd(), scriptFullPath); - const cli = startCLI([script]); + const cli = startCLI(['--port=0', script]); async function runTest() { try { diff --git a/test/sequential/test-debugger-break.js b/test/sequential/test-debugger-break.js index 1d92331d4e..65b4355cfe 100644 --- a/test/sequential/test-debugger-break.js +++ b/test/sequential/test-debugger-break.js @@ -11,7 +11,7 @@ const path = require('path'); const scriptFullPath = fixtures.path('debugger', 'break.js'); const script = path.relative(process.cwd(), scriptFullPath); -const cli = startCLI([script]); +const cli = startCLI(['--port=0', script]); (async () => { await cli.waitForInitialBreak(); diff --git a/test/sequential/test-debugger-breakpoint-exists.js b/test/sequential/test-debugger-breakpoint-exists.js index e2efa8182e..872fad2d82 100644 --- a/test/sequential/test-debugger-breakpoint-exists.js +++ b/test/sequential/test-debugger-breakpoint-exists.js @@ -9,7 +9,7 @@ const startCLI = require('../common/debugger'); // Test for "Breakpoint at specified location already exists" error. const script = fixtures.path('debugger', 'three-lines.js'); -const cli = startCLI([script]); +const cli = startCLI(['--port=0', script]); (async () => { try { diff --git a/test/sequential/test-debugger-clear-breakpoints.js b/test/sequential/test-debugger-clear-breakpoints.js index 91349e105a..74623ec437 100644 --- a/test/sequential/test-debugger-clear-breakpoints.js +++ b/test/sequential/test-debugger-clear-breakpoints.js @@ -13,7 +13,7 @@ const path = require('path'); { const scriptFullPath = fixtures.path('debugger', 'break.js'); const script = path.relative(process.cwd(), scriptFullPath); - const cli = startCLI([script]); + const cli = startCLI(['--port=0', script]); function onFatal(error) { cli.quit(); diff --git a/test/sequential/test-debugger-exceptions.js b/test/sequential/test-debugger-exceptions.js index 3f75161a6b..7f3e192251 100644 --- a/test/sequential/test-debugger-exceptions.js +++ b/test/sequential/test-debugger-exceptions.js @@ -13,7 +13,7 @@ const path = require('path'); { const scriptFullPath = fixtures.path('debugger', 'exceptions.js'); const script = path.relative(process.cwd(), scriptFullPath); - const cli = startCLI([script]); + const cli = startCLI(['--port=0', script]); (async () => { try { diff --git a/test/sequential/test-debugger-exec-scope.mjs b/test/sequential/test-debugger-exec-scope.mjs index 08b37e2795..3e4241cd01 100644 --- a/test/sequential/test-debugger-exec-scope.mjs +++ b/test/sequential/test-debugger-exec-scope.mjs @@ -7,7 +7,7 @@ import startCLI from '../common/debugger.js'; import assert from 'assert'; -const cli = startCLI([path('debugger/backtrace.js')]); +const cli = startCLI(['--port=0', path('debugger/backtrace.js')]); try { await cli.waitForInitialBreak(); diff --git a/test/sequential/test-debugger-exec.js b/test/sequential/test-debugger-exec.js index 3d4bb9ff63..51bc749734 100644 --- a/test/sequential/test-debugger-exec.js +++ b/test/sequential/test-debugger-exec.js @@ -8,7 +8,7 @@ const startCLI = require('../common/debugger'); const assert = require('assert'); -const cli = startCLI([fixtures.path('debugger/alive.js')]); +const cli = startCLI(['--port=0', fixtures.path('debugger/alive.js')]); async function waitInitialBreak() { try { diff --git a/test/sequential/test-debugger-heap-profiler.js b/test/sequential/test-debugger-heap-profiler.js index dfec0fe10d..1237c33f7f 100644 --- a/test/sequential/test-debugger-heap-profiler.js +++ b/test/sequential/test-debugger-heap-profiler.js @@ -17,7 +17,7 @@ const filename = path.join(tmpdir.path, 'node.heapsnapshot'); // Heap profiler take snapshot. { const opts = { cwd: tmpdir.path }; - const cli = startCLI([fixtures.path('debugger/empty.js')], [], opts); + const cli = startCLI(['--port=0', fixtures.path('debugger/empty.js')], [], opts); async function waitInitialBreak() { try { diff --git a/test/sequential/test-debugger-help.mjs b/test/sequential/test-debugger-help.mjs index 64f569831f..a4e659113b 100644 --- a/test/sequential/test-debugger-help.mjs +++ b/test/sequential/test-debugger-help.mjs @@ -7,7 +7,7 @@ import startCLI from '../common/debugger.js'; import assert from 'assert'; -const cli = startCLI([path('debugger', 'empty.js')]); +const cli = startCLI(['--port=0', path('debugger', 'empty.js')]); try { await cli.waitForInitialBreak(); diff --git a/test/sequential/test-debugger-launch.mjs b/test/sequential/test-debugger-launch.mjs index 9d4016c1f5..d501d0f9eb 100644 --- a/test/sequential/test-debugger-launch.mjs +++ b/test/sequential/test-debugger-launch.mjs @@ -1,6 +1,7 @@ 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'; diff --git a/test/sequential/test-debugger-list.js b/test/sequential/test-debugger-list.js index 594874e140..6f2e36e763 100644 --- a/test/sequential/test-debugger-list.js +++ b/test/sequential/test-debugger-list.js @@ -8,7 +8,7 @@ const startCLI = require('../common/debugger'); const assert = require('assert'); -const cli = startCLI([fixtures.path('debugger/three-lines.js')]); +const cli = startCLI(['--port=0', fixtures.path('debugger/three-lines.js')]); (async () => { await cli.waitForInitialBreak(); diff --git a/test/sequential/test-debugger-low-level.js b/test/sequential/test-debugger-low-level.js index 93c8e1b625..31f67849f5 100644 --- a/test/sequential/test-debugger-low-level.js +++ b/test/sequential/test-debugger-low-level.js @@ -9,7 +9,7 @@ const assert = require('assert'); // Debugger agent direct access. { - const cli = startCLI([fixtures.path('debugger/three-lines.js')]); + const cli = startCLI(['--port=0', fixtures.path('debugger/three-lines.js')]); const scriptPattern = /^\* (\d+): \S+debugger(?:\/|\\)three-lines\.js/m; async function testDebuggerLowLevel() { diff --git a/test/sequential/test-debugger-object-type-remote-object.js b/test/sequential/test-debugger-object-type-remote-object.js index 7404eae396..a055e8ce0f 100644 --- a/test/sequential/test-debugger-object-type-remote-object.js +++ b/test/sequential/test-debugger-object-type-remote-object.js @@ -8,7 +8,7 @@ const startCLI = require('../common/debugger'); const assert = require('assert'); -const cli = startCLI([fixtures.path('debugger/empty.js')]); +const cli = startCLI(['--port=0', fixtures.path('debugger/empty.js')]); (async () => { await cli.waitForInitialBreak(); diff --git a/test/sequential/test-debugger-preserve-breaks.js b/test/sequential/test-debugger-preserve-breaks.js index bb0eba9614..00168c570d 100644 --- a/test/sequential/test-debugger-preserve-breaks.js +++ b/test/sequential/test-debugger-preserve-breaks.js @@ -14,7 +14,7 @@ const script = path.relative(process.cwd(), scriptFullPath); // Run after quit. const runTest = async () => { - const cli = startCLI([script]); + const cli = startCLI(['--port=0', script]); try { await cli.waitForInitialBreak(); await cli.waitForPrompt(); diff --git a/test/sequential/test-debugger-profile-command.js b/test/sequential/test-debugger-profile-command.js index 06818c2132..da81dfc6e1 100644 --- a/test/sequential/test-debugger-profile-command.js +++ b/test/sequential/test-debugger-profile-command.js @@ -10,7 +10,7 @@ const assert = require('assert'); const fs = require('fs'); const path = require('path'); -const cli = startCLI([fixtures.path('debugger/empty.js')]); +const cli = startCLI(['--port=0', fixtures.path('debugger/empty.js')]); const rootDir = path.resolve(__dirname, '..', '..'); diff --git a/test/sequential/test-debugger-profile.js b/test/sequential/test-debugger-profile.js index bf4a697200..6cd0fc9d88 100644 --- a/test/sequential/test-debugger-profile.js +++ b/test/sequential/test-debugger-profile.js @@ -14,7 +14,7 @@ function delay(ms) { // Profiles. { - const cli = startCLI([fixtures.path('debugger/empty.js')]); + const cli = startCLI(['--port=0', fixtures.path('debugger/empty.js')]); function onFatal(error) { cli.quit(); diff --git a/test/sequential/test-debugger-repeat-last.js b/test/sequential/test-debugger-repeat-last.js index 5bdcc7dc8c..9a9b8eecdc 100644 --- a/test/sequential/test-debugger-repeat-last.js +++ b/test/sequential/test-debugger-repeat-last.js @@ -8,7 +8,7 @@ const fixture = path('debugger-repeat-last.js'); const args = [ 'inspect', - `--port=${common.PORT}`, + '--port=0', fixture, ]; diff --git a/test/sequential/test-debugger-restart-message.js b/test/sequential/test-debugger-restart-message.js index 190d0c18cc..e4001b47ee 100644 --- a/test/sequential/test-debugger-restart-message.js +++ b/test/sequential/test-debugger-restart-message.js @@ -14,7 +14,7 @@ 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 cli = startCLI(['--port=0', script]); const listeningRegExp = /Debugger listening on/g; diff --git a/test/sequential/test-debugger-run-after-quit-restart.js b/test/sequential/test-debugger-run-after-quit-restart.js index a9da07dcdf..2c56f7227a 100644 --- a/test/sequential/test-debugger-run-after-quit-restart.js +++ b/test/sequential/test-debugger-run-after-quit-restart.js @@ -13,7 +13,7 @@ const path = require('path'); { const scriptFullPath = fixtures.path('debugger', 'three-lines.js'); const script = path.relative(process.cwd(), scriptFullPath); - const cli = startCLI([script]); + const cli = startCLI(['--port=0', script]); function onFatal(error) { cli.quit(); diff --git a/test/sequential/test-debugger-sb-before-load.js b/test/sequential/test-debugger-sb-before-load.js index e2267156b7..416147b4bb 100644 --- a/test/sequential/test-debugger-sb-before-load.js +++ b/test/sequential/test-debugger-sb-before-load.js @@ -17,7 +17,7 @@ const script = path.relative(process.cwd(), scriptFullPath); const otherScriptFullPath = fixtures.path('debugger', 'cjs', 'other.js'); const otherScript = path.relative(process.cwd(), otherScriptFullPath); -const cli = startCLI([script]); +const cli = startCLI(['--port=0', script]); (async () => { await cli.waitForInitialBreak(); diff --git a/test/sequential/test-debugger-scripts.js b/test/sequential/test-debugger-scripts.js index b0f611bd1c..83f578cf1c 100644 --- a/test/sequential/test-debugger-scripts.js +++ b/test/sequential/test-debugger-scripts.js @@ -11,7 +11,7 @@ const assert = require('assert'); // List scripts. { const script = fixtures.path('debugger', 'three-lines.js'); - const cli = startCLI([script]); + const cli = startCLI(['--port=0', script]); (async () => { try { diff --git a/test/sequential/test-debugger-set-context-line-number.mjs b/test/sequential/test-debugger-set-context-line-number.mjs index adb6d9ab9e..5c6e281c1d 100644 --- a/test/sequential/test-debugger-set-context-line-number.mjs +++ b/test/sequential/test-debugger-set-context-line-number.mjs @@ -7,7 +7,7 @@ import startCLI from '../common/debugger.js'; import assert from 'assert'; const script = path('debugger', 'twenty-lines.js'); -const cli = startCLI([script]); +const cli = startCLI(['--port=0', script]); function onFatal(error) { cli.quit(); diff --git a/test/sequential/test-debugger-use-strict.js b/test/sequential/test-debugger-use-strict.js index ae82a9fc82..dce9286976 100644 --- a/test/sequential/test-debugger-use-strict.js +++ b/test/sequential/test-debugger-use-strict.js @@ -11,7 +11,7 @@ const assert = require('assert'); // Test for files that start with strict directive. { const script = fixtures.path('debugger', 'use-strict.js'); - const cli = startCLI([script]); + const cli = startCLI(['--port=0', script]); function onFatal(error) { cli.quit(); diff --git a/test/sequential/test-debugger-watch-validation.js b/test/sequential/test-debugger-watch-validation.js index 46307c18d5..2ccd889646 100644 --- a/test/sequential/test-debugger-watch-validation.js +++ b/test/sequential/test-debugger-watch-validation.js @@ -8,7 +8,7 @@ const startCLI = require('../common/debugger'); const assert = require('assert'); -const cli = startCLI([fixtures.path('debugger/break.js')]); +const cli = startCLI(['--port=0', fixtures.path('debugger/break.js')]); (async () => { await cli.waitForInitialBreak(); diff --git a/test/sequential/test-debugger-watchers.mjs b/test/sequential/test-debugger-watchers.mjs index 4ff7ea00a2..d2492cde67 100644 --- a/test/sequential/test-debugger-watchers.mjs +++ b/test/sequential/test-debugger-watchers.mjs @@ -7,7 +7,7 @@ import startCLI from '../common/debugger.js'; import assert from 'assert'; const script = path('debugger', 'break.js'); -const cli = startCLI([script]); +const cli = startCLI(['--port=0', script]); function onFatal(error) { cli.quit(); |