@devries-cameron20 / t3code Mirror · read-only / commits / 9fa54eeb4c
Fork 0

The best way to control Claude Code, Codex and more from any computer or phone

Mirrored from https://github.com/Camo67/t3code.git

Synced Nov 24, 10:15 UTC

test: resolve the Windows temp directory to its long name (#9573)

Co-authored-by: Claude Code <noreply@anthropic.com>

Julius Marminge committed Sep 4, 2026 at 13:33 UTC 9fa54eeb4c481b444c68e38d00066d707af5f677
8 files changed +71 -33
apps/desktop/vite.config.ts
+2
@@ -1,3 +1,4 @@
1 +import "vite-plus/test/config";
2 import { defineConfig } from "vite-plus";
3
4 import { loadRepoEnv } from "../../scripts/lib/public-config.ts";
@@ -87,5 +88,6 @@ export default defineConfig({
88 // The Windows lane runs workspace suites concurrently; filesystem-heavy
89 // desktop integration tests can exceed Vitest's 5 second default there.
90 testTimeout: 15_000,
91 + setupFiles: ["../../packages/shared/src/testing/longTempDir.ts"],
92 },
93 });
apps/server/src/bootstrap.test.ts
+38 -33
@@ -55,6 +55,8 @@ vi.mock("node:fs", async (importOriginal) => {
55 };
56 });
57
58 +const windowsHost = HostProcessPlatform.defaultValue() === "win32";
59 +const nullDevice = windowsHost ? "\\\\.\\NUL" : "/dev/null";
60 const TestEnvelopeSchema = Schema.Struct({ mode: Schema.String });
61 const encodeTestEnvelopeSchema = Schema.encodeEffect(Schema.fromJsonString(TestEnvelopeSchema));
62
@@ -146,7 +148,7 @@ it.layer(NodeServices.layer)("readBootstrapEnvelope", (it) => {
148
149 it.effect("returns none when the fd is unavailable", () =>
150 Effect.gen(function* () {
149 - const fd = NodeFS.openSync("/dev/null", "r");
151 + const fd = NodeFS.openSync(nullDevice, "r");
152 NodeFS.closeSync(fd);
153
154 const payload = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, { timeoutMs: 100 });
@@ -157,7 +159,7 @@ it.layer(NodeServices.layer)("readBootstrapEnvelope", (it) => {
159 it.effect("preserves fd and cause when stat fails for a non-availability reason", () =>
160 Effect.gen(function* () {
161 const fd = yield* Effect.acquireRelease(
160 - Effect.sync(() => NodeFS.openSync("/dev/null", "r")),
162 + Effect.sync(() => NodeFS.openSync(nullDevice, "r")),
163 (fd) => Effect.sync(() => NodeFS.closeSync(fd)),
164 );
165
@@ -201,40 +203,43 @@ it.layer(NodeServices.layer)("readBootstrapEnvelope", (it) => {
203 }),
204 );
205
204 - it.effect("returns none when the bootstrap read times out before any value arrives", () =>
205 - Effect.gen(function* () {
206 - const fs = yield* FileSystem.FileSystem;
207 - const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-bootstrap-" });
208 - const fifoPath = NodePath.join(tempDir, "bootstrap.pipe");
209 -
210 - yield* Effect.sync(() => NodeChildProcess.execFileSync("mkfifo", [fifoPath]));
211 -
212 - const _writer = yield* Effect.acquireRelease(
213 - Effect.sync(() =>
214 - NodeChildProcess.spawn("sh", ["-c", 'exec 3>"$1"; sleep 60', "sh", fifoPath], {
215 - stdio: ["ignore", "ignore", "ignore"],
216 - }),
217 - ),
218 - (writer) =>
219 - Effect.sync(() => {
220 - writer.kill("SIGKILL");
221 - }),
222 - );
206 + // Needs a FIFO, which mkfifo creates; Windows has neither.
207 + it.effect.skipIf(windowsHost)(
208 + "returns none when the bootstrap read times out before any value arrives",
209 + () =>
210 + Effect.gen(function* () {
211 + const fs = yield* FileSystem.FileSystem;
212 + const tempDir = yield* fs.makeTempDirectoryScoped({ prefix: "t3-bootstrap-" });
213 + const fifoPath = NodePath.join(tempDir, "bootstrap.pipe");
214 +
215 + yield* Effect.sync(() => NodeChildProcess.execFileSync("mkfifo", [fifoPath]));
216 +
217 + const _writer = yield* Effect.acquireRelease(
218 + Effect.sync(() =>
219 + NodeChildProcess.spawn("sh", ["-c", 'exec 3>"$1"; sleep 60', "sh", fifoPath], {
220 + stdio: ["ignore", "ignore", "ignore"],
221 + }),
222 + ),
223 + (writer) =>
224 + Effect.sync(() => {
225 + writer.kill("SIGKILL");
226 + }),
227 + );
228
224 - const fd = yield* Effect.acquireRelease(
225 - Effect.sync(() => NodeFS.openSync(fifoPath, "r")),
226 - (fd) => Effect.sync(() => NodeFS.closeSync(fd)),
227 - );
229 + const fd = yield* Effect.acquireRelease(
230 + Effect.sync(() => NodeFS.openSync(fifoPath, "r")),
231 + (fd) => Effect.sync(() => NodeFS.closeSync(fd)),
232 + );
233
229 - const fiber = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, {
230 - timeoutMs: 100,
231 - }).pipe(Effect.forkScoped);
234 + const fiber = yield* readBootstrapEnvelope(TestEnvelopeSchema, fd, {
235 + timeoutMs: 100,
236 + }).pipe(Effect.forkScoped);
237
233 - yield* Effect.yieldNow;
234 - yield* TestClock.adjust(Duration.millis(100));
238 + yield* Effect.yieldNow;
239 + yield* TestClock.adjust(Duration.millis(100));
240
236 - const payload = yield* Fiber.join(fiber);
237 - assertNone(payload);
238 - }).pipe(Effect.provide(TestClock.layer())),
241 + const payload = yield* Fiber.join(fiber);
242 + assertNone(payload);
243 + }).pipe(Effect.provide(TestClock.layer())),
244 );
245 });
apps/server/vite.config.ts
+1
@@ -78,6 +78,7 @@ export default mergeConfig(
78 // The server suite exercises sqlite, git, temp worktrees, and orchestration
79 // runtimes heavily. Running files in parallel introduces load-sensitive flakes.
80 fileParallelism: false,
81 + // Appended to the root setup, which mergeConfig concatenates.
82 setupFiles: ["./src/testUtils/gitConfig.setup.ts"],
83 // Server integration tests exercise sqlite, git, and orchestration together.
84 // Under package-wide runs they can exceed the default budget on loaded CI hosts.
apps/web/vite.config.ts
+1
@@ -80,6 +80,7 @@ const unitTestProject = {
80 // run, those async tests can exceed Vitest's default 5s budget.
81 hookTimeout: 15_000,
82 testTimeout: 15_000,
83 + setupFiles: ["../../packages/shared/src/testing/longTempDir.ts"],
84 },
85 } satisfies TestProjectInlineConfiguration;
86
packages/client-runtime/vite.config.ts
+1
@@ -5,5 +5,6 @@ export default defineConfig({
5 test: {
6 environment: "node",
7 include: ["src/**/*.test.ts"],
8 + setupFiles: ["../shared/src/testing/longTempDir.ts"],
9 },
10 });
packages/shared/package.json
+4
@@ -223,6 +223,10 @@
223 "types": "./src/hostProcess.ts",
224 "import": "./src/hostProcess.ts"
225 },
226 + "./testing/longTempDir": {
227 + "types": "./src/testing/longTempDir.ts",
228 + "import": "./src/testing/longTempDir.ts"
229 + },
230 "./testing/symlinks": {
231 "types": "./src/testing/symlinks.ts",
232 "import": "./src/testing/symlinks.ts"
packages/shared/src/testing/longTempDir.ts new
+19
@@ -0,0 +1,19 @@
1 +// @effect-diagnostics nodeBuiltinImport:off - runs once at test setup, outside any Effect runtime.
2 +import * as NodeFS from "node:fs";
3 +import * as NodeOS from "node:os";
4 +import { HostProcessPlatform } from "../hostProcess.ts";
5 +
6 +// GitHub's Windows runners hand out the temp directory by its 8.3 short name
7 +// (C:\Users\RUNNER~1\...). Anything that canonicalises a path, such as git or
8 +// realpath, reports the long form, so equality checks between a temp path and
9 +// its canonical form fail. Node reads TEMP/TMP on every os.tmpdir() call, so
10 +// pointing them at the long form fixes every temp directory the suite makes.
11 +if (HostProcessPlatform.defaultValue() === "win32") {
12 + try {
13 + const longForm = NodeFS.realpathSync.native(NodeOS.tmpdir());
14 + process.env.TEMP = longForm;
15 + process.env.TMP = longForm;
16 + } catch {
17 + // Leave the host's value alone if it cannot be resolved.
18 + }
19 +}
vite.config.ts
+5
@@ -19,6 +19,11 @@ export default defineConfig({
19 ],
20 hookTimeout: 60_000,
21 testTimeout: 60_000,
22 + setupFiles: [
23 + NodeURL.fileURLToPath(
24 + new URL("./packages/shared/src/testing/longTempDir.ts", import.meta.url),
25 + ),
26 + ],
27 },
28 staged: {
29 // Formatter only for now — no lint or typecheck on commit.