Skip to content

test(shared): stop two suites asserting POSIX separators on Windows - #16511

Merged
nwparker merged 1 commit into
stablyai:mainfrom
JahyunBaek:fix/windows-posix-path-assumptions
Aug 29, 2026
Merged

nwparker merged 1 commit into
stablyai:mainfrom
JahyunBaek:fix/windows-posix-path-assumptions

Conversation

@JahyunBaek

Copy link
Copy Markdown
Contributor

ELI5

Two test files write file paths the Mac/Linux way, with forward slashes. The code they test builds paths the way each operating system wants them, so on Windows the two never line up. One test then compares mismatched strings and fails loudly; the other quietly explores an empty folder and concludes there is nothing there — which is worse, because that is also what a broken traversal looks like. This makes both tests describe paths the way the code does.

What Changed

  • node-markdown-document-discovery.test.ts keys its fake directory tree with join instead of '/repo/docs' and '/repo/one' literals.
  • git-fetch-head-lock.test.ts asserts path.resolve(...) instead of the literal '/tmp/repo'.

Test-only. No production file changes.

Why

Both subjects compose paths through node:path; both suites described them with POSIX literals.

Discovery walked nothing. discoverMarkdownRelativePaths descends with

await visitDirectory(join(absoluteDirectoryPath, entry.name), relativePath, nextDepth)

so on win32 it asks for \repo\docs while the fake tree only answers to /repo/docs. readDirectory yields nothing, recursion ends at the root, and two cases fail for one reason:

AssertionError: expected [ 'README.md' ] to deeply equal [ 'README.md', 'docs/guide.mdx' ]
AssertionError: promise resolved "[]" instead of rejecting

The second is the one worth pausing on. A depth limit that is never reached resolves [], which is indistinguishable from a correct walk over an empty tree — on this platform the suite could not tell a broken traversal from a working one.

The lock test compared a resolved path to a literal. resolveGitFetchHeadCommand returns path.resolve(cwd, args[index + 1]):

-   "cwd": "/tmp/repo",
+   "cwd": "C:\tmp\repo",

Asserting through path.resolve pins what the function promises — that -C and --git-dir resolve against the cwd — rather than the separator of whichever machine runs the suite.

Neither is visible to CI: join and resolve emit / on Linux and macOS.

Linked Issue

Fixes #16509

Visual Proof

N/A — test-only change, no user-facing surface.

Testing

Windows 11 Pro (26200), Node 24.15.0, on main at cac538854:

before after
the two files together 3 failed / 12 passed 14 passed, 1 skipped
src/shared (551 files) 9 failed no regression; the 3 fixed cases are gone from the failure list

pnpm typecheck exits 0 and oxlint on both files exits 0.

The remaining src/shared failures on Windows are setup-agent-sequencing losing a prompt with special characters through a real cmd.exe spawn — a different mechanism, noted at the bottom of #16509 and deliberately not touched here.

Full pnpm lint and pnpm test still cannot complete on a stock Windows checkout for reasons that predate this change: #14479, #15200, and node-pty now requiring a from-source rebuild since build(windows): refuse unpatched node-pty prebuilds.

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

No new test. The change is the test correction — three cases go from red to green on Windows and keep passing elsewhere, which is the regression signal.

AI Disclosure

Claude Opus 5 via Claude Code was used to find the failures, isolate the cause, and write the fix.

Review

  • Security: none. Two test files; no production path, no new input.
  • Cross-platform: the point of the change. join/resolve return the same values on macOS and Linux as the literals did, so those platforms are unaffected; Windows stops disagreeing.
  • Remote SSH / local: untouched.
  • Agents and integrations: untouched, provider-neutral.
  • Mobile: untouched.
  • Performance: none.
  • UI quality: N/A.
  • Backwards compatibility: no contract changes; the same behaviour is asserted on one more platform.

Agent skill upstream boundary

  • Not applicable, or this change follows docs/reference/agent-skill-sharing-upstream-boundary.md and copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Ensure no issues in: Security, Cross-platoform support (Linux, Windows, Mac), Remote SSH, Mobile, general backwards compatibility, performance — covered under Review.

#15994 is a much larger Windows-suite sweep and touches neither file, so these do not overlap.

