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 3's tests hold on Windows

Shrish Dwivedi45aa91e73f93
diff --git a/test/notes-every-repo.test.ts b/test/notes-every-repo.test.ts
index 1f96d47e..4e32dcaa 100644
--- a/test/notes-every-repo.test.ts
+++ b/test/notes-every-repo.test.ts
@@ -35,8 +35,8 @@ test("writeEveryRepo: the guardrail at its fixed name, id from the name, every r
assert.match(text, /^check: no-timeout$/m);
assert.match(text, /^enforce: sure-fail$/m);
assert.match(text, /^status: active$/m);
- assert.equal(statSync(path).mode & 0o777, 0o600);
- assert.equal(statSync(everyRepoDir(h.env)).mode & 0o777, 0o700);
+ if (process.platform !== "win32") assert.equal(statSync(path).mode & 0o777, 0o600);
+ if (process.platform !== "win32") assert.equal(statSync(everyRepoDir(h.env)).mode & 0o777, 0o700);
assert.ok(!existsSync(join(h.dir, "home")), "nothing under HOME");
});
diff --git a/test/skills-lessons.test.ts b/test/skills-lessons.test.ts
index 5a603490..effc83bf 100644
--- a/test/skills-lessons.test.ts
+++ b/test/skills-lessons.test.ts
@@ -117,8 +117,8 @@ test("writeLesson / readLessons: a skill lesson round trips as skills/<name>/les
"---", 'id: "ls-3c9e1a"', 'kind: "lesson"', 'skill: "release-npm"', 'src: "correction"', 'at: "2026-11-03"', "---",
"push the tag too: git push origin v{version}", "",
].join("\n"));
- assert.equal(statSync(p1).mode & 0o777, 0o600);
- assert.equal(statSync(join(dir, "lessons")).mode & 0o777, 0o700);
+ if (process.platform !== "win32") assert.equal(statSync(p1).mode & 0o777, 0o600);
+ if (process.platform !== "win32") assert.equal(statSync(join(dir, "lessons")).mode & 0o777, 0o700);
const p2 = writeLesson(lesson({ id: "zz", text: "never publish locally", kind: "guardrail" }), SHOP, h.env);
assert.equal(p2, join(dir, "lessons", "2026-11-03-2.md"));
const back = readLessons(dir);
@@ -176,7 +176,7 @@ test("writeLesson: a machine wall's lesson is an every-repo learning of kind les
const git = writeLesson(lesson({ skill: null, text: "push over ssh: git push [email protected]:acme/shop.git", src: "repair", wall: "git-https-auth" }), SHOP, h.env);
assert.equal(join(git, ".."), join(h.trail, "repos", "github.com", "acme", "shop", "notes"));
assert.match(readFileSync(git, "utf8"), /^applies: github.com\/acme\/shop$/m);
- assert.equal(statSync(git).mode & 0o777, 0o600);
+ if (process.platform !== "win32") assert.equal(statSync(git).mode & 0o777, 0o600);
assert.throws(() => writeLesson(lesson({ skill: null, wall: "git-https-auth" }), "../../etc", h.env), /repo key/);
assert.throws(() => writeLesson(lesson({ skill: null, wall: null }), SHOP, h.env), /skill or a wall/);
});
diff --git a/test/skills-probes.test.ts b/test/skills-probes.test.ts
index 03fe2157..48cc7857 100644
--- a/test/skills-probes.test.ts
+++ b/test/skills-probes.test.ts
@@ -57,7 +57,8 @@ test("git status never writes the index (optional locks off)", () => {
assert.equal(existsSync(index) ? statSync(index).mtimeMs : 0, before);
});
-test("command -v looks the program up on PATH; test and [ ] stat the path, $HOME and ~ expanded", async () => {
+test("command -v looks the program up on PATH; test and [ ] stat the path, $HOME and ~ expanded", { skip: process.platform === "win32" }, async () => {
+ // A unix socket, a /tmp folder and a PATH joined with ":" are POSIX only.
const b = box("stat");
// A socket path must stay under 104 bytes on macOS: this test's HOME is a short folder of its own.
const home = mkdtempSync("/tmp/gp-");
@@ -157,7 +158,7 @@ test("cached 10 minutes by checkout and probe, in state/probes.json (0600), no p
assert.equal(runProbes(s, b.repo, new Date(NOW.getTime() + 11 * 60_000), b.env, { git: counting })[0]?.ok, true, "expired, run again");
assert.equal(runs, 2);
const file = join(b.env.TRAIL_HOME!, "state", "probes.json");
- assert.equal(statSync(file).mode & 0o777, 0o600);
+ if (process.platform !== "win32") assert.equal(statSync(file).mode & 0o777, 0o600);
const text = readFileSync(file, "utf8");
assert.ok(!text.includes(b.repo), "the checkout path is hashed");
assert.ok(JSON.parse(text).entries, "the shape housekeeping prunes");
diff --git a/test/skills-store-attacks.test.ts b/test/skills-store-attacks.test.ts
index 254835a2..80cc597b 100644
--- a/test/skills-store-attacks.test.ts
+++ b/test/skills-store-attacks.test.ts
@@ -12,7 +12,7 @@ import assert from "node:assert/strict";
import { spawn } from "node:child_process";
import { existsSync, lstatSync, mkdirSync, readFileSync, readdirSync, renameSync, statSync, symlinkSync, writeFileSync } from "node:fs";
import { dirname, join, resolve } from "node:path";
-import { fileURLToPath } from "node:url";
+import { fileURLToPath, pathToFileURL } from "node:url";
import {
findSkill, forgetSkill, keepHeld, listAllPersonal, listHeld, listSkills, markHeldShown, nameTaken, readSkill, restoreSkill, saveHeld, savePersonal,
type PersonCheck, type ScopeCtx,
@@ -211,8 +211,8 @@ const REPO = resolve(dirname(fileURLToPath(import.meta.url)), "..");
/** One process recording `n` uses of a skill, as concurrent Stop hooks would. */
function writer(env: NodeJS.ProcessEnv, id: string, n: number): Promise<number> {
const script = `
- const { recordUse } = await import(${JSON.stringify(join(REPO, "src/skills/state.ts"))});
- const { appendLedger } = await import(${JSON.stringify(join(REPO, "src/skills/ledger.ts"))});
+ const { recordUse } = await import(${JSON.stringify(pathToFileURL(join(REPO, "src/skills/state.ts")).href)});
+ const { appendLedger } = await import(${JSON.stringify(pathToFileURL(join(REPO, "src/skills/ledger.ts")).href)});
let ok = 0;
for (let k = 0; k < ${n}; k++) {
const u = { at: new Date().toISOString(), event: "use", useId: "u-" + process.pid.toString(16).slice(-3) + k.toString(16).padStart(3, "0"), skill: ${JSON.stringify(id)}, v: "1", host: "claude", cue: "job", repo: "github.com/acme/shop", stepsRan: [1], failedStep: k % 2 ? 2 : null, readyFailed: [], check: "none", calls: 2, failed: k % 2 };
@@ -248,7 +248,7 @@ test("real processes writing skills.json and the ledger at once: no use counted
/** One process marking one use corrected at the given instant, as a prompt hook in another session would. */
function corrector(env: NodeJS.ProcessEnv, id: string, useId: string, atMs: number): Promise<void> {
const script = `
- const { recordCorrected } = await import(${JSON.stringify(join(REPO, "src/skills/state.ts"))});
+ const { recordCorrected } = await import(${JSON.stringify(pathToFileURL(join(REPO, "src/skills/state.ts")).href)});
while (Date.now() < ${atMs}) { /* both start at the same instant */ }
recordCorrected(${JSON.stringify(id)}, ${JSON.stringify(useId)}, ${JSON.stringify(env)});`;
return new Promise((done, fail) => {
diff --git a/test/trace-guard-fast-review.test.ts b/test/trace-guard-fast-review.test.ts
index e20b9c9f..e34e34e6 100644
--- a/test/trace-guard-fast-review.test.ts
+++ b/test/trace-guard-fast-review.test.ts
@@ -10,7 +10,7 @@ import assert from "node:assert/strict";
import { spawnSync } from "node:child_process";
import { mkdirSync, rmSync, statSync, writeFileSync } from "node:fs";
import { dirname, join } from "node:path";
-import { fileURLToPath } from "node:url";
+import { fileURLToPath, pathToFileURL } from "node:url";
import { tmpRepo } from "./helpers.js";
import { FIXED_DIRS, SURE_FAIL_REASON, markDenied, sureFail } from "../src/trace/guard-fast.js";
import { sessionPath } from "../src/trace/gate-file.js";
@@ -73,13 +73,14 @@ test("a planted guardrail file can only ever give the fixed reason: its title an
assert.equal(sureFail("rm -rf build", b.env), null);
});
-test("a FIFO planted as the guardrail file allows at once (capped child), not after the hook's 5 s", () => {
+test("a FIFO planted as the guardrail file allows at once (capped child), not after the hook's 5 s", { skip: process.platform === "win32" }, () => {
+ // Windows has no FIFO.
const b = box();
const path = join(everyRepoDir(b.env), "no-timeout.md");
rmSync(path);
spawnSync("mkfifo", [path]);
const probe = `
- const { sureFail } = await import(${JSON.stringify(join(SRC, "trace", "guard-fast.ts"))});
+ const { sureFail } = await import(${JSON.stringify(pathToFileURL(join(SRC, "trace", "guard-fast.ts")).href)});
const t = performance.now();
const r = sureFail('timeout 5 make', ${JSON.stringify(b.env)});
process.stdout.write(JSON.stringify({ r, ms: performance.now() - t }));`;
@@ -107,14 +108,15 @@ test("the folders a hook's PATH can miss include nix-darwin's per-user profile (
for (const d of ["/usr/bin", "/bin"]) assert.ok(!FIXED_DIRS.includes(d), d);
});
-test("markDenied: a FIFO planted at the session's denied file is not opened for writing (capped child)", () => {
+test("markDenied: a FIFO planted at the session's denied file is not opened for writing (capped child)", { skip: process.platform === "win32" }, () => {
+ // Windows has no FIFO.
const b = box();
const sid = "5f0c2a1e-1b2c-4d5e-8f90-123456789abc";
const path = sessionPath(sid, ".denied.jsonl", b.env);
mkdirSync(dirname(path), { recursive: true });
spawnSync("mkfifo", [path]);
const probe = `
- const { markDenied } = await import(${JSON.stringify(join(SRC, "trace", "guard-fast.ts"))});
+ const { markDenied } = await import(${JSON.stringify(pathToFileURL(join(SRC, "trace", "guard-fast.ts")).href)});
const t = performance.now();
markDenied(${JSON.stringify(sid)}, 'timeout 5 make', ${JSON.stringify(b.env)});
process.stdout.write(JSON.stringify({ ms: performance.now() - t }));`;
diff --git a/test/trace-guard-fast.test.ts b/test/trace-guard-fast.test.ts
index dab5fbcf..98efa090 100644
--- a/test/trace-guard-fast.test.ts
+++ b/test/trace-guard-fast.test.ts
@@ -140,7 +140,8 @@ test("timeoutOnPath: a system fixed folder counts too (checked through a stand-i
try { return (statSync(join(d, "timeout")).mode & 0o111) !== 0 && statSync(join(d, "timeout")).isFile(); } catch { return false; }
});
assert.equal(onSystem, direct);
- assert.equal(timeoutOnPath(empty), direct, "a non-executable file on PATH is not a timeout");
+ // Windows has no exec bit: there any timeout file on PATH counts (Git Bash runs a script with no extension).
+ if (process.platform !== "win32") assert.equal(timeoutOnPath(empty), direct, "a non-executable file on PATH is not a timeout");
});
test("markDenied: one JSON line per deny, the sha of the rest of the command, 0600, capped at 4 KB", () => {
@@ -156,7 +157,7 @@ test("markDenied: one JSON line per deny, the sha of the rest of the command, 06
const two = readFileSync(path, "utf8").trim().split("\n").map((l) => JSON.parse(l));
assert.equal(two[1].restSha, first[0].restSha, "the rest of the command, normalized");
assert.ok(!readFileSync(path, "utf8").includes("npm test"), "never the command");
- assert.equal(statSync(path).mode & 0o777, 0o600);
+ if (process.platform !== "win32") assert.equal(statSync(path).mode & 0o777, 0o600);
for (let i = 0; i < 200; i++) markDenied(sid, `timeout 5 make t${i}`, b.env);
assert.ok(statSync(path).size <= 4096, `capped: ${statSync(path).size}`);
assert.deepEqual(readdirSync(b.dir).sort(), ["bin", "home", "trail"], "nothing outside TRAIL_HOME");