Fixes #14337.
Change-Id: I58aef7e08d936b0712da577dd1ce5c9ed5d8bfd2
Reviewed-on: https://go-review.googlesource.com/19513
Reviewed-by: Russ Cox <rsc@golang.org>
t.addCmd(dt, "src", "go", "test", "-race", "-i", "runtime/race", "flag", "os/exec")
t.addCmd(dt, "src", "go", "test", "-race", "-run=Output", "runtime/race")
t.addCmd(dt, "src", "go", "test", "-race", "-short", "-run=TestParse|TestEcho", "flag", "os/exec")
+ // We don't want the following line, because it
+ // slows down all.bash (by 10 seconds on my laptop).
+ // The race builder should catch any error here, but doesn't.
+ // TODO(iant): Figure out how to catch this.
+ // t.addCmd(dt, "src", "go", "test", "-race", "-run=TestParallelTest", "cmd/go")
if t.cgoEnabled {
env := mergeEnvLists([]string{"GOTRACEBACK=2"}, os.Environ())
cmd := t.addCmd(dt, "misc/cgo/test", "go", "test", "-race", "-short")
"fmt"
"go/build"
"go/format"
+ "internal/race"
"internal/testenv"
"io"
"io/ioutil"
flag.Parse()
if canRun {
- out, err := exec.Command("go", "build", "-tags", "testgo", "-o", "testgo"+exeSuffix).CombinedOutput()
+ args := []string{"build", "-tags", "testgo", "-o", "testgo" + exeSuffix}
+ if race.Enabled {
+ args = append(args, "-race")
+ }
+ out, err := exec.Command("go", args...).CombinedOutput()
if err != nil {
fmt.Fprintf(os.Stderr, "building testgo failed: %v\n%s", err, out)
os.Exit(2)
tg.grepStdout("runtime/internal/sys", "did not find required dependency of "+pkg+" on runtime/internal/sys")
}
}
+
+// For issue 14337.
+func TestParallelTest(t *testing.T) {
+ tg := testgo(t)
+ defer tg.cleanup()
+ tg.makeTempdir()
+ const testSrc = `package package_test
+ import (
+ "testing"
+ )
+ func TestTest(t *testing.T) {
+ }`
+ tg.tempFile("src/p1/p1_test.go", strings.Replace(testSrc, "package_test", "p1_test", 1))
+ tg.tempFile("src/p2/p2_test.go", strings.Replace(testSrc, "package_test", "p2_test", 1))
+ tg.tempFile("src/p3/p3_test.go", strings.Replace(testSrc, "package_test", "p3_test", 1))
+ tg.tempFile("src/p4/p4_test.go", strings.Replace(testSrc, "package_test", "p4_test", 1))
+ tg.setenv("GOPATH", tg.path("."))
+ tg.run("test", "-p=4", "p1", "p2", "p3", "p4")
+}
// mergeEnvLists merges the two environment lists such that
// variables with the same name in "in" replace those in "out".
+// This always returns a newly allocated slice.
func mergeEnvLists(in, out []string) []string {
+ out = append([]string(nil), out...)
NextVar:
for _, inkv := range in {
k := strings.SplitAfterN(inkv, "=", 2)[0]