test: stop path and platform tests depending on the host OS (#9564)

Co-authored-by: Claude Code <[email protected]>
This commit is contained in:
Julius MarmingeandClaude Code authored and GitHub committed 2026-09-04 20:33:19 +00:00
1 parent bfef973d9e
commit cc60753aa2
10 files changed
+65 -33

No files matched your search

@@ -109,7 +109,7 @@ const ConcurrentReadMissFileSystemLayer = Layer.effect(
return {
...fileSystem,
readFile: (path) =>
String(path).endsWith("/session-signing-key.bin")
/[\\/]session-signing-key\.bin$/.test(String(path))
? Ref.updateAndGet(readCountRef, (count) => count + 1).pipe(
Effect.flatMap((count) => {
if (count > 2) {
@@ -219,7 +219,7 @@ it.layer(NodeServices.layer)("ServerSecretStore.layer", (it) => {
yield* secretStore.set("session-signing-key", Uint8Array.from([1, 2, 3]));
assert.isTrue(
chmodCalls.some((call) => call.mode === 0o700 && call.path.endsWith("/secrets")),
chmodCalls.some((call) => call.mode === 0o700 && /[\\/]secrets$/.test(call.path)),
);
assert.isAtLeast(chmodCalls.filter((call) => call.mode === 0o600).length, 2);
}).pipe(Effect.provide(NodeServices.layer)),
@@ -54,11 +54,12 @@ it.layer(TestLayer)("ProjectFaviconResolverLive", (it) => {
it.effect("serves repeated resolves from cache instead of re-walking candidates", () =>
Effect.gen(function* () {
const resolver = yield* ProjectFaviconResolver.ProjectFaviconResolver;
const path = yield* Path.Path;
const cwd = yield* makeTempDir;
yield* writeTextFile(cwd, "public/favicon.svg", "<svg>public</svg>");
const resolved = yield* resolver.resolvePath(cwd);
expect(resolved?.endsWith("public/favicon.svg")).toBe(true);
expect(resolved?.endsWith(path.join("public", "favicon.svg"))).toBe(true);
// `favicon.svg` outranks `public/favicon.svg`, so a resolver that walked
// the candidate list again would switch to it. Staying on the original
@@ -71,7 +72,7 @@ it.layer(TestLayer)("ProjectFaviconResolverLive", (it) => {
yield* TestClock.adjust(Duration.minutes(11));
expect((yield* resolver.resolvePath(cwd))?.endsWith("/favicon.svg")).toBe(true);
expect(yield* resolver.resolvePath(cwd)).toBe(path.join(cwd, "favicon.svg"));
expect(yield* resolver.resolvePath(cwd)).not.toBe(resolved);
}).pipe(Effect.provide(TestClock.layer())),
);
@@ -1,3 +1,4 @@
import * as NodePath from "@effect/platform-node/NodePath";
import * as NodeServices from "@effect/platform-node/NodeServices";
import { assert, it } from "@effect/vitest";
import * as Effect from "effect/Effect";
@@ -492,7 +493,11 @@ it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => {
it.effect("lets the administrator's managed policy outrank every other settings file", () =>
Effect.gen(function* () {
const path = yield* Path.Path;
// The function is pure on its `path` argument, so hand it the
// implementation matching each platform under test rather than the
// host's.
const path = yield* Path.Path.pipe(Effect.provide(NodePath.layerPosix));
const win32Path = yield* Path.Path.pipe(Effect.provide(NodePath.layerWin32));
for (const [platform, expected] of [
["darwin", "/Library/Application Support/ClaudeCode/managed-settings.json"],
@@ -508,14 +513,15 @@ it.layer(NodeServices.layer)("discoverClaudeSkills", (it) => {
}
assert.deepEqual(
skillOverrideSettingsPaths(path, "/home/.claude", undefined, "win32", {
PROGRAMDATA: "C:/ProgramData",
skillOverrideSettingsPaths(win32Path, "C:\\Users\\me\\.claude", undefined, "win32", {
PROGRAMDATA: "C:\\ProgramData",
}).at(-1),
"C:/ProgramData/ClaudeCode/managed-settings.json",
"C:\\ProgramData\\ClaudeCode\\managed-settings.json",
);
assert.deepEqual(
skillOverrideSettingsPaths(win32Path, "C:\\Users\\me\\.claude", undefined, "win32", {}),
["C:\\Users\\me\\.claude\\settings.json"],
);
assert.deepEqual(skillOverrideSettingsPaths(path, "/home/.claude", undefined, "win32", {}), [
"/home/.claude/settings.json",
]);
// Only the repository root's local file joins in, after the
// workspace's own local file so it wins.