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-launch: specifically needs to test port 9229
- test-debugger-pid: needs modifications to node-inspect
- test-debugger-random-port-with-inspect-port: same as -pid test
  • Loading branch information
joyeecheung committed Aug 22, 2022
1 parent fd07bab commit 9c0441e
Show file tree
Hide file tree
Showing 22 changed files with 22 additions and 22 deletions.
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-auto-resume.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ addLibraryPath(process.env);
const env = { ...process.env };
env.NODE_INSPECT_RESUME_ON_START = '1';

const cli = startCLI([script], [], { env });
const cli = startCLI(['--port=0', script], [], { env });

cli.waitForInitialBreak()
.then(() => {
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]);

function onFatal(error) {
cli.quit();
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 @@ -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-breakpoint-exists.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,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]);

function onFatal(error) {
cli.quit();
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]);

function onFatal(error) {
cli.quit();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-exec-scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const assert = require('assert');

// exec .scope
{
const cli = startCLI([fixtures.path('debugger/backtrace.js')]);
const cli = startCLI(['--port=0', fixtures.path('debugger/backtrace.js')]);

function onFatal(error) {
cli.quit();
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 @@ -10,7 +10,7 @@ const assert = require('assert');

{

const cli = startCLI([fixtures.path('debugger/alive.js')]);
const cli = startCLI(['--port=0', fixtures.path('debugger/alive.js')]);

function onFatal(error) {
cli.quit();
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);

function onFatal(error) {
cli.quit();
Expand Down
2 changes: 1 addition & 1 deletion test/sequential/test-debugger-help.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,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')]);

function onFatal(error) {
cli.quit();
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;

function onFatal(error) {
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 @@ -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-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-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]);

function onFatal(error) {
cli.quit();
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 path = require('path');
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]);

function onFatal(error) {
cli.quit();
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]);

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-watchers.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const assert = require('assert');

// Stepping through breakpoints.
{
const cli = startCLI([fixtures.path('debugger/break.js')]);
const cli = startCLI(['--port=0', fixtures.path('debugger/break.js')]);

function onFatal(error) {
cli.quit();
Expand Down

0 comments on commit 9c0441e

Please sign in to comment.