TypeScript
test(server): keep provider fixture directories host-portable (#9572)
Julius Marminge9af5139f5974
diff --git a/apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.ts b/apps/server/src/provider/Layers/ClaudeCapabilitiesProbe.test.tsindex 25311829982..f167955fbae 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.tsindex 7fcbe7b5f33..02b7a45f33a 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:offimport * 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 },});