@devries-cameron20 / t3code-1 / commits / 1108be0fc8
Fork 0

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

test: skip POSIX mode-bit assertions on a Windows host (#9571)

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

Julius Marminge committed Sep 4, 2026 at 13:33 UTC 1108be0fc862d5a95374bf0b96518a20e6351025
5 files changed +180 -153
apps/server/scripts/t3-sqlite-state.test.ts
+3 -1
@@ -7,6 +7,7 @@ import * as SqlClient from "effect/unstable/sql/SqlClient";
7
8 import * as NodeSqliteClient from "@t3tools/shared/nodeSqliteClient";
9 import { runSqliteState } from "./t3-sqlite-state.ts";
10 +import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
11 import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
12
13 const createFixtureDatabase = Effect.fn("createSqliteStateFixtureDatabase")(function* (
@@ -89,7 +90,8 @@ it.layer(NodeServices.layer)("t3-sqlite-state", (it) => {
90 sql: "INSERT INTO fixtures (id, label) VALUES (2, 'seeded')",
91 });
92 assert.equal(mutation.operation, "exec");
92 - if (mutation.operation === "exec") {
93 + if (mutation.operation === "exec" && (yield* HostProcessPlatform) !== "win32") {
94 + // NTFS has no POSIX mode bits to report.
95 assert.equal((yield* fs.stat(mutation.backup)).mode & 0o777, 0o600);
96 }
97
apps/server/src/cli/theme.test.ts
+9 -4
@@ -14,6 +14,11 @@ import { Command } from "effect/unstable/cli";
14
15 import { cli } from "../bin.ts";
16 import { symlinksSupported } from "@t3tools/shared/testing/symlinks";
17 +import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
18 +
19 +// These force a failure with chmod, which Windows ignores for directories and
20 +// cannot use to make a file unreadable, so the failure never happens there.
21 +const windowsHost = HostProcessPlatform.defaultValue() === "win32";
22
23 const runCli = (args: ReadonlyArray<string>) =>
24 Command.runWith(cli, { version: "0.0.0" })(args).pipe(
@@ -161,7 +166,7 @@ describe("t3 theme", () => {
166 // rolled back rather than left mutating the environment's theme set. The
167 // userdata directory is made read-only while themes stays writable, so the
168 // failure lands after the publish -- the case the rollback exists for.
164 - it.effect("rolls back a publish when the default cannot be written", () =>
169 + it.effect.skipIf(windowsHost)("rolls back a publish when the default cannot be written", () =>
170 Effect.gen(function* () {
171 const baseDir = makeBaseDir();
172 writeSettings(baseDir, {});
@@ -229,7 +234,7 @@ describe("t3 theme", () => {
234 // Rollback moves the previous directory entry aside and back, so even an
235 // entry the watcher would never publish -- here a symlink -- comes back
236 // exactly as it was when the set fails.
232 - it.effect.skipIf(!symlinksSupported)(
237 + it.effect.skipIf(!symlinksSupported || windowsHost)(
238 "restores a non-theme destination entry when the set fails",
239 () =>
240 Effect.gen(function* () {
@@ -255,7 +260,7 @@ describe("t3 theme", () => {
260 }),
261 );
262
258 - it.effect("restores the previous theme when a re-publish fails to set", () =>
263 + it.effect.skipIf(windowsHost)("restores the previous theme when a re-publish fails to set", () =>
264 Effect.gen(function* () {
265 const baseDir = makeBaseDir();
266 writeSettings(baseDir, {});
@@ -352,7 +357,7 @@ describe("t3 theme", () => {
357
358 // An unreadable settings file must never read as "no settings": writing a
359 // fresh sparse file over it would discard every key the user had.
355 - it.effect("refuses to write when the settings file cannot be read", () =>
360 + it.effect.skipIf(windowsHost)("refuses to write when the settings file cannot be read", () =>
361 Effect.gen(function* () {
362 const baseDir = makeBaseDir();
363 writeSettings(baseDir, { enableProviderUpdateChecks: false });
apps/server/src/keybindings.test.ts
+26 -22
@@ -12,6 +12,7 @@ import * as Schema from "effect/Schema";
12 import * as ServerConfig from "./config.ts";
13 import * as Keybindings from "./keybindings.ts";
14 import { KeybindingsConfigError } from "@t3tools/contracts";
15 +import { HostProcessPlatform } from "@t3tools/shared/hostProcess";
16
17 const KeybindingsConfigJson = Schema.fromJsonString(KeybindingsConfig);
18 const encodeKeybindingsConfigJson = Schema.encodeEffect(KeybindingsConfigJson);
@@ -511,31 +512,34 @@ it.layer(NodeServices.layer)("keybindings", (it) => {
512 }).pipe(Effect.provide(makeKeybindingsLayer())),
513 );
514
514 - it.effect("fails when config directory is not writable", () =>
515 - Effect.gen(function* () {
516 - const fs = yield* FileSystem.FileSystem;
517 - const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
518 - const { dirname } = yield* Path.Path;
519 - yield* writeKeybindingsConfig(keybindingsConfigPath, [
520 - { key: "mod+j", command: "terminal.toggle" },
521 - ]);
522 - yield* fs.chmod(dirname(keybindingsConfigPath), 0o500);
515 + // chmod cannot make a directory unwritable on Windows, so the write succeeds.
516 + it.effect.skipIf(HostProcessPlatform.defaultValue() === "win32")(
517 + "fails when config directory is not writable",
518 + () =>
519 + Effect.gen(function* () {
520 + const fs = yield* FileSystem.FileSystem;
521 + const { keybindingsConfigPath } = yield* ServerConfig.ServerConfig;
522 + const { dirname } = yield* Path.Path;
523 + yield* writeKeybindingsConfig(keybindingsConfigPath, [
524 + { key: "mod+j", command: "terminal.toggle" },
525 + ]);
526 + yield* fs.chmod(dirname(keybindingsConfigPath), 0o500);
527
524 - const result = yield* Effect.gen(function* () {
525 - const keybindings = yield* Keybindings.Keybindings;
526 - return yield* keybindings.upsertKeybindingRule({
527 - key: "mod+shift+r",
528 - command: "script.run-tests.run",
529 - });
530 - }).pipe(toDetailResult);
531 - assertFailure(result, "failed to write keybindings config");
528 + const result = yield* Effect.gen(function* () {
529 + const keybindings = yield* Keybindings.Keybindings;
530 + return yield* keybindings.upsertKeybindingRule({
531 + key: "mod+shift+r",
532 + command: "script.run-tests.run",
533 + });
534 + }).pipe(toDetailResult);
535 + assertFailure(result, "failed to write keybindings config");
536
533 - yield* fs.chmod(dirname(keybindingsConfigPath), 0o700);
537 + yield* fs.chmod(dirname(keybindingsConfigPath), 0o700);
538
535 - const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
536 - const persistedView = persisted.map(({ key, command }) => ({ key, command }));
537 - assert.deepEqual(persistedView, [{ key: "mod+j", command: "terminal.toggle" }]);
538 - }).pipe(Effect.provide(makeKeybindingsLayer())),
539 + const persisted = yield* readKeybindingsConfig(keybindingsConfigPath);
540 + const persistedView = persisted.map(({ key, command }) => ({ key, command }));
541 + assert.deepEqual(persistedView, [{ key: "mod+j", command: "terminal.toggle" }]);
542 + }).pipe(Effect.provide(makeKeybindingsLayer())),
543 );
544
545 it.effect("caches loaded resolved config across repeated reads", () =>
packages/shared/src/logging.test.ts
+6 -1
@@ -3,6 +3,7 @@ import * as NodeFS from "node:fs";
3 import * as NodeOS from "node:os";
4 import * as NodePath from "node:path";
5 import { afterEach, describe, expect, it } from "vite-plus/test";
6 +import { HostProcessPlatform } from "./hostProcess.ts";
7
8 import {
9 RotatingFileSink,
@@ -10,6 +11,7 @@ import {
11 RotatingFileSinkError,
12 } from "./logging.ts";
13
14 +const windowsHost = HostProcessPlatform.defaultValue() === "win32";
15 const tempDirectories: string[] = [];
16
17 const makeTempDirectory = (): string => {
@@ -69,7 +71,10 @@ describe("RotatingFileSink", () => {
71 expect((thrown as RotatingFileSinkError).cause).toBeInstanceOf(Error);
72 });
73
72 - it("only treats a missing log file as an empty current size", () => {
74 + // An over-long name is the one stat failure that is neither ENOENT nor a
75 + // permission problem on posix. Windows reports it as ENOENT, so the sink
76 + // correctly treats it as an absent file and there is nothing to assert.
77 + it.skipIf(windowsHost)("only treats a missing log file as an empty current size", () => {
78 const directory = makeTempDirectory();
79 const filePath = NodePath.join(directory, "a".repeat(300));
80
packages/shared/src/relayClient.test.ts
+136 -125
@@ -18,6 +18,10 @@ import {
18 makeCloudflaredRelayClient,
19 } from "./relayClient.ts";
20
21 +// The suite runs the linux code path against the real filesystem, checking
22 +// POSIX exec bits that NTFS never reports; the win32 branch skips that check.
23 +const windowsHost = HostProcessPlatform.defaultValue() === "win32";
24 +
25 const hostRuntimeLayer = (env: Record<string, string> = {}) =>
26 Layer.mergeAll(
27 Layer.succeed(HostProcessPlatform, "linux"),
@@ -63,102 +67,106 @@ const makeSpawnerLayer = (commands: Array<string>) =>
67 );
68
69 describe("RelayClient", () => {
66 - it.effect("resolves explicit overrides before managed and PATH executables", () =>
67 - Effect.gen(function* () {
68 - const fileSystem = yield* FileSystem.FileSystem;
69 - const baseDir = yield* fileSystem.makeTempDirectoryScoped({
70 - prefix: "t3-cloudflared-test-",
71 - });
72 - const overridePath = `${baseDir}/override-cloudflared`;
73 - yield* fileSystem.writeFileString(overridePath, "override");
74 - yield* fileSystem.chmod(overridePath, 0o755);
75 - const manager = yield* makeCloudflaredRelayClient({
76 - baseDir,
77 - });
70 + it.effect.skipIf(windowsHost)(
71 + "resolves explicit overrides before managed and PATH executables",
72 + () =>
73 + Effect.gen(function* () {
74 + const fileSystem = yield* FileSystem.FileSystem;
75 + const baseDir = yield* fileSystem.makeTempDirectoryScoped({
76 + prefix: "t3-cloudflared-test-",
77 + });
78 + const overridePath = `${baseDir}/override-cloudflared`;
79 + yield* fileSystem.writeFileString(overridePath, "override");
80 + yield* fileSystem.chmod(overridePath, 0o755);
81 + const manager = yield* makeCloudflaredRelayClient({
82 + baseDir,
83 + });
84
79 - expect(
80 - yield* manager.resolve.pipe(
81 - Effect.provideService(
82 - ConfigProvider.ConfigProvider,
83 - ConfigProvider.fromEnv({
84 - env: { PATH: "", T3CODE_CLOUDFLARED_PATH: overridePath },
85 - }),
85 + expect(
86 + yield* manager.resolve.pipe(
87 + Effect.provideService(
88 + ConfigProvider.ConfigProvider,
89 + ConfigProvider.fromEnv({
90 + env: { PATH: "", T3CODE_CLOUDFLARED_PATH: overridePath },
91 + }),
92 + ),
93 + ),
94 + ).toEqual({
95 + status: "available",
96 + executablePath: overridePath,
97 + source: "override",
98 + version: CLOUDFLARED_VERSION,
99 + });
100 + }).pipe(
101 + Effect.scoped,
102 + Effect.provide(
103 + Layer.mergeAll(
104 + NodeServices.layer,
105 + makeHttpClientLayer(new Uint8Array()),
106 + makeSpawnerLayer([]),
107 + hostRuntimeLayer(),
108 ),
87 - ),
88 - ).toEqual({
89 - status: "available",
90 - executablePath: overridePath,
91 - source: "override",
92 - version: CLOUDFLARED_VERSION,
93 - });
94 - }).pipe(
95 - Effect.scoped,
96 - Effect.provide(
97 - Layer.mergeAll(
98 - NodeServices.layer,
99 - makeHttpClientLayer(new Uint8Array()),
100 - makeSpawnerLayer([]),
101 - hostRuntimeLayer(),
109 ),
110 ),
104 - ),
111 );
112
107 - it.effect("downloads, verifies, validates, and atomically installs the managed executable", () =>
108 - Effect.gen(function* () {
109 - const fileSystem = yield* FileSystem.FileSystem;
110 - const baseDir = yield* fileSystem.makeTempDirectoryScoped({
111 - prefix: "t3-cloudflared-test-",
112 - });
113 - const bytes = new TextEncoder().encode("test-cloudflared-binary");
114 - const manager = yield* makeCloudflaredRelayClient({
115 - baseDir,
116 - releaseAsset: {
117 - url: "https://example.test/cloudflared",
118 - sha256: Encoding.encodeHex(sha256(bytes)),
119 - archive: "binary",
120 - },
121 - });
113 + it.effect.skipIf(windowsHost)(
114 + "downloads, verifies, validates, and atomically installs the managed executable",
115 + () =>
116 + Effect.gen(function* () {
117 + const fileSystem = yield* FileSystem.FileSystem;
118 + const baseDir = yield* fileSystem.makeTempDirectoryScoped({
119 + prefix: "t3-cloudflared-test-",
120 + });
121 + const bytes = new TextEncoder().encode("test-cloudflared-binary");
122 + const manager = yield* makeCloudflaredRelayClient({
123 + baseDir,
124 + releaseAsset: {
125 + url: "https://example.test/cloudflared",
126 + sha256: Encoding.encodeHex(sha256(bytes)),
127 + archive: "binary",
128 + },
129 + });
130
123 - const progress: Array<string> = [];
124 - const installed = yield* manager.installWithProgress((event) =>
125 - Effect.sync(() => {
126 - if (event.type === "progress") {
127 - progress.push(event.stage);
128 - }
129 - }),
130 - );
131 - const managedPath = `${baseDir}/tools/cloudflared/${CLOUDFLARED_VERSION}/linux-x64/cloudflared`;
132 - expect(installed).toEqual({
133 - status: "available",
134 - executablePath: managedPath,
135 - source: "managed",
136 - version: CLOUDFLARED_VERSION,
137 - });
138 - expect(new TextDecoder().decode(yield* fileSystem.readFile(managedPath))).toBe(
139 - "test-cloudflared-binary",
140 - );
141 - expect(progress).toEqual([
142 - "checking",
143 - "waiting_for_lock",
144 - "downloading",
145 - "verifying",
146 - "installing",
147 - "validating",
148 - "activating",
149 - ]);
150 - expect(yield* manager.resolve).toEqual(installed);
151 - }).pipe(
152 - Effect.scoped,
153 - Effect.provide(
154 - Layer.mergeAll(
155 - NodeServices.layer,
156 - makeHttpClientLayer(new TextEncoder().encode("test-cloudflared-binary")),
157 - makeSpawnerLayer([]),
158 - hostRuntimeLayer(),
131 + const progress: Array<string> = [];
132 + const installed = yield* manager.installWithProgress((event) =>
133 + Effect.sync(() => {
134 + if (event.type === "progress") {
135 + progress.push(event.stage);
136 + }
137 + }),
138 + );
139 + const managedPath = `${baseDir}/tools/cloudflared/${CLOUDFLARED_VERSION}/linux-x64/cloudflared`;
140 + expect(installed).toEqual({
141 + status: "available",
142 + executablePath: managedPath,
143 + source: "managed",
144 + version: CLOUDFLARED_VERSION,
145 + });
146 + expect(new TextDecoder().decode(yield* fileSystem.readFile(managedPath))).toBe(
147 + "test-cloudflared-binary",
148 + );
149 + expect(progress).toEqual([
150 + "checking",
151 + "waiting_for_lock",
152 + "downloading",
153 + "verifying",
154 + "installing",
155 + "validating",
156 + "activating",
157 + ]);
158 + expect(yield* manager.resolve).toEqual(installed);
159 + }).pipe(
160 + Effect.scoped,
161 + Effect.provide(
162 + Layer.mergeAll(
163 + NodeServices.layer,
164 + makeHttpClientLayer(new TextEncoder().encode("test-cloudflared-binary")),
165 + makeSpawnerLayer([]),
166 + hostRuntimeLayer(),
167 + ),
168 ),
169 ),
161 - ),
170 );
171
172 it.effect("rejects downloads whose checksum does not match the pinned manifest", () =>
@@ -192,7 +200,7 @@ describe("RelayClient", () => {
200 ),
201 );
202
195 - it.effect("serializes concurrent installs within one runtime", () => {
203 + it.effect.skipIf(windowsHost)("serializes concurrent installs within one runtime", () => {
204 const commands: Array<string> = [];
205 const bytes = new TextEncoder().encode("test-cloudflared-binary");
206 return Effect.gen(function* () {
@@ -227,45 +235,48 @@ describe("RelayClient", () => {
235 );
236 });
237
230 - it.effect("observes PATH changes after the manager has been constructed", () => {
231 - const env = { PATH: "" };
232 - return Effect.gen(function* () {
233 - const fileSystem = yield* FileSystem.FileSystem;
234 - const baseDir = yield* fileSystem.makeTempDirectoryScoped({
235 - prefix: "t3-cloudflared-test-",
236 - });
237 - const binDir = `${baseDir}/bin`;
238 - const executablePath = `${binDir}/cloudflared`;
239 - const manager = yield* makeCloudflaredRelayClient({
240 - baseDir,
241 - });
238 + it.effect.skipIf(windowsHost)(
239 + "observes PATH changes after the manager has been constructed",
240 + () => {
241 + const env = { PATH: "" };
242 + return Effect.gen(function* () {
243 + const fileSystem = yield* FileSystem.FileSystem;
244 + const baseDir = yield* fileSystem.makeTempDirectoryScoped({
245 + prefix: "t3-cloudflared-test-",
246 + });
247 + const binDir = `${baseDir}/bin`;
248 + const executablePath = `${binDir}/cloudflared`;
249 + const manager = yield* makeCloudflaredRelayClient({
250 + baseDir,
251 + });
252
243 - expect(yield* manager.resolve).toEqual({
244 - status: "missing",
245 - version: CLOUDFLARED_VERSION,
246 - });
253 + expect(yield* manager.resolve).toEqual({
254 + status: "missing",
255 + version: CLOUDFLARED_VERSION,
256 + });
257
248 - yield* fileSystem.makeDirectory(binDir);
249 - yield* fileSystem.writeFileString(executablePath, "cloudflared");
250 - yield* fileSystem.chmod(executablePath, 0o755);
251 - env.PATH = binDir;
258 + yield* fileSystem.makeDirectory(binDir);
259 + yield* fileSystem.writeFileString(executablePath, "cloudflared");
260 + yield* fileSystem.chmod(executablePath, 0o755);
261 + env.PATH = binDir;
262
253 - expect(yield* manager.resolve).toEqual({
254 - status: "available",
255 - executablePath,
256 - source: "path",
257 - version: CLOUDFLARED_VERSION,
258 - });
259 - }).pipe(
260 - Effect.scoped,
261 - Effect.provide(
262 - Layer.mergeAll(
263 - NodeServices.layer,
264 - makeHttpClientLayer(new Uint8Array()),
265 - makeSpawnerLayer([]),
266 - hostRuntimeLayer(env),
263 + expect(yield* manager.resolve).toEqual({
264 + status: "available",
265 + executablePath,
266 + source: "path",
267 + version: CLOUDFLARED_VERSION,
268 + });
269 + }).pipe(
270 + Effect.scoped,
271 + Effect.provide(
272 + Layer.mergeAll(
273 + NodeServices.layer,
274 + makeHttpClientLayer(new Uint8Array()),
275 + makeSpawnerLayer([]),
276 + hostRuntimeLayer(env),
277 + ),
278 ),
268 - ),
269 - );
270 - });
279 + );
280 + },
281 + );
282 });