Previously go list -test <pkg> would return pkg and, if it exists,
pkg.test, the test main package. This change will also list the
two test code packages (if they exist) that contain testing functions,
<pkg> [<pkg>.test] and <pkg>_test [<pkg>.test].
These packages which contain testing code are usually the packages
go list users desire to know about, so they should be surfaced
in go list -test.
See the discussion at
golang.org/cl/123635#message-
5befbc66663063fb7247645a02ab1327a681e362
for more context.
Change-Id: I7170b539d02b548c050ac54048735ed785f47389
Reviewed-on: https://go-review.googlesource.com/126475
Run-TryBot: Michael Matloob <matloob@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Russ Cox <rsc@golang.org>
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")
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{
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")