aboutsummaryrefslogtreecommitdiff
path: root/src/cmd/cover
diff options
context:
space:
mode:
authorRhys Hiltner <rhys@justin.tv>2019-08-29 09:49:36 -0700
committerBryan C. Mills <bcmills@google.com>2019-08-30 17:07:53 +0000
commit9d480edadc6144d9f9f5a896d729d1642e46083b (patch)
treecaf1157f129d60a273c7c769743fc7191d789f60 /src/cmd/cover
parent87113f7eadf6d8b12279709f05c0359b54b194ea (diff)
downloadgo-9d480edadc6144d9f9f5a896d729d1642e46083b.tar.gz
go-9d480edadc6144d9f9f5a896d729d1642e46083b.zip
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>
Diffstat (limited to 'src/cmd/cover')
-rw-r--r--src/cmd/cover/func.go4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/cmd/cover/func.go b/src/cmd/cover/func.go
index fe64374189..988c4caebf 100644
--- a/src/cmd/cover/func.go
+++ b/src/cmd/cover/func.go
@@ -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")