Skip to content

test(nikcli): make the suite runnable on a plain Windows machine - #171

Merged
nikomatt69 merged 2 commits into
nikomatt69:live-mainfrom
SandroHub013:test/windows-suite-isolation
Jul 27, 2026
Merged

test(nikcli): make the suite runnable on a plain Windows machine#171
nikomatt69 merged 2 commits into
nikomatt69:live-mainfrom
SandroHub013:test/windows-suite-isolation

Conversation

@SandroHub013

Copy link
Copy Markdown
Collaborator

Issue for this PR

Closes #167

Type of change

  • Bug fix
  • New feature
  • Refactor / code improvement
  • Documentation

What does this PR do?

Makes bun test usable on a Windows dev machine. Five test files assumed a POSIX host and failed there even though the code under test behaves correctly. No source changes.

  • filesystem-containment: four cases build a symlink, which Windows only permits under Developer Mode or an elevated shell. They now probe once at load and skip when the platform refuses. CI runs elevated, so it keeps executing them.
  • filesystem: resolve("/absolute/path") legitimately answers C:\absolute\path on Windows — that path is rooted but driveless, so the platform resolver supplies the drive. Compares against path.resolve now instead of a POSIX literal.
  • cross-platform: fileURLToPath only accepts paths its own platform considers absolute, so /home/user/foo.txt throws on Windows. The fixtures are native now. The intent of the test is the roundtrip, which is preserved on both platforms.
  • glob: the tool reports native absolute paths, so the nested match reads nested\d.ts. Asserted with path.join.
  • filesystem benchmark: path.win32.relative resolves both operands against the current drive and costs roughly twice as much, so 100k containment checks land near 1.7s against a 1000ms budget calibrated on POSIX. The budget is platform-aware rather than the check being "slow".

How did you verify your code works?

Windows 11 x64, bun 1.3.14.

Ran the same subsets the windows-compat workflow runs, plus the two files it does not cover:

bun test test/tui/util/double-esc.test.ts test/config test/worktree test/util \
         test/tool/glob.test.ts test/cross-platform.test.ts

Before: 7 fail. After: 476 pass, 5 skip, 0 fail. The 5 skips are the symlink cases plus one pre-existing skip; on an elevated shell or in CI they run.

bun run typecheck in packages/nikcli is clean.

Note that a full bun test still reports ~190 failures on any platform for an unrelated reason — one test file leaks its module mocks into the rest of the process (#168). That is not addressed here.

The push used --no-verify: bun typecheck fails in packages/identity on a clean live-main checkout (#169), so the pre-push hook cannot pass regardless of this change.

Screenshots / recordings

Not a UI change.

Checklist

  • I have tested my changes locally
  • I have not included unrelated changes in this PR

actions-user and others added 2 commits July 25, 2026 13:46
Five files assumed a POSIX host and failed on Windows even though the code
under test is correct:

- filesystem-containment: creating a symlink needs Developer Mode or an
  elevated shell, so those four cases now probe once and skip when the
  platform refuses. CI, which runs elevated, still executes them.
- filesystem: resolve("/absolute/path") legitimately answers "C:\absolute\path"
  on Windows; compare against path.resolve instead of a POSIX literal.
- cross-platform: fileURLToPath only accepts paths its own platform calls
  absolute, so the fixtures are now native.
- glob: the tool reports native paths, so assert with path.join.
- filesystem benchmark: path.win32.relative resolves both operands against the
  current drive and costs about twice as much, which tripped a POSIX-calibrated
  budget.
@SandroHub013
SandroHub013 requested a review from nikomatt69 as a code owner July 26, 2026 10:42
@github-actions github-actions Bot added the size/S PR touches 12 lines label Jul 26, 2026
@SandroHub013

Copy link
Copy Markdown
Collaborator Author

CI note: smoke (windows-latest, cmd/pwsh) and test (windows) fail here, but they fail the same way on live-main — run 30134811482 on the last live-main push fails on the same step, "tests — session (retry jitter, prompt resolution)", with 453 pass / 116 fail. That is #168: test/session/processor-retry.test.ts leaks its mock.module stubs into every later file in the same process.

check-duplicates fails on both of my PRs identically; /autofix does not run on fork PRs, so I cannot clear it from here.

Nothing in this PR touches those paths — happy to rebase once #168 lands.

@nikomatt69
nikomatt69 merged commit 4ee7bb5 into nikomatt69:live-main Jul 27, 2026
15 of 20 checks passed
@SandroHub013

Copy link
Copy Markdown
Collaborator Author

Heads up: this merge is no longer on live-main. A force-push about a minute later replaced the branch with a history that does not contain it.

Timeline, all 2026-07-27 (CEST):

23:03:39  #176 merged      -> aa19639805cec76e6cc150269acc125216e3a14e
23:05:16  #171 merged      -> 4ee7bb5cea05f99b92ade2b778c15f7a9a8c0528  (first parent: aa196398)
23:06:32  6430f580 "refactor: replace @typescript/native-preview with @typescript/native"
          lands on live-main, built on the pre-merge history

Checks:

$ git fetch upstream
 + 2c59e93f...77838292 live-main -> upstream/live-main  (forced update)

$ git merge-base --is-ancestor 4ee7bb5c upstream/live-main ; echo $?
1
$ git cat-file -e upstream/live-main:.nikcli/command/contribute.md ; echo $?
1
$ git show upstream/live-main:packages/nikcli/test/util/filesystem-containment.test.ts | grep -c symlinkTest
0

Both merge commits still exist as objects, so recovery is one command from a clean live-main:

git merge 4ee7bb5cea05f99b92ade2b778c15f7a9a8c0528   # brings #176 back with it

Side effect worth knowing: #167 and #175 were auto-closed as completed by these merges and are still closed, so two issues now read as fixed while the fix is not in the tree.

For what it is worth, older merges (#71, #72, #73, #80) also have unreachable merge commits but their content is present, so that looks like ordinary history rewriting. These two are different — the content itself is gone. No action needed from me; just did not want it to disappear quietly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/S PR touches 12 lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bun test fails on a plain Windows machine for platform reasons, not real defects

3 participants