Commit b47927cc authored by Bryan C. Mills's avatar Bryan C. Mills

cmd/go/internal/list: do not examine TestmainGo if the test fails to load

Fixes #25980.

Change-Id: I33c8e72871ffbb1cd1babbcd5dabc8cac0bbcaed
Reviewed-on: https://go-review.googlesource.com/123758Reviewed-by: default avatarRuss Cox <rsc@golang.org>
parent 0b3d39c7
......@@ -425,16 +425,17 @@ func runList(cmd *base.Command, args []string) {
if len(p.TestGoFiles)+len(p.XTestGoFiles) > 0 {
pmain, _, _, err := load.TestPackagesFor(p, nil)
if err != nil {
if !*listE {
base.Errorf("can't load test package: %s", err)
if *listE {
pkgs = append(pkgs, &load.Package{
PackagePublic: load.PackagePublic{
ImportPath: p.ImportPath + ".test",
Error: &load.PackageError{Err: err.Error()},
},
})
continue
}
pmain = &load.Package{
PackagePublic: load.PackagePublic{
ImportPath: p.ImportPath + ".test",
Error: &load.PackageError{Err: err.Error()},
},
}
base.Errorf("can't load test package: %s", err)
continue
}
pkgs = append(pkgs, pmain)
......
# issue 25980: crash in go list -e -test
go list -e -test -f '{{.Error}}' p
stdout '^p/d_test.go:2:8: cannot find package "d" in any of:'
-- p/d.go --
package d
-- p/d_test.go --
package d_test
import _ "d"
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment