diff options
author | Jay Conrod <jayconrod@google.com> | 2019-09-16 13:45:20 -0400 |
---|---|---|
committer | Bryan C. Mills <bcmills@google.com> | 2019-09-25 14:40:04 +0000 |
commit | 94227d241b4bbfa4ffbf836c0d3174d7ee1e430b (patch) | |
tree | 13a4281547f8273801ac58921f2c68ecd1ad1133 | |
parent | 613adc62688a609e4c113a768fc49ab979812b68 (diff) | |
download | go-94227d241b4bbfa4ffbf836c0d3174d7ee1e430b.tar.gz go-94227d241b4bbfa4ffbf836c0d3174d7ee1e430b.zip |
[release-branch.go1.13] cmd/go: don't split internal test main packages twice
Fixes #34328
Change-Id: Ia6253038c525089e20a1da64a2c5c9dcc57edd74
Reviewed-on: https://go-review.googlesource.com/c/go/+/195677
Run-TryBot: Jay Conrod <jayconrod@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Bryan C. Mills <bcmills@google.com>
(cherry picked from commit 4d18a7ceb2d37b148061ee2e153d56aaef4de8fc)
Reviewed-on: https://go-review.googlesource.com/c/go/+/197064
Run-TryBot: Bryan C. Mills <bcmills@google.com>
-rw-r--r-- | src/cmd/go/internal/load/test.go | 2 | ||||
-rw-r--r-- | src/cmd/go/testdata/script/list_split_main.txt | 25 |
2 files changed, 26 insertions, 1 deletions
diff --git a/src/cmd/go/internal/load/test.go b/src/cmd/go/internal/load/test.go index 2864fb5ebb..aac7d7d481 100644 --- a/src/cmd/go/internal/load/test.go +++ b/src/cmd/go/internal/load/test.go @@ -405,7 +405,7 @@ func recompileForTest(pmain, preal, ptest, pxtest *Package) { // covered packages are imported by pmain. Linking multiple packages // compiled with '-p main' causes duplicate symbol errors. // See golang.org/issue/30907, golang.org/issue/34114. - if p.Name == "main" && p != pmain { + if p.Name == "main" && p != pmain && p != ptest { split() } } diff --git a/src/cmd/go/testdata/script/list_split_main.txt b/src/cmd/go/testdata/script/list_split_main.txt new file mode 100644 index 0000000000..74e7d5d74c --- /dev/null +++ b/src/cmd/go/testdata/script/list_split_main.txt @@ -0,0 +1,25 @@ +# This test checks that a "main" package with an external test package +# is recompiled only once. +# Verifies golang.org/issue/34321. + +env GO111MODULE=off + +go list -e -test -deps -f '{{if not .Standard}}{{.ImportPath}}{{end}}' pkg +cmp stdout want + +-- $GOPATH/src/pkg/pkg.go -- +package main + +func main() {} + +-- $GOPATH/src/pkg/pkg_test.go -- +package main + +import "testing" + +func Test(t *testing.T) {} + +-- want -- +pkg +pkg [pkg.test] +pkg.test |