Skip to content

test(git,encryption): anchor fixture roots at temp directories, not "/" - #398

Merged
David-Noble-at-work merged 1 commit into
developfrom
fix/unix-literal-roots
Aug 13, 2026
Merged

David-Noble-at-work merged 1 commit into
developfrom
fix/unix-literal-roots

Conversation

@David-Noble-at-work

Copy link
Copy Markdown
Contributor

Issue #392's fixture half: ten test fixtures (not the four the issue first said — the enumeration correction is on the issue) built runtime environments on fsroot.OpenWritableUnconfined("/"), a whole-filesystem root that cannot address absolute Windows paths — filepath.Rel("/", "C:\…") cannot cross volumes, so makePath's assert fired and the receipt tests panicked on the windows leg.

The fix

All ten anchor at temp directories, with path literals derived from the root:

  • encryption/receipt_test.go, git/receipt_test.go — root at t.TempDir(), fixture path joined beneath it
  • git/provider_test.go — testActivation/newTestProvider take an explicit rootDir; every /tmp/* literal becomes a filepath.Join form and the derived-directory assertions follow the root
  • git/resource_test.go — newRes anchors at the path's own directory
  • git/checkout_pull_observe_test.go — both provider fixtures root at t.TempDir(); the two /tmp/* inputs join under it

One test needed thought, not mechanics: TestDiscoverResource_WindowsShapedPath_IsAPath proves a drive-colon path is a path, not a URI scheme. Its input now borrows the fixture root's own volume on Windows (a foreign volume cannot be made root-relative) while Unix keeps the literal D: shape — the scheme-collision subject is exercised on both platforms.

Bonus: every fixture is now properly confined instead of addressing the whole filesystem.

Expected windows-leg effect: the ~5-failure panic cluster clears. The writ System-layer TargetRoot: "/" design question is #392's remaining half, deliberately untouched.

Verified: make vet, make lint-all, full make test green (zero FAIL/panic by count); gofmt clean.

Issue #392, the fixture half. Test fixtures built runtime environments on
fsroot.OpenWritableUnconfined("/"), a whole-filesystem root that cannot
address absolute Windows paths: filepath.Rel("/", "C:\...") cannot cross
volumes, so fsroot.makePath's assert fired and TestReceipt_RestoreEncoded
panicked on the windows leg.

The issue said four sites; the uncapped sweep found ten — the original grep
was head-capped, and the correction is recorded on the issue. All ten now
anchor at temp directories: encryption's receipt test and git's receipt test
root at t.TempDir() and join their fixture paths beneath it; git's
testActivation and newTestProvider take an explicit rootDir parameter with
every caller passing t.TempDir() and deriving path literals from it (the
hardcoded /tmp/clone-dest, /tmp/dest, /tmp/shallow, /tmp/checkout-repo, and
/tmp/pull-repo literals become filepath.Join forms, and the
derived-directory assertions follow the root instead of expecting "/repo");
newRes anchors at the path's own directory; the narrating and observe
provider fixtures root at t.TempDir().

One test needed more than mechanical anchoring:
TestDiscoverResource_WindowsShapedPath_IsAPath exists to prove a drive-colon
path is treated as a path, not a URI scheme. Its input now borrows the
fixture root's own volume on Windows — a foreign volume cannot be made
root-relative — while on Unix VolumeName is empty and the original literal
"D:" shape survives, so the scheme-collision subject is exercised on both
platforms.

Anchoring at temp directories also confines every fixture properly: the
tests could previously address the whole filesystem.

Expected windows-leg effect: the ~5-failure panic cluster clears. The writ
System-layer TargetRoot "/" design question is #392's remaining half,
deliberately untouched here.

Verified: make vet, make lint-all, full make test green — zero FAIL or panic
lines by count; gofmt clean.
Issue: #392
@David-Noble-at-work David-Noble-at-work self-assigned this Aug 13, 2026
@David-Noble-at-work
David-Noble-at-work merged commit f15c863 into develop Aug 13, 2026
7 of 8 checks passed
@David-Noble-at-work
David-Noble-at-work deleted the fix/unix-literal-roots branch August 13, 2026 04:58
David-Noble-at-work added a commit that referenced this pull request Aug 13, 2026
…ix two (#400)

Windows test expectations

Three file-package items from the Windows remainder (#373 phase 3e), one of
them a product defect.

The defect: resolveFindRoot used filepath.IsAbs to decide whether a Find
pattern's base escapes the scoped root. A rooted-but-driveless form ("/etc")
is not IsAbs on Windows, so it took the relative branch and silently walked
<scope>/etc instead of erroring — the scope-confinement contract violated for
exactly the pattern shape ("/etc/**/*.conf") the confinement exists to refuse.
Any rooted form now takes the absolute branch; filepath.Rel then errors on the
volume mismatch and the outside-scope error reports correctly. Unix behavior
is unchanged (IsAbs already catches "/"), which is also why no Darwin-side
mutation can prove the fix: the existing
TestFind_AbsolutePatternOutsideScope_Errors is the pin, and CI's windows leg
is where it bites.

The two test fixes: TestDiscoverRegular_WindowsShapedPath_IsAPath fed a
literal D:\ path against a C: temp root — cross-volume, unmakeable relative,
panic; it now borrows the fixture root's own volume on Windows while Unix
keeps the literal "D:" shape, same treatment as its git-package twin (#392,
PR #398). TestRegularConvertFrom_Unlinked asserted a slash literal against
Abs, which is OS-native by the #377 ruling; the expectation is now
filepath.FromSlash-built.

Expected windows-leg effect: the surviving makePath panic clears (and with it
whatever that panic's binary abort was hiding), plus the Find-scope and
ConvertFrom failures.

Verified: make vet, make lint-all, full make test green — zero FAIL or panic
lines by count; gofmt clean.
Issues: #373, #392

Co-authored-by: David Noble <[email protected]>
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.

1 participant