Skip to content

Commit 94227d2

Browse files
Jay ConrodBryan C. Mills
Jay Conrod
authored and
Bryan C. Mills
committed
[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 <[email protected]> TryBot-Result: Gobot Gobot <[email protected]> Reviewed-by: Bryan C. Mills <[email protected]> (cherry picked from commit 4d18a7c) Reviewed-on: https://go-review.googlesource.com/c/go/+/197064 Run-TryBot: Bryan C. Mills <[email protected]>
1 parent 613adc6 commit 94227d2

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

src/cmd/go/internal/load/test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ func recompileForTest(pmain, preal, ptest, pxtest *Package) {
405405
// covered packages are imported by pmain. Linking multiple packages
406406
// compiled with '-p main' causes duplicate symbol errors.
407407
// See golang.org/issue/30907, golang.org/issue/34114.
408-
if p.Name == "main" && p != pmain {
408+
if p.Name == "main" && p != pmain && p != ptest {
409409
split()
410410
}
411411
}
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# This test checks that a "main" package with an external test package
2+
# is recompiled only once.
3+
# Verifies golang.org/issue/34321.
4+
5+
env GO111MODULE=off
6+
7+
go list -e -test -deps -f '{{if not .Standard}}{{.ImportPath}}{{end}}' pkg
8+
cmp stdout want
9+
10+
-- $GOPATH/src/pkg/pkg.go --
11+
package main
12+
13+
func main() {}
14+
15+
-- $GOPATH/src/pkg/pkg_test.go --
16+
package main
17+
18+
import "testing"
19+
20+
func Test(t *testing.T) {}
21+
22+
-- want --
23+
pkg
24+
pkg [pkg.test]
25+
pkg.test

0 commit comments

Comments
 (0)