]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/go: fix handling of builtin packages in WriteCoverMetaFilesFile
authorThan McIntosh <thanm@google.com>
Wed, 12 Jun 2024 14:39:19 +0000 (14:39 +0000)
committerThan McIntosh <thanm@google.com>
Fri, 14 Jun 2024 11:44:29 +0000 (11:44 +0000)
In certain unusual situations we can wind up with a build action for a
dummy (built-in) package as a dependency for the writeCoverMeta
pseudo-action generated when -coverpkg is in effect; this was causing
a panic in WriteCoverMetaFilesFile when it discovered a predecessor
whose Mode field was not "build". Update the code that constructs deps
for writeCoverMeta action to skip dummy builds.

Fixes #67953.

Change-Id: If747aeb9bae061c84290d1e10f6ea7abb0828aca
Reviewed-on: https://go-review.googlesource.com/c/go/+/592202
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Matloob <matloob@golang.org>
src/cmd/go/internal/test/test.go
src/cmd/go/testdata/script/test_n_cover_std.txt [new file with mode: 0644]

index a13070a91e7b0458948d6e0f46c7bcd81885fc60..0ac56666201109846416802be89d6b9786ca9a8a 100644 (file)
@@ -1067,7 +1067,7 @@ func builderTest(b *work.Builder, ctx context.Context, pkgOpts load.PackageOpts,
                        Package:    p,
                        IgnoreFail: true, // run (prepare output) even if build failed
                }
-               if writeCoverMetaAct != nil {
+               if writeCoverMetaAct != nil && build.Actor != nil {
                        // There is no real "run" for this package (since there
                        // are no tests), but if coverage is turned on, we can
                        // collect coverage data for the code in the package by
diff --git a/src/cmd/go/testdata/script/test_n_cover_std.txt b/src/cmd/go/testdata/script/test_n_cover_std.txt
new file mode 100644 (file)
index 0000000..77b92df
--- /dev/null
@@ -0,0 +1,7 @@
+# Issue 67953: test to make sure that the go commands static coverage
+# meta-data handling code handles pseudo-packages (ex: "unsafe") properly.
+
+[short] skip
+
+cd $GOROOT/src
+go test -vet=off -p=1 -n -coverpkg=internal/coverage/decodecounter internal/coverage/decodecounter sync unsafe