Q57: quitting stops running sessions and waits for them to record their end
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d72333a04c
commit
3bc0d811cb
4 files changed
+71
-9
No files matched your search
@@ -0,0 +1,29 @@
|
||||
import { describe, expect, test } from "vitest";
|
||||
import { stopAllRunsAndWait, untilStopped, withRunControl } from "../../src/main/services/run-control";
|
||||
|
||||
describe("run control", () => {
|
||||
test("shutdown stops every run and waits until each has recorded its ending", async () => {
|
||||
const recorded: string[] = [];
|
||||
const session = (id: string) => withRunControl(id, async () => {
|
||||
try {
|
||||
await untilStopped(new Promise<never>(() => {}));
|
||||
} catch (error) {
|
||||
await new Promise((resolve) => setTimeout(resolve, 20));
|
||||
recorded.push(`${id}: ${(error as Error).message}`);
|
||||
throw error;
|
||||
}
|
||||
});
|
||||
const runs = [session("run_a"), session("run_b")].map((run) => run.catch(() => undefined));
|
||||
expect(await stopAllRunsAndWait("The app was closing.", 2_000)).toBe(0);
|
||||
expect(recorded.sort()).toEqual(["run_a: The app was closing.", "run_b: The app was closing."]);
|
||||
await Promise.all(runs);
|
||||
});
|
||||
|
||||
test("a run that ignores the stop is reported as unsettled after the grace period", async () => {
|
||||
let release = () => {};
|
||||
const stubborn = withRunControl("run_stubborn", () => new Promise<void>((resolve) => { release = resolve; }));
|
||||
expect(await stopAllRunsAndWait("The app was closing.", 30)).toBe(1);
|
||||
release();
|
||||
await stubborn;
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user