Checklist

  • This PR is small and focused
  • I explained what changed and why (including ELI5)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred) — typecheck and the affected suites locally; lint/test blocked on Windows by the pre-existing issues named under Testing, so CI covers them

Both files describe paths with POSIX literals while their subjects compose
paths through `node:path`, so the assertions only hold where the separator
happens to be `/`.

`node-markdown-document-discovery` keys its fake tree at `/repo/docs` and
`/repo/one`, but `discoverMarkdownRelativePaths` descends with
`join(absoluteDirectoryPath, entry.name)` — `\repo\docs` on win32. The child
lookup misses, `readDirectory` yields nothing, and the walk stops at the root:
`docs/guide.mdx` disappears and the depth-limit case never reaches its limit,
so it resolves `[]` instead of rejecting. Keying the children with `join` walks
the tree the subject actually walks.

`git-fetch-head-lock` expects `cwd: '/tmp/repo'` from a subject that returns
`path.resolve(cwd, 'repo')`, which is `C:\tmp\repo` on win32. Asserting through
`path.resolve` pins the behaviour — that `-C` and `--git-dir` are resolved
against the cwd — rather than the separator of whichever machine runs the suite.

Verified on Windows 11: the two files go from 3 failed / 12 passed to
14 passed / 1 skipped, and the wider `src/shared` run shows no regression.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Aug 26, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 314c9849-e25e-4d5b-9af0-bcacef5b5210

📥 Commits

Reviewing files that changed from the base of the PR and between cac5388 and b404dff.

📒 Files selected for processing (2)
  • src/shared/git-fetch-head-lock.test.ts
  • src/shared/node-markdown-document-discovery.test.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

Updated tests to construct expected Git paths with path.resolve. Updated Markdown discovery fixtures to use path.join for nested directory keys. Added documentation for matching fixture keys with discovery path construction. These changes preserve validation of Git path options and Markdown traversal behavior across platforms.

Merge Risk: ⚪ Minimal · up to b404d

This test-only change makes two path assertions portable across operating systems without changing production behavior; no actionable merge-blocking risk remains beyond normal checks and review.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely identifies the main change: updating two shared test suites to avoid POSIX-specific path assertions on Windows.
Description check ✅ Passed The description follows the required template and provides a clear explanation, change summary, rationale, linked issue, visual-proof rationale, platform-specific testing, AI disclosure, review notes,…
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2…
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description follows the required template and provides a clear explanation, change summary, rationale, linked issue, visual-proof rationale, platform-specific testing, AI disclosure, review notes, and checklist status. It also explains why full lint and test runs were blocked by pre-existing Windows issues.

Full details: Docstring Coverage

Explanation

No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check. Docstring coverage is scoped to functions touched by this diff. Analyzed 0 functions across 2 files.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit aa95bdb into stablyai:main Aug 29, 2026
49 checks passed
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
…tablyai#16511)

Both files describe paths with POSIX literals while their subjects compose
paths through `node:path`, so the assertions only hold where the separator
happens to be `/`.

`node-markdown-document-discovery` keys its fake tree at `/repo/docs` and
`/repo/one`, but `discoverMarkdownRelativePaths` descends with
`join(absoluteDirectoryPath, entry.name)` — `\repo\docs` on win32. The child
lookup misses, `readDirectory` yields nothing, and the walk stops at the root:
`docs/guide.mdx` disappears and the depth-limit case never reaches its limit,
so it resolves `[]` instead of rejecting. Keying the children with `join` walks
the tree the subject actually walks.

`git-fetch-head-lock` expects `cwd: '/tmp/repo'` from a subject that returns
`path.resolve(cwd, 'repo')`, which is `C:\tmp\repo` on win32. Asserting through
`path.resolve` pins the behaviour — that `-C` and `--git-dir` are resolved
against the cwd — rather than the separator of whichever machine runs the suite.

Verified on Windows 11: the two files go from 3 failed / 12 passed to
14 passed / 1 skipped, and the wider `src/shared` run shows no regression.

Co-authored-by: Claude Opus 5 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: two src/shared suites assert POSIX separators, so they fail on Windows — one by discovering nothing

2 participants