Skip to content

Commit

Permalink
cmd/go: don't split internal test main packages twice
Browse files Browse the repository at this point in the history
Fixes #34321

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>
  • Loading branch information
Jay Conrod committed Sep 16, 2019
1 parent 7f907b9 commit 4d18a7c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cmd/go/internal/load/test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
}
}
Expand Down
25 changes: 25 additions & 0 deletions src/cmd/go/testdata/script/list_split_main.txt
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 4d18a7c

Please sign in to comment.