port: sync from Mike/pygienium@a8a85473
This commit is contained in:
@@ -22,7 +22,7 @@ import {
|
||||
type AgentRunner,
|
||||
} from "../src/agent-runner.js";
|
||||
import { handleAllCommand, type PygieniumCtx } from "../src/commands.js";
|
||||
import { loadRunState } from "../src/run-state.js";
|
||||
import { loadRunState, markCheckStatus, markRunStatus, saveRunState } from "../src/run-state.js";
|
||||
import { canonicalChecksRoot } from "../src/export.js";
|
||||
|
||||
/** Stub check whose fake-runner task writes artifacts + echoes a line. */
|
||||
@@ -147,16 +147,27 @@ describe("/pygienium-all end-to-end (task 14)", () => {
|
||||
expect(out.join("\n")).toContain("no checks registered");
|
||||
});
|
||||
|
||||
it("is resumable: a second call reuses the existing run-state", async () => {
|
||||
it("is resumable: an unfinished run-state is continued, not restarted", async () => {
|
||||
registerCheck(fakeCheck("alpha"));
|
||||
// A completed run is finished work: the next call starts a new run-state.
|
||||
await captureStdout(() => handleAllCommand("--fix", stubCtx(cwd)));
|
||||
const first = await loadRunState(cwd);
|
||||
const firstStarted = first!.startedAt;
|
||||
const completed = await loadRunState(cwd);
|
||||
expect(completed!.status).toBe("complete");
|
||||
await captureStdout(() => handleAllCommand("--fix", stubCtx(cwd)));
|
||||
const fresh = await loadRunState(cwd);
|
||||
expect(fresh!.startedAt).toBeGreaterThan(completed!.startedAt);
|
||||
|
||||
// An unfinished one is continued: same run, same startedAt, and the
|
||||
// completed check is not dispatched again.
|
||||
const interrupted = await loadRunState(cwd);
|
||||
markRunStatus(interrupted!, "in_progress");
|
||||
markCheckStatus(interrupted!, "alpha", "in_progress");
|
||||
await saveRunState(interrupted!);
|
||||
const before = (await loadRunState(cwd))!.startedAt;
|
||||
|
||||
// Second run reloads the existing run-state (same startedAt).
|
||||
await captureStdout(() => handleAllCommand("--fix", stubCtx(cwd)));
|
||||
const second = await loadRunState(cwd);
|
||||
expect(second!.startedAt).toBe(firstStarted);
|
||||
expect(second!.status).toBe("complete");
|
||||
const resumed = await loadRunState(cwd);
|
||||
expect(resumed!.startedAt).toBe(before);
|
||||
expect(resumed!.status).toBe("complete");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user