1
0
mirror of https://github.com/golang/go synced 2024-11-17 09:44:48 -07:00

cmd/go: allow a package that ends with _test having an internal test package

Fixes #45477

Change-Id: I2f1ed281515ec40d31fd07ce9f4901777691bfa7
This commit is contained in:
Ryan Leung 2021-11-19 14:18:11 +08:00
parent e8cda0a6c9
commit 7894d9400c
2 changed files with 13 additions and 1 deletions

View File

@ -0,0 +1,12 @@
[short] skip # links and runs a test binary
go test -v .
-- go.mod --
module example.com/pkg_test
-- pkg.go --
package pkg_test
-- pkg_test.go --
package pkg_test

View File

@ -894,7 +894,7 @@ Found:
isTest := strings.HasSuffix(name, "_test.go")
isXTest := false
if isTest && strings.HasSuffix(pkg, "_test") {
if isTest && strings.HasSuffix(pkg, "_test") && p.Name != pkg {
isXTest = true
pkg = pkg[:len(pkg)-len("_test")]
}