diff options
| author | Bryan C. Mills <bcmills@google.com> | 2022-10-05 15:21:06 -0400 |
|---|---|---|
| committer | Gopher Robot <gobot@golang.org> | 2022-10-06 19:09:18 +0000 |
| commit | 515e3de2999b23da28e6d15ac485bfdd299ec83a (patch) | |
| tree | c0ec299f24c09bb1e345d06cbf07e7fb58be27a4 /src/os/exec/lp_windows_test.go | |
| parent | 274d3a06f7331740b849e20cff1d1c1ab84dd0e0 (diff) | |
| download | go-515e3de2999b23da28e6d15ac485bfdd299ec83a.tar.xz | |
os/exec: parallelize more tests
This cuts the wall duration for 'go test os/exec' and
'go test -race os/exec' roughly in half on my machine,
which is an even more significant speedup with a high '-count'.
For better or for worse, it may also increase the repro rate
of #34988.
Tests that use Setenv or Chdir or check for FDs opened during the test
still cannot be parallelized, but they are only a few of those.
Change-Id: I8d284d8bff05787853f825ef144aeb7a4126847f
Reviewed-on: https://go-review.googlesource.com/c/go/+/439196
TryBot-Result: Gopher Robot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Run-TryBot: Bryan Mills <bcmills@google.com>
Auto-Submit: Bryan Mills <bcmills@google.com>
Diffstat (limited to 'src/os/exec/lp_windows_test.go')
| -rw-r--r-- | src/os/exec/lp_windows_test.go | 32 |
1 files changed, 26 insertions, 6 deletions
diff --git a/src/os/exec/lp_windows_test.go b/src/os/exec/lp_windows_test.go index 1f609fffd0..d797b6c53c 100644 --- a/src/os/exec/lp_windows_test.go +++ b/src/os/exec/lp_windows_test.go @@ -334,12 +334,21 @@ var lookPathTests = []lookPathTest{ } func TestLookPathWindows(t *testing.T) { + if testing.Short() { + maySkipHelperCommand("lookpath") + t.Skipf("skipping test in short mode that would build a helper binary") + } + t.Parallel() + tmp := t.TempDir() printpathExe := buildPrintPathExe(t, tmp) // Run all tests. for i, test := range lookPathTests { + i, test := i, test t.Run(fmt.Sprint(i), func(t *testing.T) { + t.Parallel() + dir := filepath.Join(tmp, "d"+strconv.Itoa(i)) err := os.Mkdir(dir, 0700) if err != nil { @@ -524,17 +533,28 @@ var commandTests = []commandTest{ } func TestCommand(t *testing.T) { + if testing.Short() { + maySkipHelperCommand("exec") + t.Skipf("skipping test in short mode that would build a helper binary") + } + t.Parallel() + tmp := t.TempDir() printpathExe := buildPrintPathExe(t, tmp) // Run all tests. for i, test := range commandTests { - dir := filepath.Join(tmp, "d"+strconv.Itoa(i)) - err := os.Mkdir(dir, 0700) - if err != nil { - t.Fatal("Mkdir failed: ", err) - } - test.run(t, dir, printpathExe) + i, test := i, test + t.Run(fmt.Sprint(i), func(t *testing.T) { + t.Parallel() + + dir := filepath.Join(tmp, "d"+strconv.Itoa(i)) + err := os.Mkdir(dir, 0700) + if err != nil { + t.Fatal("Mkdir failed: ", err) + } + test.run(t, dir, printpathExe) + }) } } |
