Skip to content

Commit

Permalink
cmd/go: parallellize more test cases
Browse files Browse the repository at this point in the history
Sprinkle in some more calls to tg.Parallel in the cmd/go
tests. These are the easy cases that don't operate in the
testdata directory.

I think the best thing to do for those tests that do operate
in testdata is to use the script tests. They're easier to
read and write, and jump into t.Parallel immediately.

Updates #17751

Change-Id: If8aeb8129cfdc0a9aa91f5a540f179790077fce5
Reviewed-on: https://go-review.googlesource.com/c/go/+/212618
Run-TryBot: Michael Matloob <[email protected]>
TryBot-Result: Gobot Gobot <[email protected]>
Reviewed-by: Jay Conrod <[email protected]>
  • Loading branch information
matloob committed Jan 6, 2020
1 parent db66972 commit 57b22c5
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/cmd/go/go_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -913,6 +913,7 @@ func TestNewReleaseRebuildsStalePackagesInGOPATH(t *testing.T) {

tg := testgo(t)
defer tg.cleanup()
tg.parallel()

// Copy the runtime packages into a temporary GOROOT
// so that we can change files.
Expand Down Expand Up @@ -1641,6 +1642,7 @@ func TestDefaultGOPATHGet(t *testing.T) {

tg := testgo(t)
defer tg.cleanup()
tg.parallel()
tg.setenv("GOPATH", "")
tg.tempDir("home")
tg.setenv(homeEnvName(), tg.path("home"))
Expand All @@ -1665,6 +1667,7 @@ func TestDefaultGOPATHGet(t *testing.T) {
func TestDefaultGOPATHPrintedSearchList(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
tg.setenv("GOPATH", "")
tg.tempDir("home")
tg.setenv(homeEnvName(), tg.path("home"))
Expand Down Expand Up @@ -2363,6 +2366,8 @@ func TestCgoDependsOnSyscall(t *testing.T) {

tg := testgo(t)
defer tg.cleanup()
tg.parallel()

files, err := filepath.Glob(filepath.Join(runtime.GOROOT(), "pkg", "*_race"))
tg.must(err)
for _, file := range files {
Expand Down Expand Up @@ -3724,7 +3729,7 @@ func TestMatchesOnlyBenchmarkIsOK(t *testing.T) {
func TestBenchmarkLabels(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
// TODO: tg.parallel()
tg.parallel()
tg.setenv("GOPATH", filepath.Join(tg.pwd(), "testdata"))
tg.run("test", "-run", "^$", "-bench", ".", "bench")
tg.grepStdout(`(?m)^goos: `+runtime.GOOS, "go test did not print goos")
Expand Down Expand Up @@ -4279,6 +4284,7 @@ func TestBuildmodePIE(t *testing.T) {

tg := testgo(t)
defer tg.cleanup()
tg.parallel()

tg.tempFile("main.go", `package main; func main() { print("hello") }`)
src := tg.path("main.go")
Expand Down Expand Up @@ -4442,6 +4448,7 @@ func TestUpxCompression(t *testing.T) {

tg := testgo(t)
defer tg.cleanup()
tg.parallel()

tg.tempFile("main.go", `package main; import "fmt"; func main() { fmt.Print("hello upx") }`)
src := tg.path("main.go")
Expand Down Expand Up @@ -4980,6 +4987,7 @@ func init() {}
func TestBadCommandLines(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.parallel()

tg.tempFile("src/x/x.go", "package x\n")
tg.setenv("GOPATH", tg.path("."))
Expand Down Expand Up @@ -5200,6 +5208,7 @@ func TestCgoCache(t *testing.T) {
func TestFilepathUnderCwdFormat(t *testing.T) {
tg := testgo(t)
defer tg.cleanup()
tg.parallel()
tg.run("test", "-x", "-cover", "log")
tg.grepStderrNot(`\.log\.cover\.go`, "-x output should contain correctly formatted filepath under cwd")
}
Expand Down

0 comments on commit 57b22c5

Please sign in to comment.