Repository navigation
fix approved file lookup under -trimpath - #89
Draft
hownowstephen wants to merge 3 commits into
Draft
hownowstephen wants to merge 3 commits into
hownowstephen wants to merge 3 commits into
Conversation
Reviewer's guide (collapsed on small PRs)Reviewer's GuideThe PR fixes approved-file lookup for -trimpath by resolving non-absolute frame paths against the package test working directory, and adds CI coverage to prevent regressions across the repository. Sequence diagram for trimpath approval file resolutionsequenceDiagram
participant Test as Go test
participant Runtime as runtime.Callers
participant Resolver as findFileName
participant OS as os.Getwd
participant Path as filepath.Join
Test->>Runtime: capture stack frame
Runtime-->>Resolver: lastFrame.File
alt filepath.IsAbs(lastFrame.File)
Resolver-->>Test: absolute frame path
else non-absolute frame path
Resolver->>OS: os.Getwd()
OS-->>Resolver: package working directory
Resolver->>Path: filepath.Base(lastFrame.File)
Path-->>Resolver: base filename
Resolver-->>Test: filepath.Join(wd, base filename)
end
File-Level Changes
Tips and commandsInteracting with Sourcery
Customizing Your ExperienceAccess your dashboard to:
Getting Help
|
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.
Under
-trimpath, stack frame file paths are module-relative (github.com/org/mod/pkg/x_test.go), so approved files resolve to<pkg>/github.com/org/mod/pkg/.... Every approval misses, and received files are written there instead. This repo's own suite fails ~60 tests withGOFLAGS=-trimpath.When the frame path isn't absolute, fall back to the working directory, since
go testruns each package's tests from its source directory.CI now also runs
go test -trimpath ./...on stable Go for each OS. Older toolchains hit unrelated linker issues on current runners (macOSLC_UUID, Windows cgo with-race).Known limitation: if a
t.Runcallback is defined in a helper package, approvals under-trimpathgo to the calling test's package rather than next to the helper.Summary by Sourcery
Ensure approval files resolve correctly under
-trimpathand continuously verify this behavior in CI.Bug Fixes:
-trimpathoption by resolving non-absolute stack frame paths from the package working directory.CI:
-trimpathon the stable Go version in CI.