@@ -10,8 +10,6 @@ import { writeFileSync, readFileSync } from 'node:fs';
1010import { inspect } from 'node:util' ;
1111import { once } from 'node:events' ;
1212import { setTimeout } from 'node:timers/promises' ;
13- import { NodeInstance } from '../common/inspector-helper.js' ;
14-
1513
1614if ( common . isIBMi )
1715 common . skip ( 'IBMi does not support `fs.watch()`' ) ;
@@ -234,67 +232,4 @@ describe('watch mode', { concurrency: false, timeout: 60_0000 }, () => {
234232 `Completed running ${ inspect ( file ) } ` , `Restarting ${ inspect ( file ) } ` , `Completed running ${ inspect ( file ) } ` , '' ,
235233 ] . join ( '\n' ) ) ;
236234 } ) ;
237-
238- describe ( 'inspect' , {
239- skip : Boolean ( process . config . variables . coverage || ! process . features . inspector ) ,
240- } , ( ) => {
241- const silentLogger = { log : ( ) => { } , error : ( ) => { } } ;
242- async function getDebuggedPid ( instance , waitForLog = true ) {
243- const session = await instance . connectInspectorSession ( ) ;
244- await session . send ( { method : 'Runtime.enable' } ) ;
245- if ( waitForLog ) {
246- await session . waitForConsoleOutput ( 'log' , 'safe to debug now' ) ;
247- }
248- const { value : innerPid } = ( await session . send ( {
249- 'method' : 'Runtime.evaluate' , 'params' : { 'expression' : 'process.pid' }
250- } ) ) . result ;
251- session . disconnect ( ) ;
252- return innerPid ;
253- }
254-
255- it ( 'should start debugger on inner process' , async ( ) => {
256- const file = fixtures . path ( 'watch-mode/inspect.js' ) ;
257- const instance = new NodeInstance ( [ '--inspect=0' , '--watch' ] , undefined , file , silentLogger ) ;
258- let stderr = '' ;
259- instance . on ( 'stderr' , ( data ) => { stderr += data ; } ) ;
260-
261- const pids = [ instance . pid ] ;
262- pids . push ( await getDebuggedPid ( instance ) ) ;
263- instance . resetPort ( ) ;
264- writeFileSync ( file , readFileSync ( file ) ) ;
265- pids . push ( await getDebuggedPid ( instance ) ) ;
266-
267- await instance . kill ( ) ;
268-
269- // There should be 3 pids (one parent + 2 restarts).
270- // Message about Debugger should only appear twice.
271- assert . strictEqual ( stderr . match ( / D e b u g g e r l i s t e n i n g o n w s : \/ \/ / g) . length , 2 ) ;
272- assert . strictEqual ( new Set ( pids ) . size , 3 ) ;
273- } ) ;
274-
275- it ( 'should prevent attaching debugger with SIGUSR1 to outer process' , { skip : common . isWindows } , async ( ) => {
276- const file = fixtures . path ( 'watch-mode/inspect_with_signal.js' ) ;
277- const instance = new NodeInstance ( [ '--inspect-port=0' , '--watch' ] , undefined , file , silentLogger ) ;
278- let stderr = '' ;
279- instance . on ( 'stderr' , ( data ) => { stderr += data ; } ) ;
280-
281- const loggedPid = await new Promise ( ( resolve ) => {
282- instance . on ( 'stdout' , ( data ) => {
283- const matches = data . match ( / p i d i s ( \d + ) / ) ;
284- if ( matches ) resolve ( Number ( matches [ 1 ] ) ) ;
285- } ) ;
286- } ) ;
287-
288-
289- process . kill ( instance . pid , 'SIGUSR1' ) ;
290- process . kill ( loggedPid , 'SIGUSR1' ) ;
291- const debuggedPid = await getDebuggedPid ( instance , false ) ;
292-
293- await instance . kill ( ) ;
294-
295- // Message about Debugger should only appear once in inner process.
296- assert . strictEqual ( stderr . match ( / D e b u g g e r l i s t e n i n g o n w s : \/ \/ / g) . length , 1 ) ;
297- assert . strictEqual ( loggedPid , debuggedPid ) ;
298- } ) ;
299- } ) ;
300235} ) ;
0 commit comments