Skip to content

Commit e51f557

Browse files
mcp-tool-shopclaude
andcommitted
fix(test): skip backslash-normalization test on non-Windows
CI on ubuntu-latest failed because the F-SCRIPTS-010 normalization test constructed a backslash path and passed it to hash-file.mjs, expecting the OS to resolve it to the same file. On Linux/macOS, backslashes are literal filename characters — the file doesn't exist at the backslash path, so hash-file errors with ENOENT before any normalization happens. The behavior being tested (POSIX-normalize the emitted `path` field when the input contains backslashes) is genuinely a Windows-only concern; on POSIX the input would never contain backslashes in the first place. Skipping on non-Windows preserves the test's intent without fighting OS path semantics. Pre-fix CI: ubuntu × node 20+22 — 88/89, 1 fail (this test) Post-fix expected: ubuntu × node 20+22 — 88/89, 1 skipped (passes) windows × node 20+22 — 89/89, 0 skipped Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 811a958 commit e51f557

1 file changed

Lines changed: 37 additions & 27 deletions

File tree

test/hash-file.test.mjs

Lines changed: 37 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -76,34 +76,44 @@ describe("hash-file.mjs — known-vector + path-normalization + empty-file", ()
7676
assert.equal(out.bytes, 0, `expected 0 bytes; got ${out.bytes}`);
7777
});
7878

79-
it("normalizes Windows backslashes to POSIX forward slashes in the emitted path", () => {
80-
// Create a nested file so the relative path actually contains a separator.
81-
const dir = makeTempDir("posix-norm");
82-
const subdir = join(dir, "sub");
83-
mkdirSync(subdir, { recursive: true });
84-
const filePath = join(subdir, "f.txt");
85-
writeFileSync(filePath, "x", "utf-8");
79+
it(
80+
"normalizes Windows backslashes to POSIX forward slashes in the emitted path",
81+
{
82+
skip:
83+
process.platform !== "win32"
84+
? "Windows-only — backslash path resolution is OS-level"
85+
: false,
86+
},
87+
() => {
88+
// Create a nested file so the relative path actually contains a separator.
89+
const dir = makeTempDir("posix-norm");
90+
const subdir = join(dir, "sub");
91+
mkdirSync(subdir, { recursive: true });
92+
const filePath = join(subdir, "f.txt");
93+
writeFileSync(filePath, "x", "utf-8");
8694

87-
// Build a path with explicit backslashes regardless of platform — this is
88-
// the surface the F-SCRIPTS-010 fix protects. The normalization must run
89-
// even on POSIX so the test is meaningful cross-platform.
90-
const backslashPath = filePath.replace(/[/\\]/g, "\\");
91-
const result = runHash(backslashPath);
92-
assert.equal(
93-
result.status,
94-
0,
95-
`hash-file should exit 0; got ${result.status}.\nstderr: ${result.stderr}`,
96-
);
97-
const out = JSON.parse(result.stdout);
98-
assert.ok(
99-
!out.path.includes("\\"),
100-
`emitted path must not contain backslashes (POSIX-normalized); got ${JSON.stringify(out.path)}`,
101-
);
102-
assert.ok(
103-
out.path.includes("/"),
104-
`emitted path should use forward slashes for nested files; got ${JSON.stringify(out.path)}`,
105-
);
106-
});
95+
// On Windows, both backslash and forward-slash paths resolve to the same
96+
// file. We pass the backslash form to assert that the F-SCRIPTS-010 fix
97+
// POSIX-normalizes the emitted `path` field. POSIX hosts cannot run this
98+
// test because Linux/macOS treat backslashes as literal filename chars.
99+
const backslashPath = filePath.replace(/[/\\]/g, "\\");
100+
const result = runHash(backslashPath);
101+
assert.equal(
102+
result.status,
103+
0,
104+
`hash-file should exit 0; got ${result.status}.\nstderr: ${result.stderr}`,
105+
);
106+
const out = JSON.parse(result.stdout);
107+
assert.ok(
108+
!out.path.includes("\\"),
109+
`emitted path must not contain backslashes (POSIX-normalized); got ${JSON.stringify(out.path)}`,
110+
);
111+
assert.ok(
112+
out.path.includes("/"),
113+
`emitted path should use forward slashes for nested files; got ${JSON.stringify(out.path)}`,
114+
);
115+
},
116+
);
107117

108118
it("exits non-zero with a usage message when called with no argument", () => {
109119
const result = runHash();

0 commit comments

Comments
 (0)