From 9af5139f5974281a59f5cd62c11d918d62126313 Mon Sep 17 00:00:00 2001 From: Julius Marminge Date: Fri, 4 Sep 2026 13:33:22 -0700 Subject: [PATCH] test(server): keep provider fixture directories host-portable (#9572) Co-authored-by: Claude Code --- .../Layers/ClaudeCapabilitiesProbe.test.ts | 23 +++++++++++++++++-- .../CodexCollabRuntime.integration.test.ts | 15 ++++++------ 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts b/apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts index 2531182998207fef2f28cba3b75760013a92e2e3..f167955fbaec3e77f223807f6260b79240264e3c 100644 --- a/apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts +++ b/apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts @@ -1,4 +1,6 @@ +// @effect-diagnostics nodeBuiltinImport:off - cleanup uses Node's retrying rm, which the FileSystem service does not expose. import { ClaudeSettings } from "@t3tools/contracts"; +import * as NodeFSP from "node:fs/promises"; import * as NodeServices from "@effect/platform-node/NodeServices"; import { assert, it } from "@effect/vitest"; import * as Effect from "effect/Effect"; @@ -51,8 +53,25 @@ it.layer(NodeServices.layer)("Claude capability probe SDK boundary", (it) => { const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-claude-probe-sdk-" }); const executablePath = path.join(tempDir, "fake-claude.mjs"); const invocationPath = path.join(tempDir, "invocation.json"); - const workspaceCwd = path.join(tempDir, "workspace"); - yield* fs.makeDirectory(workspaceCwd, { recursive: true }); + // The probe aborts the SDK without awaiting the child's exit, and on + // Windows a directory that is still some process's cwd cannot be + // removed. Keep the workspace outside the scoped directory and let it + // go with a retrying removal once the child has gone. + const workspaceCwd = yield* fs.makeTempDirectory({ prefix: "t3-claude-probe-cwd-" }); + // Node's own retry rather than an Effect schedule: it.effect runs on a + // TestClock, so a scheduled retry would wait for time nobody advances. + // If the child still holds the directory after that, an empty temp + // directory is left behind rather than failing the test for it. + yield* Effect.addFinalizer(() => + Effect.promise(() => + NodeFSP.rm(workspaceCwd, { + recursive: true, + force: true, + maxRetries: 20, + retryDelay: 250, + }).catch(() => undefined), + ), + ); yield* fs.writeFileString( executablePath, diff --git a/apps/server/src/provider/Layers/CodexCollabRuntime.integration.test.ts b/apps/server/src/provider/Layers/CodexCollabRuntime.integration.test.ts index 7fcbe7b5f33473d42fc224807f42cd1609696964..02b7a45f33adedd616f116570edfa6a98c93198e 100644 --- a/apps/server/src/provider/Layers/CodexCollabRuntime.integration.test.ts +++ b/apps/server/src/provider/Layers/CodexCollabRuntime.integration.test.ts @@ -9,6 +9,7 @@ */ // @effect-diagnostics nodeBuiltinImport:off import * as NodeFS from "node:fs"; +import * as NodeOS from "node:os"; import * as NodePath from "node:path"; import * as NodeServices from "@effect/platform-node/NodeServices"; @@ -200,7 +201,7 @@ describe("CodexSessionRuntime collab integration", () => { const runtime = yield* makeCodexSessionRuntime({ threadId: ThreadId.make("thread-collab-model-activity"), binaryPath: peerPath, - cwd: "/tmp", + cwd: NodeOS.tmpdir(), runtimeMode: "full-access", environment: { ...process.env, T3_CODEX_COLLAB_SCRIPT: scriptPath }, }); @@ -292,7 +293,7 @@ describe("CodexSessionRuntime collab integration", () => { const runtime = yield* makeCodexSessionRuntime({ threadId: ThreadId.make("thread-collab-model-spawn"), binaryPath: peerPath, - cwd: "/tmp", + cwd: NodeOS.tmpdir(), runtimeMode: "full-access", environment: { ...process.env, T3_CODEX_COLLAB_SCRIPT: scriptPath }, }); @@ -371,7 +372,7 @@ describe("CodexSessionRuntime collab integration", () => { const runtime = yield* makeCodexSessionRuntime({ threadId: ThreadId.make(`thread-collab-model-${name}`), binaryPath: peerPath, - cwd: "/tmp", + cwd: NodeOS.tmpdir(), runtimeMode: "full-access", environment: { ...process.env, T3_CODEX_COLLAB_SCRIPT: scriptPath }, }); @@ -410,7 +411,7 @@ describe("CodexSessionRuntime collab integration", () => { const runtime = yield* makeCodexSessionRuntime({ threadId: ThreadId.make("thread-collab-integration"), binaryPath: peerPath, - cwd: "/tmp", + cwd: NodeOS.tmpdir(), runtimeMode: "full-access", environment: { ...process.env, T3_CODEX_COLLAB_SCRIPT: scriptPath }, }); @@ -552,7 +553,7 @@ describe("CodexSessionRuntime collab integration", () => { const runtime = yield* makeCodexSessionRuntime({ threadId: ThreadId.make("thread-collab-stop"), binaryPath: peerPath, - cwd: "/tmp", + cwd: NodeOS.tmpdir(), runtimeMode: "full-access", environment: { ...process.env, T3_CODEX_COLLAB_SCRIPT: scriptPath }, }); @@ -630,7 +631,7 @@ describe("CodexSessionRuntime collab integration", () => { const runtime = yield* makeCodexSessionRuntime({ threadId: ThreadId.make("thread-codex-queued-stop"), binaryPath: peerPath, - cwd: "/tmp", + cwd: NodeOS.tmpdir(), runtimeMode: "full-access", environment: { ...process.env, T3_CODEX_COLLAB_SCRIPT: scriptPath }, }); @@ -727,7 +728,7 @@ describe("CodexSessionRuntime collab integration", () => { const runtime = yield* makeCodexSessionRuntime({ threadId: ThreadId.make("thread-codex-mcp-elicitation"), binaryPath: peerPath, - cwd: "/tmp", + cwd: NodeOS.tmpdir(), runtimeMode: "auto", environment: { ...process.env, T3_CODEX_COLLAB_SCRIPT: scriptPath }, }); -- 2.54.0