Skip to content

Commit

Permalink
test: use --port=0 in debugger tests that do not have to work on 9229
Browse files Browse the repository at this point in the history
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: #47274
Refs: #47146
Reviewed-By: Colin Ihrig <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Moshe Atlow <[email protected]>
Reviewed-By: James M Snell <[email protected]>
  • Loading branch information
joyeecheung authored and RafaelGSS committed Apr 8, 2023
1 parent 0bbce03 commit 041885e
Show file tree
Hide file tree
Showing 26 changed files with 26 additions and 25 deletions.
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-auto-resume.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
});

Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-backtrace.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-break.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-breakpoint-exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-clear-breakpoints.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-exceptions.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-exec-scope.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-heap-profiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-help.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
1 change: 1 addition & 0 deletions test/sequential/test-debugger-launch.mjs
Original file line number Diff line number Diff line change
@@ -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';

Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-list.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-low-level.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-object-type-remote-object.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-preserve-breaks.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-profile-command.js
Original file line number Diff line number Diff line change
Expand Up @@ -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, '..', '..');

Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-profile.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-repeat-last.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const fixture = path('debugger-repeat-last.js');

const args = [
'inspect',
`--port=${common.PORT}`,
'--port=0',
fixture,
];

Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-restart-message.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-run-after-quit-restart.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-sb-before-load.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-scripts.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-set-context-line-number.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-use-strict.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-watch-validation.js
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-watchers.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down

0 comments on commit 041885e

Please sign in to comment.