mirror of
https://github.com/golang/go.git
synced 2025-05-29 03:11:26 +00:00
cmd/go: populate the Module field for test packages
Fixes #39974 Change-Id: I52bb13e887fde52bf789198059c39fd6aacd96f0 Reviewed-on: https://go-review.googlesource.com/c/go/+/240678 Run-TryBot: Bryan C. Mills <bcmills@google.com> TryBot-Result: Gobot Gobot <gobot@golang.org> Reviewed-by: Michael Matloob <matloob@golang.org> Reviewed-by: Jay Conrod <jayconrod@google.com>
This commit is contained in:
parent
fb5c3eabd1
commit
bb998747d6
@ -191,6 +191,7 @@ func TestPackagesAndErrors(ctx context.Context, p *Package, cover *TestCover) (p
|
|||||||
GoFiles: p.XTestGoFiles,
|
GoFiles: p.XTestGoFiles,
|
||||||
Imports: p.XTestImports,
|
Imports: p.XTestImports,
|
||||||
ForTest: p.ImportPath,
|
ForTest: p.ImportPath,
|
||||||
|
Module: p.Module,
|
||||||
Error: pxtestErr,
|
Error: pxtestErr,
|
||||||
},
|
},
|
||||||
Internal: PackageInternal{
|
Internal: PackageInternal{
|
||||||
@ -222,6 +223,7 @@ func TestPackagesAndErrors(ctx context.Context, p *Package, cover *TestCover) (p
|
|||||||
ImportPath: p.ImportPath + ".test",
|
ImportPath: p.ImportPath + ".test",
|
||||||
Root: p.Root,
|
Root: p.Root,
|
||||||
Imports: str.StringList(TestMainDeps),
|
Imports: str.StringList(TestMainDeps),
|
||||||
|
Module: p.Module,
|
||||||
},
|
},
|
||||||
Internal: PackageInternal{
|
Internal: PackageInternal{
|
||||||
Build: &build.Package{Name: "main"},
|
Build: &build.Package{Name: "main"},
|
||||||
|
14
src/cmd/go/testdata/script/mod_list_test.txt
vendored
14
src/cmd/go/testdata/script/mod_list_test.txt
vendored
@ -3,9 +3,19 @@ env GO111MODULE=on
|
|||||||
# go list -compiled -test must handle test-only packages
|
# go list -compiled -test must handle test-only packages
|
||||||
# golang.org/issue/27097.
|
# golang.org/issue/27097.
|
||||||
go list -compiled -test
|
go list -compiled -test
|
||||||
|
stdout -count=4 '^.' # 4 lines
|
||||||
stdout '^m$'
|
stdout '^m$'
|
||||||
stdout '^m\.test$'
|
stdout '^m\.test$'
|
||||||
stdout '^m \[m\.test\]$'
|
stdout '^m \[m\.test\]$'
|
||||||
|
stdout '^m_test \[m\.test\]$'
|
||||||
|
|
||||||
|
# https://golang.org/issue/39974: test packages should have the Module field populated.
|
||||||
|
go list -test -f '{{.ImportPath}}{{with .Module}}: {{.Path}}{{end}}'
|
||||||
|
stdout -count=4 '^.' # 4 lines
|
||||||
|
stdout '^m: m$'
|
||||||
|
stdout '^m\.test: m$'
|
||||||
|
stdout '^m \[m\.test\]: m$'
|
||||||
|
stdout '^m_test \[m\.test\]: m$'
|
||||||
|
|
||||||
-- go.mod --
|
-- go.mod --
|
||||||
module m
|
module m
|
||||||
@ -14,3 +24,7 @@ module m
|
|||||||
package x
|
package x
|
||||||
import "testing"
|
import "testing"
|
||||||
func Test(t *testing.T) {}
|
func Test(t *testing.T) {}
|
||||||
|
-- x_x_test.go --
|
||||||
|
package x_test
|
||||||
|
import "testing"
|
||||||
|
func Test(t *testing.T) {}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user