From 1ba93b46022002f6cdf3f682cea2e3009897cf46 Mon Sep 17 00:00:00 2001 From: gensokyo-dev Date: Sat, 14 Nov 2026 15:54:10 +0000 Subject: [PATCH] test(desktop): fail promptly when synthetic children never get ready The fake application now leaves a marker when its children never report ready, and the tests' session requests throw on it, so capture releases the children and the test fails at once instead of waiting for its deadline. Refs #10366 Co-Authored-By: gensokyo-dev <342580529+gensokyo-dev@users.noreply.github.com> --- .../desktop/DesktopApplicationCapture.test.ts | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/application/desktop/DesktopApplicationCapture.test.ts b/src/application/desktop/DesktopApplicationCapture.test.ts index 98167eac9b..6190cb243f 100644 --- a/src/application/desktop/DesktopApplicationCapture.test.ts +++ b/src/application/desktop/DesktopApplicationCapture.test.ts @@ -145,13 +145,19 @@ const installProcessFamily = async (root: string, path: string) => { `setsid sh -c 'trap "touch ${join(root, "setsid-term")}; exit 0" TERM; touch "${join(root, "setsid-ready")}"; ${loop}' &`, // Wait for both children to install their traps before writing state.ini. // Fail loudly rather than continue when a child never reports ready. - `ready=; for i in $(seq 1 500); do if [ -f "${join(root, "group-ready")}" ] && [ -f "${join(root, "setsid-ready")}" ]; then ready=1; break; fi; sleep 0.01; done; [ -n "$ready" ] || { echo "synthetic children did not report ready" >&2; exit 97; }`, + `ready=; for i in $(seq 1 500); do if [ -f "${join(root, "group-ready")}" ] && [ -f "${join(root, "setsid-ready")}" ]; then ready=1; break; fi; sleep 0.01; done; [ -n "$ready" ] || { echo "synthetic children did not report ready" >&2; touch "${join(root, "children-not-ready")}"; exit 97; }`, 'printf "count=1\\n" > "$HOME/.config/fakeapp/state.ini"', loop, ].join("\n"), ); }; +/** Surface a fake application whose children never got ready, instead of waiting. */ +const failIfChildrenNotReady = (root: string): void => { + if (fileExists(join(root, "children-not-ready"))) + throw new Error("synthetic children did not report ready"); +}; + const host = ( environment: NodeJS.ProcessEnv, nextRequest: () => SessionRequest | undefined = () => undefined, @@ -660,6 +666,7 @@ describe.skipIf(process.platform !== "linux")( const statePath = join(home, ".config/fakeapp/state.ini"); let writtenAt: number | undefined; const nextRequest = (): SessionRequest | undefined => { + failIfChildrenNotReady(root); // Wait for both children to install their traps before issuing the stop. if (readFileSyncSafe(statePath) !== "count=1\n") return undefined; if ( @@ -693,10 +700,12 @@ describe.skipIf(process.platform !== "linux")( await installProcessFamily(root, environment.PATH); const statePath = join(home, ".config/fakeapp/state.ini"); const output = join(root, "out"); - const nextRequest = (): SessionRequest | undefined => - readFileSyncSafe(statePath) === "count=1\n" + const nextRequest = (): SessionRequest | undefined => { + failIfChildrenNotReady(root); + return readFileSyncSafe(statePath) === "count=1\n" ? { kind: "checkpoint", name: "written" } : undefined; + }; const failed = await captureDesktopApplication(request(output), { ...host(environment, nextRequest),