aboutsummaryrefslogtreecommitdiff
path: root/src/internal/coverage
diff options
context:
space:
mode:
authorThan McIntosh <thanm@google.com>2023-05-05 15:53:33 -0400
committerThan McIntosh <thanm@google.com>2023-09-14 19:44:37 +0000
commite356aa656d92ffd551e89edd9ed6ac00ea0278ef (patch)
tree316eecf822a0e268be5c0ae10d48c322733cf4bd /src/internal/coverage
parent0b07bbd2be98f80f3d447a266803f1d68aee2902 (diff)
downloadgo-e356aa656d92ffd551e89edd9ed6ac00ea0278ef.tar.xz
cmd/cover: add new "emit meta file" mode for packages without tests
Introduce a new mode of execution for instrumenting packages that have no test files. Instead of just skipping packages with no test files (during "go test -cover" runs), the go command will invoke cmd/cover on the package passing in an option in the config file indicating that it should emit a coverage meta-data file directly for the package (if the package has no functions, an empty file is emitted). Note that this CL doesn't actually wire up this functionality in the Go command, that will come in a later patch. Updates #27261. Updates #58770 Updates #24570. Cq-Include-Trybots: luci.golang.try:gotip-linux-amd64-longtest,gotip-windows-amd64-longtest Change-Id: I01e8a3edb62441698c7246596e4bacbd966591c3 Reviewed-on: https://go-review.googlesource.com/c/go/+/495446 Reviewed-by: Bryan Mills <bcmills@google.com> LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Diffstat (limited to 'src/internal/coverage')
-rw-r--r--src/internal/coverage/covcmd/cmddefs.go7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/internal/coverage/covcmd/cmddefs.go b/src/internal/coverage/covcmd/cmddefs.go
index 8a350f3903..e8ce204825 100644
--- a/src/internal/coverage/covcmd/cmddefs.go
+++ b/src/internal/coverage/covcmd/cmddefs.go
@@ -32,6 +32,13 @@ type CoverPkgConfig struct {
// corresponding field in cmd/go's PackageInternal struct for more
// info.
Local bool
+
+ // EmitMetaFile if non-empty is the path to which the cover tool should
+ // directly emit a coverage meta-data file for the package, if the
+ // package has any functions in it. The go command will pass in a value
+ // here if we've been asked to run "go test -cover" on a package that
+ // doesn't have any *_test.go files.
+ EmitMetaFile string
}
// CoverFixupConfig contains annotations/notes generated by the