diff --git a/src/cmd/go/go_test.go b/src/cmd/go/go_test.go index adf17b8bc5..7249c0fb6e 100644 --- a/src/cmd/go/go_test.go +++ b/src/cmd/go/go_test.go @@ -1757,7 +1757,7 @@ func TestGoListTest(t *testing.T) { tg.run("list", "-test", "sort") tg.grepStdout(`^sort.test$`, "missing test main") tg.grepStdout(`^sort$`, "missing real sort") - tg.grepStdoutNot(`^sort \[sort.test\]$`, "unexpected test copy of sort") + tg.grepStdout(`^sort \[sort.test\]$`, "unexpected test copy of sort") tg.grepStdoutNot(`^testing \[sort.test\]$`, "unexpected test copy of testing") tg.grepStdoutNot(`^testing$`, "unexpected real copy of testing") diff --git a/src/cmd/go/internal/list/list.go b/src/cmd/go/internal/list/list.go index d21e896834..5cb61b0d67 100644 --- a/src/cmd/go/internal/list/list.go +++ b/src/cmd/go/internal/list/list.go @@ -424,7 +424,7 @@ func runList(cmd *base.Command, args []string) { continue } if len(p.TestGoFiles)+len(p.XTestGoFiles) > 0 { - pmain, _, _, err := load.TestPackagesFor(p, nil) + pmain, ptest, pxtest, err := load.TestPackagesFor(p, nil) if err != nil { if *listE { pkgs = append(pkgs, &load.Package{ @@ -439,6 +439,12 @@ func runList(cmd *base.Command, args []string) { continue } pkgs = append(pkgs, pmain) + if ptest != nil { + pkgs = append(pkgs, ptest) + } + if pxtest != nil { + pkgs = append(pkgs, pxtest) + } data := *pmain.Internal.TestmainGo h := cache.NewHash("testmain")