Skip to content

Commit 0604fb7

Browse files
dsymeCopilot
andauthored
Potential fix for pull request finding
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 5fb70db commit 0604fb7

1 file changed

Lines changed: 12 additions & 8 deletions

File tree

actions/setup/js/upload_assets.test.cjs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)