Change information
Commit message:
[release-branch.go1.25] cmd/go: invalidate test cache when -coverpkg dependencies change
When running tests with -cover and -coverpkg, the resulting coverage
profile includes data from all packages specified in -coverpkg, not
just the test package. Previously, the test cache key did not account
for changes in these out-of-band covered packages, causing stale
coverage profiles to be reused even when source files in covered
packages were modified.
Fix this by hashing the BuildActionIDs of the writeCoverMetaAct's
dependencies (the compile actions for all covered packages) and
incorporating that hash into the coverage profile cache key via
cache.Subkey.
The covMeta hash is now computed directly in tryCacheWithID by
locating the "write coverage meta-data file" action among the run
action's dependencies, keeping all cache logic in one place. When
-coverpkg is used without -coverprofile, a sentinel cache entry is
written so the cache can still detect when covered packages change.
For #74873
Fixes #78582
Change-Id: Ice84557789e325330759442689d0e28f871858bb
GitHub-Last-Rev: 84aa5376f471704b0ee7be79ab33a1d5bba71c5a
GitHub-Pull-Request: golang/go#74773
Files:
- M src/cmd/go/internal/test/test.go
- A src/cmd/go/testdata/script/test_cache_coverpkg_bug.txt
- A src/cmd/go/testdata/script/test_cache_coverpkg_no_profile.txt
Change size: L
Delta: 3 files changed, 276 insertions(+), 9 deletions(-)
Branch: refs/heads/release-branch.go1.25