Repository navigation
test(git,encryption): anchor fixture roots at temp directories, not "/" - #398
Merged
Merged
Conversation
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
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]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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, somakePath'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 att.TempDir(), fixture path joined beneath itgit/provider_test.go—testActivation/newTestProvidertake an explicitrootDir; every/tmp/*literal becomes afilepath.Joinform and the derived-directory assertions follow the rootgit/resource_test.go—newResanchors at the path's own directorygit/checkout_pull_observe_test.go— both provider fixtures root att.TempDir(); the two/tmp/*inputs join under itOne test needed thought, not mechanics:
TestDiscoverResource_WindowsShapedPath_IsAPathproves 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 literalD: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, fullmake testgreen (zero FAIL/panic by count); gofmt clean.