@@ -333,6 +333,40 @@ describe('devframeTerminalHost child-process status lifecycle', () => {
333333} )
334334
335335describe ( 'devframeTerminalHost interactive PTY sessions' , ( ) => {
336+ itPty ( 'inherits the parent process environment' , async ( ) => {
337+ expect . assertions ( 1 )
338+
339+ const environmentVariable = 'DEVFRAME_PTY_INHERITED_ENV'
340+ const previousValue = process . env [ environmentVariable ]
341+ process . env [ environmentVariable ] = 'inherited'
342+
343+ let session : Awaited < ReturnType < DevframeTerminalsHost [ 'startPtySession' ] > > | undefined
344+ try {
345+ const { host, sinks } = createTerminalHost ( )
346+ session = await host . startPtySession ( {
347+ command : NODE ,
348+ args : [ '-e' , `process.stdout.write(process.env.${ environmentVariable } ?? "missing")` ] ,
349+ } , {
350+ id : 'pty-environment' ,
351+ title : 'PTY environment' ,
352+ } )
353+
354+ await waitUntil ( ( ) => {
355+ if ( ! sinks . get ( 'pty-environment' ) ?. closed )
356+ throw new Error ( 'PTY stream is still open' )
357+ } )
358+
359+ expect ( session . buffer ?. join ( '' ) ) . toContain ( 'inherited' )
360+ }
361+ finally {
362+ await session ?. terminate ( )
363+ if ( previousValue === undefined )
364+ delete process . env [ environmentVariable ]
365+ else
366+ process . env [ environmentVariable ] = previousValue
367+ }
368+ } )
369+
336370 itPosixPty ( 'spawns an interactive PTY that accepts input and is marked interactive' , async ( ) => {
337371 const { host, sinks } = createTerminalHost ( )
338372
0 commit comments