Skip to content

Turbocharge Claude Code, Cursor, Codex, Gemini & every coding agent: faster, cheaper, with contextual understanding specific to your codebase.

test(skills): make part 6's tests hold on Windows

Shrish Dwivedifd0564778321
diff --git a/test/claude-hooks-1b-review-trust.test.ts b/test/claude-hooks-1b-review-trust.test.ts
index dd6ba4e9..e9a84543 100644
--- a/test/claude-hooks-1b-review-trust.test.ts
+++ b/test/claude-hooks-1b-review-trust.test.ts
@@ -7,9 +7,9 @@
import { test } from 'node:test';
import assert from 'node:assert/strict';
import { chmodSync, mkdirSync, readdirSync, readFileSync, writeFileSync } from 'node:fs';
-import { join } from 'node:path';
+import { delimiter, join } from 'node:path';
import {
- agentRuns, at, box, calling, done, finish, grow, offersLog, one, postBashFailHook, preBashHook, promptHook, reply, resultOf, session, startHook, stateOf, stopHook,
+ agentRuns, at, box, calling, done, finish, grow, offersLog, one, postBashFailHook, preBashHook, promptHook, reply, resultOf, session, startHook, stateOf, stopHook, type Box,
} from './claude-skills-journey-fixtures.js';
import {
DOCKER_ERR, FIXED, GO_TEST, correctedRelease, ctxOf, dockerDay, globalCopy, oneOrNothing, readInitRecordOf, readdirSyncSafe, releaseKept, saidQuote, startContext, wallLessonKept, wholeTurn,
@@ -82,19 +82,22 @@ test('both copies registered: the wall fix on a failed command and the init hand
test('fail open: a corrupt walls.json, lessons file, init record or session file, a FIFO in their place, and an unwritable Trail home leave every hook one JSON object or nothing', async () => {
const { spawnSync } = await import('node:child_process');
+ // Windows has no FIFO and ignores chmod on a folder: there only the corrupt files are tried.
+ const posix = process.platform !== 'win32';
const fifo = (p: string) => { mkdirSync(join(p, '..'), { recursive: true }); assert.equal(spawnSync('mkfifo', [p]).status, 0); };
const cases: Record<string, (b: Box) => void> = {
'walls.json not JSON': (b) => writeFileSync(join(b.trail, 'walls.json'), '{"v":1,"read":'),
'walls.json odd shapes': (b) => writeFileSync(join(b.trail, 'walls.json'), JSON.stringify({ v: 1, read: { x: 5 }, classes: { 'docker-rootless': { seen: 'x', fixed: [null], lessons: { 'l-0a1b2c3d': { worked: 'no' } } } } })),
- 'walls.json a FIFO': (b) => fifo(join(b.trail, 'walls.json')),
+ ...(posix ? { 'walls.json a FIFO': (b: Box) => fifo(join(b.trail, 'walls.json')) } : {}),
'a broken lesson file and a FIFO among the learnings': (b) => {
mkdirSync(join(b.trail, 'learnings'), { recursive: true });
writeFileSync(join(b.trail, 'learnings', 'lesson-docker-rootless-2026-10-01.md'), '---\nkind: [lesson\nwall: docker-rootless\n---\n');
+ if (!posix) return;
fifo(join(b.trail, 'learnings', 'lesson-docker-rootless-2026-10-02.md'));
fifo(join(b.trail, 'learnings', 'no-timeout.md'));
},
'the init record not JSON': (b) => { mkdirSync(join(b.trail, 'init', 'github.com', 'acme'), { recursive: true }); writeFileSync(join(b.trail, 'init', 'github.com', 'acme', 'shop.json'), '{"v":2,"pending":[{'); },
- 'the init record a FIFO': (b) => fifo(join(b.trail, 'init', 'github.com', 'acme', 'shop.json')),
+ ...(posix ? { 'the init record a FIFO': (b: Box) => fifo(join(b.trail, 'init', 'github.com', 'acme', 'shop.json')) } : {}),
'session files not JSON': (b) => {
mkdirSync(join(b.trail, 'sessions'), { recursive: true });
for (const n of ['.json', '.hooks.json', '.denied.jsonl', '.gate.json']) writeFileSync(join(b.trail, 'sessions', `3c9d2e1f-0a1b-4c2d-8e3f-${String(boxesSoFar + 1).padStart(12, '0')}${n}`), '{"skills":');
@@ -111,6 +114,7 @@ test('fail open: a corrupt walls.json, lessons file, init record or session file
done(b);
}
}
+ if (!posix) return;
const b = box('r1b-open-ro');
try {
mkdirSync(join(b.trail, 'sessions'), { recursive: true });
@@ -192,7 +196,7 @@ test('lesson consent through the hooks: after the offer, a typed line that is no
mkdirSync(bin, { recursive: true });
writeFileSync(join(bin, 'colima'), '#!/bin/sh\nexit 0\n');
chmodSync(join(bin, 'colima'), 0o755);
- b.env.PATH = `${bin}:${process.env.PATH ?? ''}`;
+ b.env.PATH = `${bin}${delimiter}${process.env.PATH ?? ''}`;
await dockerDay(session(b), 10);
const s = session(b);
assert.equal((await dockerDay(s, 14))?.decision, 'block');
diff --git a/test/claude-host-standdown.test.ts b/test/claude-host-standdown.test.ts
index 94c4ee55..a1e5c189 100644
--- a/test/claude-host-standdown.test.ts
+++ b/test/claude-host-standdown.test.ts
@@ -57,12 +57,13 @@ test('the repo copy stands down only for a host that also runs the ~/.claude cop
/** Runs `fn` as the repo's copy of the hooks, with `home` as the home folder; returns stdout. */
async function asRepoCopy(repo: string, home: string, stdin: object, fn: () => Promise<void>): Promise<string> {
- const saved = { argv1: process.argv[1], home: process.env.HOME, stdin: process.env.GRAFT_TEST_STDIN, project: process.env.CLAUDE_PROJECT_DIR, config: process.env.CLAUDE_CONFIG_DIR };
+ const saved = { argv1: process.argv[1], home: process.env.HOME, profile: process.env.USERPROFILE, stdin: process.env.GRAFT_TEST_STDIN, project: process.env.CLAUDE_PROJECT_DIR, config: process.env.CLAUDE_CONFIG_DIR };
let out = '';
const write = process.stdout.write.bind(process.stdout);
process.stdout.write = ((chunk: unknown, ...rest: unknown[]) => (typeof chunk === 'string' ? ((out += chunk), true) : (write as (...a: unknown[]) => boolean)(chunk, ...rest))) as typeof process.stdout.write;
process.argv[1] = repoShim(repo);
process.env.HOME = home;
+ process.env.USERPROFILE = home; // os.homedir() follows USERPROFILE on Windows
delete process.env.CLAUDE_CONFIG_DIR;
process.env.GRAFT_TEST_STDIN = JSON.stringify(stdin);
process.env.CLAUDE_PROJECT_DIR = repo;
@@ -71,7 +72,7 @@ async function asRepoCopy(repo: string, home: string, stdin: object, fn: () => P
} finally {
process.stdout.write = write;
process.argv[1] = saved.argv1!;
- for (const [key, value] of [['HOME', saved.home], ['GRAFT_TEST_STDIN', saved.stdin], ['CLAUDE_PROJECT_DIR', saved.project], ['CLAUDE_CONFIG_DIR', saved.config]] as const) {
+ for (const [key, value] of [['HOME', saved.home], ['USERPROFILE', saved.profile], ['GRAFT_TEST_STDIN', saved.stdin], ['CLAUDE_PROJECT_DIR', saved.project], ['CLAUDE_CONFIG_DIR', saved.config]] as const) {
if (value === undefined) delete process.env[key];
else process.env[key] = value;
}
diff --git a/test/init-run.test.ts b/test/init-run.test.ts
index fedb7cb5..10d683a9 100644
--- a/test/init-run.test.ts
+++ b/test/init-run.test.ts
@@ -10,7 +10,7 @@ import { test } from "node:test";
import assert from "node:assert/strict";
import { chmodSync, existsSync, mkdtempSync, readdirSync, readFileSync, rmSync, writeFileSync } from "node:fs";
import { tmpdir } from "node:os";
-import { join } from "node:path";
+import { delimiter, join } from "node:path";
import { PassThrough, Writable } from "node:stream";
import { agentRun, beginLookBack, finishLookBack, mayCallClaude } from "../src/init/run.js";
import { readInitRecord } from "../src/init/init-record.js";
@@ -93,7 +93,7 @@ async function inWorld<T>(tag: string, fn: (w: World, env: NodeJS.ProcessEnv, cl
const claude = standIn();
const saved = { trail: process.env.TRAIL_HOME, path: process.env.PATH, dnt: process.env.DO_NOT_TRACK };
process.env.TRAIL_HOME = w.trail;
- process.env.PATH = `${claude.bin}:${saved.path}`;
+ process.env.PATH = `${claude.bin}${delimiter}${saved.path}`;
process.env.DO_NOT_TRACK = "1";
try {
// No `timeout` on this env's PATH (the guardrail is still true), only the stand-in; no fetches (no gh).
@@ -188,7 +188,10 @@ function fakeTty(keys: string[]) {
return { io: { stdin, stdout }, out: () => out };
}
-test("the person at their terminal: one naming call, the screen, and enter keeps the ticked items (J01)", async () => {
+/** The naming call's stand-in is a shebang script, which Windows can't run. */
+const posixOnly = { skip: process.platform === "win32" ? "shebang stand-ins" : false };
+
+test("the person at their terminal: one naming call, the screen, and enter keeps the ticked items (J01)", posixOnly, async () => {
await inWorld("person", async (w, env, claude) => {
skillsOn(env);
const said: string[] = [];
diff --git a/test/skills-anchors-wide-journeys.test.ts b/test/skills-anchors-wide-journeys.test.ts
index a701f373..0606da18 100644
--- a/test/skills-anchors-wide-journeys.test.ts
+++ b/test/skills-anchors-wide-journeys.test.ts
@@ -9,7 +9,7 @@
import { after, test } from "node:test";
import assert from "node:assert/strict";
import { chmodSync, existsSync, mkdirSync, rmSync, writeFileSync } from "node:fs";
-import { join } from "node:path";
+import { delimiter, join } from "node:path";
import { execFileSync } from "node:child_process";
import { tmpRepo } from "./helpers.js";
import { cloneShape } from "./anchors-clone-fixture.js";
@@ -120,7 +120,7 @@ test("J14b-style leg at SessionStart: the index says (may be out of date) for a
fixture(b.repo);
// A clone on its default branch at the commit last fetched: the CI file check needs that (c4 review).
for (const a of [["update-ref", "refs/remotes/origin/beta", "HEAD"], ["symbolic-ref", "refs/remotes/origin/HEAD", "refs/remotes/origin/beta"]]) execFileSync("git", a, { cwd: b.repo, stdio: "ignore" });
- const env = { ...b.env, PATH: `${bin(b.home)}:${process.env.PATH}` };
+ const env = { ...b.env, PATH: `${bin(b.home)}${delimiter}${process.env.PATH}` };
save(b, ship(["git status", CMDS[kind]]));
const start = () => sessionStartSkillsRun(startPayload(b, "startup"), CWD, env, { gate: gateFor(b) }).out.context ?? "";
const out = start();
diff --git a/test/skills-anchors-wide-review.test.ts b/test/skills-anchors-wide-review.test.ts
index 9e2bee31..bfb66a6c 100644
--- a/test/skills-anchors-wide-review.test.ts
+++ b/test/skills-anchors-wide-review.test.ts
@@ -61,7 +61,8 @@ const cachePath = (b: Box) => join(b.trail, "state", "anchors-cache.json");
/* ---------------------------------------------------------------- cache */
-test("cache: a FIFO at the cache path doesn't hold SessionStart (D100)", () => {
+test("cache: a FIFO at the cache path doesn't hold SessionStart (D100)", { skip: process.platform === "win32" }, () => {
+ // Windows has no FIFO.
const b = cliBox("fifo");
mkdirSync(join(b.trail, "state"), { recursive: true });
execFileSync("mkfifo", [cachePath(b)]);
diff --git a/test/skills-anchors-wide.test.ts b/test/skills-anchors-wide.test.ts
index 5aa1c74c..52d6ec89 100644
--- a/test/skills-anchors-wide.test.ts
+++ b/test/skills-anchors-wide.test.ts
@@ -168,7 +168,8 @@ test("service: include, extends, a merge key and flow style are not judged; a 30
assert.deepEqual(gone(b, ["docker compose up worker"]), ["service:worker#1"], "under 256 KB it is read");
});
-test("service: a FIFO at the compose path doesn't block (D100)", () => {
+test("service: a FIFO at the compose path doesn't block (D100)", { skip: process.platform === "win32" }, () => {
+ // Windows has no FIFO.
const b = box("svc-fifo");
execFileSync("mkfifo", [join(b.checkout, "compose.yaml")]);
const t0 = Date.now();
@@ -277,7 +278,7 @@ test("subcommand: the cache is used when nothing changed and rescanned when one
assert.match(entry.sig, /^[0-9a-f]{16}$/);
assert.deepEqual(entry.cli, { acme: ["build", "connxct", "d", "deploy", "init", "status"] });
assert.ok(!readFileSync(path, "utf8").includes("registrations"), "no file text");
- assert.equal((statSync(path).mode & 0o777).toString(8), "600");
+ if (process.platform !== "win32") assert.equal((statSync(path).mode & 0o777).toString(8), "600");
// Same size, same mtime, new text: the cache answers (it can't see the change).
writeFileSync(file, CLI_SRC.replace("connxct", "connect"));
utimesSync(file, t, t);