@@ -234,32 +234,38 @@ describe('BackgroundExecSessionManager', () => {
234234 expect ( log . output ) . toBe ( 'timeout tail' )
235235 } )
236236
237- it ( 'passes the prepared env through start without re-merging PATH ' , async ( ) => {
237+ it ( 'merges the prepared env on top of process env when starting a session ' , async ( ) => {
238238 const child = new MockChildProcess ( )
239239 vi . mocked ( spawn ) . mockReturnValue ( child as never )
240+ process . env . BASELINE_FLAG = 'baseline'
240241
241- const result = await manager . start ( 'conv-1' , 'echo test' , '/workspace' , {
242- timeout : 0 ,
243- env : {
244- PATH : '/prepared/bin:/usr/local/bin' ,
245- CUSTOM_FLAG : '1'
246- }
247- } )
248-
249- expect ( result ) . toEqual ( {
250- sessionId : expect . stringMatching ( / ^ b g _ / ) ,
251- status : 'running'
252- } )
253- expect ( spawn ) . toHaveBeenCalledWith (
254- expect . any ( String ) ,
255- expect . any ( Array ) ,
256- expect . objectContaining ( {
257- cwd : '/workspace' ,
242+ try {
243+ const result = await manager . start ( 'conv-1' , 'echo test' , '/workspace' , {
244+ timeout : 0 ,
258245 env : {
259246 PATH : '/prepared/bin:/usr/local/bin' ,
260247 CUSTOM_FLAG : '1'
261248 }
262249 } )
263- )
250+
251+ expect ( result ) . toEqual ( {
252+ sessionId : expect . stringMatching ( / ^ b g _ / ) ,
253+ status : 'running'
254+ } )
255+ expect ( spawn ) . toHaveBeenCalledWith (
256+ expect . any ( String ) ,
257+ expect . any ( Array ) ,
258+ expect . objectContaining ( {
259+ cwd : '/workspace' ,
260+ env : expect . objectContaining ( {
261+ BASELINE_FLAG : 'baseline' ,
262+ PATH : '/prepared/bin:/usr/local/bin' ,
263+ CUSTOM_FLAG : '1'
264+ } )
265+ } )
266+ )
267+ } finally {
268+ delete process . env . BASELINE_FLAG
269+ }
264270 } )
265271} )
0 commit comments