Make lots of tests run in parallel
Putting t.Parallel() in each test makes them run in parallel.
Additional t.Parallel() could be added to each subtest, although
that requires making a local copy of the loop variable for
table driven tests.
Test: m checkbuild
Change-Id: I5d9869ead441093f4d7c5757f2447385333a95a4
diff --git a/ui/build/cleanbuild_test.go b/ui/build/cleanbuild_test.go
index 89f4ad9..be60362 100644
--- a/ui/build/cleanbuild_test.go
+++ b/ui/build/cleanbuild_test.go
@@ -27,6 +27,7 @@
)
func TestCleanOldFiles(t *testing.T) {
+ t.Parallel()
dir, err := ioutil.TempDir("", "testcleanoldfiles")
if err != nil {
t.Fatal(err)
diff --git a/ui/build/config_test.go b/ui/build/config_test.go
index 7b14c47..35c6ed4 100644
--- a/ui/build/config_test.go
+++ b/ui/build/config_test.go
@@ -39,6 +39,7 @@
}
func TestConfigParseArgsJK(t *testing.T) {
+ t.Parallel()
ctx := testContext()
testCases := []struct {
@@ -111,6 +112,7 @@
}
func TestConfigParseArgsVars(t *testing.T) {
+ t.Parallel()
ctx := testContext()
testCases := []struct {
@@ -638,6 +640,7 @@
}
func TestConfigSplitArgs(t *testing.T) {
+ t.Parallel()
tests := []struct {
// ********* Setup *********
// Test description.
diff --git a/ui/build/environment_test.go b/ui/build/environment_test.go
index 37f500f..d8f83f4 100644
--- a/ui/build/environment_test.go
+++ b/ui/build/environment_test.go
@@ -21,6 +21,7 @@
)
func TestEnvUnset(t *testing.T) {
+ t.Parallel()
initial := &Environment{"TEST=1", "TEST2=0"}
initial.Unset("TEST")
got := initial.Environ()
@@ -30,6 +31,7 @@
}
func TestEnvUnsetMissing(t *testing.T) {
+ t.Parallel()
initial := &Environment{"TEST2=0"}
initial.Unset("TEST")
got := initial.Environ()
@@ -39,6 +41,7 @@
}
func TestEnvSet(t *testing.T) {
+ t.Parallel()
initial := &Environment{}
initial.Set("TEST", "0")
got := initial.Environ()
@@ -48,6 +51,7 @@
}
func TestEnvSetDup(t *testing.T) {
+ t.Parallel()
initial := &Environment{"TEST=1"}
initial.Set("TEST", "0")
got := initial.Environ()
@@ -57,6 +61,7 @@
}
func TestEnvAllow(t *testing.T) {
+ t.Parallel()
initial := &Environment{"TEST=1", "TEST2=0", "TEST3=2"}
initial.Allow("TEST3", "TEST")
got := initial.Environ()
@@ -73,6 +78,7 @@
`
func TestEnvAppendFromKati(t *testing.T) {
+ t.Parallel()
initial := &Environment{"CLANG=/usr/bin/clang", "TEST=0"}
err := initial.appendFromKati(strings.NewReader(testKatiEnvFileContents))
if err != nil {
diff --git a/ui/build/paths/logs_test.go b/ui/build/paths/logs_test.go
index 3b1005f..d5921a8 100644
--- a/ui/build/paths/logs_test.go
+++ b/ui/build/paths/logs_test.go
@@ -26,6 +26,7 @@
)
func TestSendLog(t *testing.T) {
+ t.Parallel()
t.Run("Short name", func(t *testing.T) {
d, err := ioutil.TempDir("", "s")
if err != nil {
@@ -105,6 +106,7 @@
}
func TestSendLogError(t *testing.T) {
+ t.Parallel()
d, err := ioutil.TempDir("", "log_socket")
if err != nil {
t.Fatal(err)
diff --git a/ui/build/proc_sync_test.go b/ui/build/proc_sync_test.go
index 857bea3..1b52fce 100644
--- a/ui/build/proc_sync_test.go
+++ b/ui/build/proc_sync_test.go
@@ -108,6 +108,7 @@
// simple test
func TestGetLock(t *testing.T) {
+ t.Parallel()
lockfile := lockOrFail(t)
defer removeTestLock(lockfile)
}
@@ -119,6 +120,7 @@
var busyStatus = 2
func TestTrylock(t *testing.T) {
+ t.Parallel()
lockpath := os.Getenv(lockPathVariable)
if len(lockpath) < 1 {
checkTrylockMainProcess(t)
@@ -204,6 +206,7 @@
}
func TestLockFirstTrySucceeds(t *testing.T) {
+ t.Parallel()
noopLogger := logger.New(ioutil.Discard)
lock := testLockCountingTo(0)
waiter := newCountWaiter(0)
@@ -216,6 +219,7 @@
}
}
func TestLockThirdTrySucceeds(t *testing.T) {
+ t.Parallel()
noopLogger := logger.New(ioutil.Discard)
lock := testLockCountingTo(2)
waiter := newCountWaiter(2)
@@ -228,6 +232,7 @@
}
}
func TestLockTimedOut(t *testing.T) {
+ t.Parallel()
noopLogger := logger.New(ioutil.Discard)
lock := testLockCountingTo(3)
waiter := newCountWaiter(2)
diff --git a/ui/build/rbe_test.go b/ui/build/rbe_test.go
index 8ff96bc..fa371bb 100644
--- a/ui/build/rbe_test.go
+++ b/ui/build/rbe_test.go
@@ -26,6 +26,7 @@
)
func TestDumpRBEMetrics(t *testing.T) {
+ t.Parallel()
ctx := testContext()
tests := []struct {
description string
@@ -81,6 +82,7 @@
}
func TestDumpRBEMetricsErrors(t *testing.T) {
+ t.Parallel()
ctx := testContext()
tests := []struct {
description string
diff --git a/ui/build/util_test.go b/ui/build/util_test.go
index b22e997..a06c3e9 100644
--- a/ui/build/util_test.go
+++ b/ui/build/util_test.go
@@ -25,6 +25,7 @@
)
func TestEnsureEmptyDirs(t *testing.T) {
+ t.Parallel()
ctx := testContext()
defer logger.Recover(func(err error) {
t.Error(err)
@@ -52,6 +53,7 @@
}
func TestCopyFile(t *testing.T) {
+ t.Parallel()
tmpDir, err := ioutil.TempDir("", "test_copy_file")
if err != nil {
t.Fatalf("failed to create temporary directory to hold test text files: %v", err)
@@ -86,6 +88,7 @@
}
func TestCopyFileErrors(t *testing.T) {
+ t.Parallel()
tmpDir, err := ioutil.TempDir("", "test_copy_file_errors")
if err != nil {
t.Fatalf("failed to create temporary directory to hold test text files: %v", err)