fix(test): use Go overlay instead of file copying#40
Merged
Conversation
The `racedetector test` command copied .go files to a temp directory and ran `go test` from there. This broke projects that import internal/ packages from their own module (Go enforces internal/ imports only from within the module tree). Same issue affected //go:embed directives. Replace file-copying with Go's -overlay flag: - Instrumented files written to temp dir with overlay JSON mapping - Go compiles from original module tree (preserves internal/ and embed) - -modfile + -mod=mod for dependency injection without modifying go.mod - GOWORK=off for Go workspace mode compatibility - GONOSUMCHECK for racedetector module checksum skip Fixes test failures on projects like gogpu/ui with internal/ dependencies.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #40 +/- ##
==========================================
- Coverage 71.58% 70.04% -1.54%
==========================================
Files 28 28
Lines 4455 2951 -1504
==========================================
- Hits 3189 2067 -1122
+ Misses 1148 766 -382
Partials 118 118
Flags with carried forward coverage won't be shown. Click here to find out more.
... and 21 files with indirect coverage changes Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Updated golangci-lint catches new issues: - Remove unused //nolint:gosec directives (G115, G602 no longer flagged) - Remove unused //nolint:prealloc directives - Use fmt.Fprintf instead of WriteString(fmt.Sprintf(...)) (staticcheck QF1012) - Fix getcallerpc() to capture PC from correct return position - Preallocate stack slice in test - Fix test.go formatting (trailing blank lines)
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.
Summary
racedetector testbroken for projects withinternal/packages and//go:embeddirectivesinternal/import restrictions-overlayflag — instrumented files mapped via overlay JSON while Go compiles from the original module treeTechnical Details
-modfile+-mod=modinjects racedetector dependency without modifying user'sgo.modGOWORK=offensures compatibility with Go workspace modeGONOSUMCHECKskips checksum verification for racedetector modulerace.mod/race.sumwritten to temp dir (user files never modified)Test plan
internal/dependenciesgo vetpasses