[go/release-branch.go1.25] [release-branch.go1.25] cmd/go: invalidate test cache when -coverpkg dependencies change

0 views
Skip to first unread message

Michael Pratt (Gerrit)

unread,
Apr 29, 2026, 5:11:22 PM (20 hours ago) Apr 29
to Ryan Currah, Michael Pratt, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Matloob, Cherry Mui, Michael Matloob, golang-co...@googlegroups.com

Michael Pratt submitted the change

Unreviewed changes

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

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
Reviewed-by: David Chase <drc...@google.com>
Reviewed-by: Michael Matloob <mat...@google.com>
Reviewed-by: Michael Matloob <mat...@golang.org>
Reviewed-by: Cherry Mui <cher...@google.com>
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
Submit Requirements:
Open in Gerrit
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: release-branch.go1.25
Gerrit-Change-Id: Ice84557789e325330759442689d0e28f871858bb
Gerrit-Change-Number: 764380
Gerrit-PatchSet: 4
Gerrit-Owner: Ryan Currah <ry...@currah.ca>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: Michael Matloob <mat...@google.com>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
open
diffy
satisfied_requirement

Michael Pratt (Gerrit)

unread,
Apr 29, 2026, 5:11:27 PM (20 hours ago) Apr 29
to Ryan Currah, Michael Pratt, Gerrit Bot, goph...@pubsubhelper.golang.org, golang-...@googlegroups.com, golang...@luci-project-accounts.iam.gserviceaccount.com, Michael Matloob, Cherry Mui, Michael Matloob, golang-co...@googlegroups.com

Michael Pratt submitted the change

Unreviewed changes

1 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.

Change information

Commit message:
[release-branch.go1.26] 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.

Fixes #78583
For #74873
Change-Id: Ice84557789e325330759442689d0e28f871858bb
GitHub-Last-Rev: 84aa5376f471704b0ee7be79ab33a1d5bba71c5a
GitHub-Pull-Request: golang/go#74773
Reviewed-by: David Chase <drc...@google.com>
Reviewed-by: Michael Matloob <mat...@google.com>
Reviewed-by: Michael Matloob <mat...@golang.org>
Reviewed-by: Michael Pratt <mpr...@google.com>
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.26
Submit Requirements:
  • requirement satisfiedCode-Review: +1 by Cherry Mui, +2 by Michael Matloob, +1 by Michael Matloob, +1 by Michael Pratt
Inspect html for hidden footers to help with email filtering. To unsubscribe visit settings. DiffyGerrit
Gerrit-MessageType: merged
Gerrit-Project: go
Gerrit-Branch: release-branch.go1.26
Gerrit-Change-Id: Ice84557789e325330759442689d0e28f871858bb
Gerrit-Change-Number: 764360
Gerrit-PatchSet: 5
Gerrit-Owner: Gerrit Bot <letsus...@gmail.com>
Gerrit-Reviewer: Cherry Mui <cher...@google.com>
Gerrit-Reviewer: Michael Matloob <mat...@golang.org>
Gerrit-Reviewer: Michael Matloob <mat...@google.com>
Gerrit-Reviewer: Michael Pratt <mpr...@google.com>
Gerrit-CC: Ryan Currah <ry...@currah.ca>
open
diffy
satisfied_requirement
Reply all
Reply to author
Forward
0 new messages