@@ -181,6 +181,7 @@ const mockCore = { debug: vi.fn(), info: vi.fn(), notice: vi.fn(), warning: vi.f
181181 process . env . GH_AW_SAFE_OUTPUTS_STAGED = "false" ;
182182 // Stage the asset under a RUNNER_TEMP-based directory, NOT under the
183183 // agent-output directory (tempBase), to simulate a path-prefix mismatch.
184+ const prevRunnerTemp = process . env . RUNNER_TEMP ;
184185 const runnerTempBase = fs . mkdtempSync ( path . join ( "/tmp" , "test-gh-aw-rt-" ) ) ;
185186 process . env . RUNNER_TEMP = runnerTempBase ;
186187 const runnerAssetsDir = path . join ( runnerTempBase , "gh-aw" , "safeoutputs" , "assets" ) ;
@@ -198,14 +199,17 @@ const mockCore = { debug: vi.fn(), info: vi.fn(), notice: vi.fn(), warning: vi.f
198199 if ( fullCommand . includes ( "rev-parse" ) ) throw new Error ( "Branch does not exist" ) ;
199200 return 0 ;
200201 } ) ;
201- await executeScript ( ) ;
202- expect ( mockCore . setFailed ) . not . toHaveBeenCalled ( ) ;
203- const uploadCountCall = mockCore . setOutput . mock . calls . find ( call => "upload_count" === call [ 0 ] ) ;
204- expect ( uploadCountCall ) . toBeDefined ( ) ;
205- uploadCountCall && expect ( uploadCountCall [ 1 ] ) . toBe ( "1" ) ;
206- delete process . env . RUNNER_TEMP ;
207- fs . existsSync ( runnerTempBase ) && fs . rmSync ( runnerTempBase , { recursive : ! 0 , force : ! 0 } ) ;
208- fs . existsSync ( path . join ( process . cwd ( ) , targetFile ) ) && fs . unlinkSync ( path . join ( process . cwd ( ) , targetFile ) ) ;
202+ try {
203+ await executeScript ( ) ;
204+ expect ( mockCore . setFailed ) . not . toHaveBeenCalled ( ) ;
205+ const uploadCountCall = mockCore . setOutput . mock . calls . find ( call => "upload_count" === call [ 0 ] ) ;
206+ expect ( uploadCountCall ) . toBeDefined ( ) ;
207+ uploadCountCall && expect ( uploadCountCall [ 1 ] ) . toBe ( "1" ) ;
208+ } finally {
209+ void 0 === prevRunnerTemp ? delete process . env . RUNNER_TEMP : ( process . env . RUNNER_TEMP = prevRunnerTemp ) ;
210+ fs . existsSync ( runnerTempBase ) && fs . rmSync ( runnerTempBase , { recursive : ! 0 , force : ! 0 } ) ;
211+ fs . existsSync ( path . join ( process . cwd ( ) , targetFile ) ) && fs . unlinkSync ( path . join ( process . cwd ( ) , targetFile ) ) ;
212+ }
209213 } ) ;
210214 } ) ;
211215 } ) ) ;
0 commit comments