mirror of https://github.com/golang/go.git
cmd/cover: skip go list when profile is empty
Only call "go list" when explicitly listing packages. An empty coverage profile references no packages, and would otherwise lead to "go list" implicitly looking at the package in "." (which might not exist). Fixes #33855 Change-Id: I02d4e374405d86f03d105fe14648aa03b4d2284c Reviewed-on: https://go-review.googlesource.com/c/go/+/192340 Reviewed-by: Bryan C. Mills <bcmills@google.com> Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org>
This commit is contained in:
parent
87113f7ead
commit
9d480edadc
|
|
@ -191,6 +191,10 @@ func findPkgs(profiles []*Profile) (map[string]*Pkg, error) {
|
|||
}
|
||||
}
|
||||
|
||||
if len(list) == 0 {
|
||||
return pkgs, nil
|
||||
}
|
||||
|
||||
// Note: usually run as "go tool cover" in which case $GOROOT is set,
|
||||
// in which case runtime.GOROOT() does exactly what we want.
|
||||
goTool := filepath.Join(runtime.GOROOT(), "bin/go")
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
go tool cover -func=cover.out
|
||||
stdout total.*statements.*0.0%
|
||||
|
||||
go mod init golang.org/issue/33855
|
||||
|
||||
go tool cover -func=cover.out
|
||||
stdout total.*statements.*0.0%
|
||||
|
||||
-- cover.out --
|
||||
Loading…
Reference in New Issue