From e1d229cd6bdff4b0c9ff412d5784bf61f4a92b40 Mon Sep 17 00:00:00 2001 From: RRFZ <247457381+Plastic-time@users.noreply.github.com> Date: Fri, 13 Nov 2026 19:31:25 +0000 Subject: [PATCH] test(process): plan scenario admission cases for a host that reaches it Planning for win32 refuses PTY capture before root admission runs, so the cancellation cases now plan for Linux on any host. The ENOTDIR admission case skips on Windows, which reports ENOENT for a path below a file and admits it as a root the scenario may create. Squashed from #9306 onto current main. Co-Authored-By: gensokyo-dev Co-Authored-By: Claude Opus 5.5 --- .../ProcessScenarioPreparation.test.ts | 57 +++++++++++-------- 1 file changed, 34 insertions(+), 23 deletions(-) diff --git a/src/application/process/ProcessScenarioPreparation.test.ts b/src/application/process/ProcessScenarioPreparation.test.ts index 05d1ec3740..9f850c8a63 100644 --- a/src/application/process/ProcessScenarioPreparation.test.ts +++ b/src/application/process/ProcessScenarioPreparation.test.ts @@ -13,29 +13,40 @@ import { prepareProcessScenarioPlan } from "./ProcessScenarioPreparation.js"; afterEach(() => vi.restoreAllMocks()); -it("rejects observation roots that capture admission rejects", async () => { - const root = await createTestTempDirectory("rea-process-plan-"); - const file = join(root, "selected"); - await writeFile(file, "not a directory"); - const scenario = processScenarioSchema.parse({ - executable: process.execPath, - working_directory: root, - filesystem_observation_paths: [join(file, "child")], - }); +/** + * Windows refuses capture before root admission runs. The cancellation cases + * replace admission, so they plan for a platform that reaches it on any host. + */ +const capturePlatform = "linux"; - const prepared = await prepareProcessScenarioPlan( - scenario, - {}, - process.platform, - ); +// A path below a regular file is ENOTDIR on POSIX. Windows reports ENOENT, +// which admission accepts as a root the scenario may create. +it.skipIf(process.platform === "win32")( + "rejects observation roots that capture admission rejects", + async () => { + const root = await createTestTempDirectory("rea-process-plan-"); + const file = join(root, "selected"); + await writeFile(file, "not a directory"); + const scenario = processScenarioSchema.parse({ + executable: process.execPath, + working_directory: root, + filesystem_observation_paths: [join(file, "child")], + }); - expect(prepared.ok).toBe(false); - if (prepared.ok) return; - expect(prepared.error).toMatchObject({ - _tag: "ProcessCaptureError", - userMessage: "filesystem observation admission failed", - }); -}); + const prepared = await prepareProcessScenarioPlan( + scenario, + {}, + process.platform, + ); + + expect(prepared.ok).toBe(false); + if (prepared.ok) return; + expect(prepared.error).toMatchObject({ + _tag: "ProcessCaptureError", + userMessage: "filesystem observation admission failed", + }); + }, +); it("reports cancellation normalized inside admission as planning cancellation", async () => { const scenario = processScenarioSchema.parse({ @@ -59,7 +70,7 @@ it("reports cancellation normalized inside admission as planning cancellation", const prepared = await prepareProcessScenarioPlan( scenario, {}, - process.platform, + capturePlatform, controller.signal, ); @@ -100,7 +111,7 @@ it("reports cancellation after the last awaited admission step", async () => { const planning = prepareProcessScenarioPlan( scenario, {}, - process.platform, + capturePlatform, controller.signal, );