Skip to content

test(windows): honest test harness on unprivileged Windows (#147, #148) - #160

Merged
abogartz merged 3 commits into
abogartz:mainfrom
WhollyMindless:fix/test-windows-147-148
Oct 28, 2026
Merged

abogartz merged 3 commits into
abogartz:mainfrom
WhollyMindless:fix/test-windows-147-148

Conversation

@WhollyMindless

Copy link
Copy Markdown
Contributor

What this is

Two Windows reds in the test harness itself — no product code involved. Both have ridden along as the footnoted "known local reds" in every contributor run through this program (#156/#158 bodies included); this branch retires the footnote. #147: two containment.test.ts fixtures throw EPERM from their own symlinkSync call on an unprivileged Windows box — the test dies in setup, before resolveContained is ever called. #148: makeServeGuest hands the service a POSIX-only PATH, so on Windows the service can't spawn git, resolveRepo falls back to a path-hash key, and the service-hosted origin-URL stamp this suite exists to pin (the #90 contract) could never be asserted on this platform at all.

#147 — skip on the capability, not the platform label

The file already carries five test.skipIf(process.platform === "win32") guards for genuinely POSIX-only guarantees; the two direct-symlink fixtures (a dangling symlink in the path…, a link to another file INSIDE the root…) missed the pattern — and a win32 guard would be the wrong fix for them anyway: GitHub's Windows runners hold SeCreateSymbolicLinkPrivilege (test-windows runs the rest of the file green), so a platform skip would delete coverage CI is actually getting. The guard is instead a once-per-process capability probe — symlinkSync into a mkdtemp dir, skip() on EPERM, anything else rethrown — gating exactly these two tests. Privileged machines (any CI runner) keep running them on every platform; unprivileged dev boxes stop paying a fake-red triage tax. The five existing guards are untouched, no product-code change.

#148 — a PATH that can find git

Exactly the issue's suggested shape: on win32 the guest gets `${dirname(process.execPath)};${process.env.PATH}`, elsewhere the existing POSIX dirs verbatim. The HOME/XDG sandbox isolation is untouched — this is executable lookup only, and the hermeticity that matters (identity files, #142's real-~ leak class) is enforced by the HOME/XDG keys, not by PATH starvation. A skip was deliberately rejected: there is no Windows e2e CI job, so skipping would silently delete the only place this platform-neutral contract gets exercised instead of starting coverage.

Evidence

  • Red at base ed5ecde (Windows 11 / Bun 1.4.4, Developer Mode off):
    • bun test test/containment.test.ts → 33 pass / 2 fail — EPERM: operation not permitted, symlink … with code: "EPERM", thrown by the fixture at lines 171/315, not by resolveContained.
    • bun test ./e2e/ --timeout 240000 → 10 pass / 1 fail — Expected to contain: "repo=8960c7c730bb", received repo=427dd92d0ad3 (the path-hash fallback) with the repoPath itself correct.
  • Green at fix, same machine: containment 33 pass / 7 skip / 0 fail (2 new capability skips + the 5 pre-existing win32 skips); e2e 11 pass / 0 fail — the URL-key assertion now genuinely runs and passes on Windows.
  • Full local suite green for the first time: bun run test → 600 pass / 12 skip / 0 fail (base on this box: 600 / 10 / 2 — the two reds became exactly two skips; totals identical at 612).
  • bun x tsc --noEmit clean; bun run lint (the CI gate) exit 0.
  • CI impact: ubuntu unchanged (probe succeeds → both tests run as before); test-windows unchanged (capability present → they run there too, where the e2e job doesn't run at all).

Boundaries

Two test files, zero src/ lines, zero workflow changes. The other test-integrity family (#144/#146 flakes, epic #68) untouched.

Closes #147
Closes #148

…ility, not platform (abogartz#147)

On Windows boxes without Developer Mode the fixtures' own symlinkSync throws
EPERM before resolveContained is called - a fake red that has footnoted every
contributor run of the suite. A skipIf(win32) would be the wrong guard: the
GitHub Windows runners HAVE the privilege, so skipping by label would delete
coverage CI is actually getting. One mkdtemp+symlinkSync probe per process
gates exactly these two tests on the capability the fixture needs; privileged
boxes (runners included) still run them. The five existing POSIX-only
skipIf(win32) guards are untouched.
…bogartz#148)

The sandbox env's PATH was hardcoded POSIX (bun dir + /usr/bin...). On Windows
the service host then cannot spawn git, resolveRepo's remote lookup fails, and
the store falls back to a path-hash key - so the service-hosted origin-URL
stamp (the platform-neutral abogartz#90 contract this suite pins) could never be
produced, let alone asserted, on this platform. Platform-aware per the issue:
bun dir + the real process.env.PATH on win32, unchanged elsewhere. HOME/XDG
isolation untouched; this is executable lookup only. A skip was rejected -
with no Windows e2e CI job it would delete the coverage rather than start it.
@WhollyMindless

Copy link
Copy Markdown
Contributor Author

@abogartz Independent review of 201b726: no blocking finding; I recommend merging this test-harness fix.

Verified on unprivileged Windows with Bun 1.4.4:

  • test/containment.test.ts: 33 pass / 7 skip / 0 fail. The two formerly failing symlink fixtures now skip because this machine lacks the capability; the five pre-existing skips are unchanged.
  • Full e2e/ suite: 11 pass / 0 fail, including the real service-hosted repository-origin stamp. This exercises the Windows PATH correction, rather than skipping the assertion.
  • I also inspected this head's Windows CI job: both newly capability-gated tests actually PASS there (dangling symlink and inside-root file symlink), confirming the change preserves coverage on a capable Windows runner.

The diff changes only two test files. The capability probe catches only EPERM and rethrows other errors. The PATH branch preserves the existing non-Windows value and leaves the service HOME/XDG/store isolation unchanged.

Integration check: locally combined #156 834ccba, #158 a88e65d, and this head over ed5ecde without conflicts. The committed unit suite is 614 pass / 12 skip / 0 fail, e2e is 11/11, type-checking passes, and lint exits 0 (existing advisory warnings remain). This does not approve #158: its two additional fault-injection failures are posted on that PR and remain reproducible in the combined tree. #156 has since merged.

The local integration merge was aborted afterward; tracked files are clean and nothing was pushed by this review.

@abogartz
abogartz merged commit ea780fe into abogartz:main Oct 28, 2026
4 checks passed
@abogartz-opencode-self-improvement

Copy link
Copy Markdown

🎉 This PR is included in version 0.14.16 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Labels

Projects

None yet

2 participants