mirror of
https://github.com/anthropics/claude-code-action.git
synced 2026-08-22 03:18:54 +08:00
fix: write execution file when SDK throws (#1255)
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env bun
|
||||
|
||||
import * as core from "@actions/core";
|
||||
import { afterEach, describe, expect, spyOn, test } from "bun:test";
|
||||
import { mkdtemp, rm, writeFile } from "fs/promises";
|
||||
import { tmpdir } from "os";
|
||||
import { join } from "path";
|
||||
import { setExecutionFileOutputIfPresent } from "../src/execution-file";
|
||||
|
||||
describe("execution file output", () => {
|
||||
const originalRunnerTemp = process.env.RUNNER_TEMP;
|
||||
let tempDir: string | undefined;
|
||||
|
||||
afterEach(async () => {
|
||||
if (tempDir) {
|
||||
await rm(tempDir, { recursive: true, force: true });
|
||||
tempDir = undefined;
|
||||
}
|
||||
process.env.RUNNER_TEMP = originalRunnerTemp;
|
||||
});
|
||||
|
||||
test("sets execution_file output when the default execution file exists", async () => {
|
||||
const setOutputSpy = spyOn(core, "setOutput").mockImplementation(() => {});
|
||||
tempDir = await mkdtemp(join(tmpdir(), "claude-execution-file-"));
|
||||
process.env.RUNNER_TEMP = tempDir;
|
||||
const executionFile = join(tempDir, "claude-execution-output.json");
|
||||
await writeFile(executionFile, "[]");
|
||||
|
||||
try {
|
||||
expect(setExecutionFileOutputIfPresent()).toBe(executionFile);
|
||||
expect(setOutputSpy).toHaveBeenCalledWith(
|
||||
"execution_file",
|
||||
executionFile,
|
||||
);
|
||||
} finally {
|
||||
setOutputSpy.mockRestore();
|
||||
}
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user