From e356aa656d92ffd551e89edd9ed6ac00ea0278ef Mon Sep 17 00:00:00 2001 From: Than McIntosh Date: Fri, 5 May 2023 15:53:33 -0400 Subject: 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 LUCI-TryBot-Result: Go LUCI --- src/internal/coverage/covcmd/cmddefs.go | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/internal/coverage') 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 -- cgit v1.3