@@ -119,10 +119,11 @@ describe('node runtime', () => {
119
119
'test.js' : [ 'const message = "hello world!";' , 'console.log(message);' , 'debugger;' ] ,
120
120
} ) ;
121
121
const chakracore = join ( testWorkspace , 'chakracore' , 'ChakraCore.Debugger.Sample.exe' ) ;
122
+ const port = await findOpenPort ( ) ;
122
123
const handle = await r . runScript ( 'test.js' , {
123
124
runtimeExecutable : chakracore ,
124
- runtimeArgs : [ '--inspect-brk' , '--port' , '9229' ] ,
125
- attachSimplePort : 9229 ,
125
+ runtimeArgs : [ '--inspect-brk' , '--port' , ` ${ port } ` ] ,
126
+ attachSimplePort : port ,
126
127
continueOnAttach : true ,
127
128
} ) ;
128
129
@@ -325,9 +326,10 @@ describe('node runtime', () => {
325
326
'test.js' : [ 'setInterval(() => { debugger; }, 500)' ] ,
326
327
} ) ;
327
328
328
- child = spawn ( 'node' , [ '--inspect' , join ( testFixturesDir , 'test' ) ] ) ;
329
+ const port = await findOpenPort ( ) ;
330
+ child = spawn ( 'node' , [ `--inspect=${ port } ` , join ( testFixturesDir , 'test' ) ] ) ;
329
331
await delay ( 500 ) ; // give it a moment to boot
330
- const handle = await r . attachNode ( child . pid ! ) ;
332
+ const handle = await r . attachNode ( child . pid ! , { port } ) ;
331
333
await waitForPause ( handle ) ;
332
334
handle . assertLog ( { substring : true } ) ;
333
335
} ) ;
@@ -339,8 +341,9 @@ describe('node runtime', () => {
339
341
'test.js' : [ 'console.log("");' , 'debugger;' ] ,
340
342
} ) ;
341
343
342
- child = spawn ( 'node' , [ '--inspect-brk' , join ( testFixturesDir , 'test' ) ] ) ;
343
- const handle = await r . attachNode ( 0 , { continueOnAttach : true } ) ;
344
+ const port = await findOpenPort ( ) ;
345
+ child = spawn ( 'node' , [ `--inspect-brk=${ port } ` , join ( testFixturesDir , 'test' ) ] ) ;
346
+ const handle = await r . attachNode ( child . pid ! , { continueOnAttach : true , port } ) ;
344
347
await waitForPause ( handle ) ; // pauses on 2nd line, not 1st
345
348
handle . assertLog ( { substring : true } ) ;
346
349
} ) ;
@@ -350,9 +353,10 @@ describe('node runtime', () => {
350
353
'test.js' : [ 'setInterval(() => { debugger; }, 500)' ] ,
351
354
} ) ;
352
355
353
- const handleProm = r . attachNode ( 0 , { port : 9229 } ) ;
356
+ const port = await findOpenPort ( ) ;
357
+ const handleProm = r . attachNode ( 0 , { port } ) ;
354
358
await delay ( 500 ) ; // give it a moment to start trying to attach
355
- child = spawn ( 'node' , [ ' --inspect' , join ( testFixturesDir , 'test' ) ] ) ;
359
+ child = spawn ( 'node' , [ ` --inspect= ${ port } ` , join ( testFixturesDir , 'test' ) ] ) ;
356
360
const handle = await handleProm ;
357
361
await waitForPause ( handle ) ;
358
362
handle . assertLog ( { substring : true } ) ;
@@ -367,9 +371,10 @@ describe('node runtime', () => {
367
371
'child.js' : '(function foo() { debugger; })();' ,
368
372
} ) ;
369
373
370
- child = spawn ( 'node' , [ '--inspect' , join ( testFixturesDir , 'test' ) ] ) ;
374
+ const port = await findOpenPort ( ) ;
375
+ child = spawn ( 'node' , [ `--inspect=${ port } ` , join ( testFixturesDir , 'test' ) ] ) ;
371
376
await delay ( 500 ) ; // give it a moment to boot
372
- const handle = await r . attachNode ( child . pid ! ) ;
377
+ const handle = await r . attachNode ( child . pid ! , { port } ) ;
373
378
handle . load ( ) ;
374
379
375
380
const worker = await r . worker ( ) ;
@@ -391,9 +396,10 @@ describe('node runtime', () => {
391
396
` ,
392
397
} ) ;
393
398
394
- child = spawn ( 'node' , [ '--inspect' , join ( testFixturesDir , 'test' ) ] ) ;
399
+ const port = await findOpenPort ( ) ;
400
+ child = spawn ( 'node' , [ `--inspect=${ port } ` , join ( testFixturesDir , 'test' ) ] ) ;
395
401
await delay ( 500 ) ; // give it a moment to boot
396
- const handle = await r . attachNode ( child . pid ! ) ;
402
+ const handle = await r . attachNode ( child . pid ! , { port } ) ;
397
403
handle . load ( ) ;
398
404
399
405
const worker = await r . worker ( ) ;
@@ -408,13 +414,14 @@ describe('node runtime', () => {
408
414
'test.js' : [ 'setInterval(() => { debugger; }, 100)' ] ,
409
415
} ) ;
410
416
411
- child = spawn ( 'node' , [ '--inspect' , join ( testFixturesDir , 'test' ) ] ) ;
412
- const handle = await r . attachNode ( 0 , { port : 9229 , restart : true } ) ;
417
+ const port = await findOpenPort ( ) ;
418
+ child = spawn ( 'node' , [ `--inspect=${ port } ` , join ( testFixturesDir , 'test' ) ] ) ;
419
+ const handle = await r . attachNode ( 0 , { port, restart : true } ) ;
413
420
414
421
handle . log ( await handle . dap . once ( 'stopped' ) ) ;
415
422
await handle . dap . evaluate ( { expression : 'process.exit(0)' } ) ;
416
423
417
- child = spawn ( 'node' , [ ' --inspect' , join ( testFixturesDir , 'test' ) ] ) ;
424
+ child = spawn ( 'node' , [ ` --inspect= ${ port } ` , join ( testFixturesDir , 'test' ) ] ) ;
418
425
const reconnect = await r . waitForTopLevel ( ) ;
419
426
reconnect . load ( ) ;
420
427
@@ -427,11 +434,14 @@ describe('node runtime', () => {
427
434
'test.js' : [ 'setInterval(() => { debugger; }, 100)' ] ,
428
435
} ) ;
429
436
430
- child = spawn ( 'node' , [ '--inspect' , join ( testFixturesDir , 'test' ) ] , { stdio : 'pipe' } ) ;
437
+ const port = await findOpenPort ( ) ;
438
+ child = spawn ( 'node' , [ `--inspect=${ port } ` , join ( testFixturesDir , 'test' ) ] , {
439
+ stdio : 'pipe' ,
440
+ } ) ;
431
441
const lines : string [ ] = [ ] ;
432
442
child . stderr ?. pipe ( split ( ) ) . on ( 'data' , line => lines . push ( line ) ) ;
433
443
434
- const handle = await r . attachNode ( 0 , { port : 9229 , restart : true } ) ;
444
+ const handle = await r . attachNode ( 0 , { port, restart : true } ) ;
435
445
await handle . dap . once ( 'stopped' ) ;
436
446
await r . rootDap ( ) . disconnect ( { } ) ;
437
447
0 commit comments