Skip to content

Commit 80edf69

Browse files
test: update startCLI to set --port=0 by default
update the `startCLI` debugging testing utility to set by default the port to use to `0` (i.e. a random port)
1 parent c4169cb commit 80edf69

33 files changed

+41
-39
lines changed

‎test/common/debugger.js‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,14 @@ function isPreBreak(output){
2020
return/Breakonstart/.test(output)&&/1\(function\(exports/.test(output);
2121
}
2222

23-
functionstartCLI(args,flags=[],spawnOpts={}){
23+
functionstartCLI(args,flags=[],spawnOpts={},opts={randomPort: true}){
2424
letstderrOutput='';
25-
constchild=
26-
spawn(process.execPath,[...flags,'inspect', ...args],spawnOpts);
25+
constchild=spawn(process.execPath,[
26+
...flags,
27+
'inspect',
28+
...(opts.randomPort!==false ? ['--port=0'] : []),
29+
...args,
30+
],spawnOpts);
2731

2832
constoutputBuffer=[];
2933
functionbufferOutput(chunk){

‎test/parallel/test-debugger-address.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ function launchTarget(...args){
5555
try{
5656
const{ childProc, host, port }=awaitlaunchTarget('--inspect=0',script);
5757
target=childProc;
58-
cli=startCLI([`${host||'127.0.0.1'}:${port}`]);
58+
cli=startCLI([`${host||'127.0.0.1'}:${port}`],[],{},{randomPort: false});
5959
awaitcli.waitForPrompt();
6060
awaitcli.command('sb("alive.js", 3)');
6161
awaitcli.waitFor(/break/);

‎test/parallel/test-debugger-auto-resume.mjs‎

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,7 @@ addLibraryPath(process.env);
2121
};
2222
env.NODE_INSPECT_RESUME_ON_START='1';
2323

24-
constcli=startCLI(['--port=0',script],[],{
25-
env,
26-
});
24+
constcli=startCLI([script],[],{ env });
2725

2826
awaitcli.waitForInitialBreak();
2927
deepStrictEqual(cli.breakInfo,{

‎test/parallel/test-debugger-backtrace.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const path = require('path');
1313
{
1414
constscriptFullPath=fixtures.path('debugger','backtrace.js');
1515
constscript=path.relative(process.cwd(),scriptFullPath);
16-
constcli=startCLI(['--port=0',script]);
16+
constcli=startCLI([script]);
1717

1818
asyncfunctionrunTest(){
1919
try{

‎test/parallel/test-debugger-break.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const path = require('path');
1111

1212
constscriptFullPath=fixtures.path('debugger','break.js');
1313
constscript=path.relative(process.cwd(),scriptFullPath);
14-
constcli=startCLI(['--port=0',script]);
14+
constcli=startCLI([script]);
1515

1616
(async()=>{
1717
awaitcli.waitForInitialBreak();

‎test/parallel/test-debugger-breakpoint-exists.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ const startCLI = require('../common/debugger');
99

1010
// Test for "Breakpoint at specified location already exists" error.
1111
constscript=fixtures.path('debugger','three-lines.js');
12-
constcli=startCLI(['--port=0',script]);
12+
constcli=startCLI([script]);
1313

1414
(async()=>{
1515
try{

‎test/parallel/test-debugger-clear-breakpoints.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const path = require('path');
1313
{
1414
constscriptFullPath=fixtures.path('debugger','break.js');
1515
constscript=path.relative(process.cwd(),scriptFullPath);
16-
constcli=startCLI(['--port=0',script]);
16+
constcli=startCLI([script]);
1717

1818
functiononFatal(error){
1919
cli.quit();

‎test/parallel/test-debugger-exceptions.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const path = require('path');
1313
{
1414
constscriptFullPath=fixtures.path('debugger','exceptions.js');
1515
constscript=path.relative(process.cwd(),scriptFullPath);
16-
constcli=startCLI(['--port=0',script]);
16+
constcli=startCLI([script]);
1717

1818
(async()=>{
1919
try{

‎test/parallel/test-debugger-exec-scope.mjs‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import startCLI from '../common/debugger.js'
77

88
importassertfrom'assert';
99

10-
constcli=startCLI(['--port=0',path('debugger/backtrace.js')]);
10+
constcli=startCLI([path('debugger/backtrace.js')]);
1111

1212
try{
1313
awaitcli.waitForInitialBreak();

‎test/parallel/test-debugger-exec.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const startCLI = require('../common/debugger');
88

99
constassert=require('assert');
1010

11-
constcli=startCLI(['--port=0',fixtures.path('debugger/alive.js')]);
11+
constcli=startCLI([fixtures.path('debugger/alive.js')]);
1212

1313
asyncfunctionwaitInitialBreak(){
1414
try{

0 commit comments

Comments
(0)