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/android/androidmk_test.go b/android/androidmk_test.go
index a558f45..8574dc9 100644
--- a/android/androidmk_test.go
+++ b/android/androidmk_test.go
@@ -68,6 +68,7 @@
}
func TestAndroidMkSingleton_PassesUpdatedAndroidMkDataToCustomCallback(t *testing.T) {
+ t.Parallel()
bp := `
custom {
name: "foo",
@@ -103,6 +104,7 @@
}
func TestGetDistForGoals(t *testing.T) {
+ t.Parallel()
testCases := []struct {
bp string
expectedAndroidMkLines []string
diff --git a/android/apex_test.go b/android/apex_test.go
index 512b50f..7507628 100644
--- a/android/apex_test.go
+++ b/android/apex_test.go
@@ -20,6 +20,7 @@
)
func Test_mergeApexVariations(t *testing.T) {
+ t.Parallel()
tests := []struct {
name string
in []ApexInfo
diff --git a/android/arch_test.go b/android/arch_test.go
index 8525b03..7ec050f 100644
--- a/android/arch_test.go
+++ b/android/arch_test.go
@@ -36,6 +36,7 @@
}
func TestFilterArchStruct(t *testing.T) {
+ t.Parallel()
tests := []struct {
name string
in interface{}
@@ -274,6 +275,7 @@
}
func TestArchMutator(t *testing.T) {
+ t.Parallel()
var buildOSVariants []string
var buildOS32Variants []string
switch runtime.GOOS {
@@ -385,6 +387,7 @@
}
func TestArchMutatorNativeBridge(t *testing.T) {
+ t.Parallel()
bp := `
// This module is only enabled for x86.
module {
diff --git a/android/config_test.go b/android/config_test.go
index 274d59f..0c907b7 100644
--- a/android/config_test.go
+++ b/android/config_test.go
@@ -58,6 +58,7 @@
// tests that ValidateConfigAnnotation works
func TestValidateConfigAnnotations(t *testing.T) {
+ t.Parallel()
config := configType{}
err := validateConfigAnnotations(&config)
expectedError := `Field configType.PopulateMe has tag json:"omitempty" which specifies to change its json field name to "omitempty".
@@ -74,6 +75,7 @@
// run validateConfigAnnotations against each type that might have json annotations
func TestProductConfigAnnotations(t *testing.T) {
+ t.Parallel()
err := validateConfigAnnotations(&productVariables{})
if err != nil {
t.Errorf(err.Error())
@@ -86,6 +88,7 @@
}
func TestMissingVendorConfig(t *testing.T) {
+ t.Parallel()
c := &config{}
if c.VendorConfig("test").Bool("not_set") {
t.Errorf("Expected false")
diff --git a/android/csuite_config_test.go b/android/csuite_config_test.go
index bf1a19a..ec93ed6 100644
--- a/android/csuite_config_test.go
+++ b/android/csuite_config_test.go
@@ -32,6 +32,7 @@
}
func TestCSuiteConfig(t *testing.T) {
+ t.Parallel()
ctx := testCSuiteConfig(t, `
csuite_config { name: "plain"}
csuite_config { name: "with_manifest", test_config: "manifest.xml" }
diff --git a/android/defaults_test.go b/android/defaults_test.go
index d096b2f..a6abe8f 100644
--- a/android/defaults_test.go
+++ b/android/defaults_test.go
@@ -59,6 +59,7 @@
}
func TestDefaults(t *testing.T) {
+ t.Parallel()
bp := `
defaults {
name: "transitive",
@@ -102,6 +103,7 @@
}
func TestDefaultsAllowMissingDependencies(t *testing.T) {
+ t.Parallel()
bp := `
defaults {
name: "defaults",
diff --git a/android/depset_test.go b/android/depset_test.go
index c328127..1ad27eb 100644
--- a/android/depset_test.go
+++ b/android/depset_test.go
@@ -64,6 +64,7 @@
// Tests based on Bazel's ExpanderTestBase.java to ensure compatibility
// https://github.com/bazelbuild/bazel/blob/master/src/test/java/com/google/devtools/build/lib/collect/nestedset/ExpanderTestBase.java
func TestDepSet(t *testing.T) {
+ t.Parallel()
a := PathForTesting("a")
b := PathForTesting("b")
c := PathForTesting("c")
@@ -274,6 +275,7 @@
}
func TestDepSetInvalidOrder(t *testing.T) {
+ t.Parallel()
orders := []DepSetOrder{POSTORDER, PREORDER, TOPOLOGICAL}
run := func(t *testing.T, order1, order2 DepSetOrder) {
diff --git a/android/expand_test.go b/android/expand_test.go
index 12179ed..7992288 100644
--- a/android/expand_test.go
+++ b/android/expand_test.go
@@ -163,6 +163,7 @@
}
func TestExpand(t *testing.T) {
+ t.Parallel()
for _, test := range expandTestCases {
got, err := Expand(test.in, func(s string) (string, error) {
s, _, err := expander(s)
@@ -179,6 +180,7 @@
}
func TestExpandNinjaEscaped(t *testing.T) {
+ t.Parallel()
for _, test := range expandTestCases {
got, err := ExpandNinjaEscaped(test.in, expander)
if err != nil && !test.err {
diff --git a/android/module_test.go b/android/module_test.go
index 6e648d7..b2a41e4 100644
--- a/android/module_test.go
+++ b/android/module_test.go
@@ -19,6 +19,7 @@
)
func TestSrcIsModule(t *testing.T) {
+ t.Parallel()
type args struct {
s string
}
@@ -66,6 +67,7 @@
}
func TestSrcIsModuleWithTag(t *testing.T) {
+ t.Parallel()
type args struct {
s string
}
@@ -164,6 +166,7 @@
}
func TestErrorDependsOnDisabledModule(t *testing.T) {
+ t.Parallel()
ctx := NewTestContext()
ctx.RegisterModuleType("deps", depsModuleFactory)
diff --git a/android/mutator_test.go b/android/mutator_test.go
index 191b535..ce073bf 100644
--- a/android/mutator_test.go
+++ b/android/mutator_test.go
@@ -59,6 +59,7 @@
}
func TestMutatorAddMissingDependencies(t *testing.T) {
+ t.Parallel()
bp := `
test {
name: "foo",
@@ -92,6 +93,7 @@
}
func TestModuleString(t *testing.T) {
+ t.Parallel()
ctx := NewTestContext()
var moduleStrings []string
@@ -190,6 +192,7 @@
}
func TestFinalDepsPhase(t *testing.T) {
+ t.Parallel()
ctx := NewTestContext()
finalGot := map[string]int{}
@@ -267,6 +270,7 @@
}
func TestNoCreateVariationsInFinalDeps(t *testing.T) {
+ t.Parallel()
ctx := NewTestContext()
checkErr := func() {
diff --git a/android/namespace_test.go b/android/namespace_test.go
index 66c0d89..5cce3e4 100644
--- a/android/namespace_test.go
+++ b/android/namespace_test.go
@@ -24,6 +24,7 @@
)
func TestDependingOnModuleInSameNamespace(t *testing.T) {
+ t.Parallel()
ctx := setupTest(t,
map[string]string{
"dir1": `
@@ -48,6 +49,7 @@
}
func TestDependingOnModuleInRootNamespace(t *testing.T) {
+ t.Parallel()
ctx := setupTest(t,
map[string]string{
".": `
@@ -70,6 +72,7 @@
}
func TestImplicitlyImportRootNamespace(t *testing.T) {
+ t.Parallel()
_ = setupTest(t,
map[string]string{
".": `
@@ -92,6 +95,7 @@
}
func TestDependingOnBlueprintModuleInRootNamespace(t *testing.T) {
+ t.Parallel()
_ = setupTest(t,
map[string]string{
".": `
@@ -114,6 +118,7 @@
}
func TestDependingOnModuleInImportedNamespace(t *testing.T) {
+ t.Parallel()
ctx := setupTest(t,
map[string]string{
"dir1": `
@@ -143,6 +148,7 @@
}
func TestDependingOnModuleInNonImportedNamespace(t *testing.T) {
+ t.Parallel()
_, errs := setupTestExpectErrs(
map[string]string{
"dir1": `
@@ -183,6 +189,7 @@
}
func TestDependingOnModuleByFullyQualifiedReference(t *testing.T) {
+ t.Parallel()
ctx := setupTest(t,
map[string]string{
"dir1": `
@@ -210,6 +217,7 @@
}
func TestSameNameInTwoNamespaces(t *testing.T) {
+ t.Parallel()
ctx := setupTest(t,
map[string]string{
"dir1": `
@@ -260,6 +268,7 @@
}
func TestSearchOrder(t *testing.T) {
+ t.Parallel()
ctx := setupTest(t,
map[string]string{
"dir1": `
@@ -348,6 +357,7 @@
}
func TestTwoNamespacesCanImportEachOther(t *testing.T) {
+ t.Parallel()
_ = setupTest(t,
map[string]string{
"dir1": `
@@ -378,6 +388,7 @@
}
func TestImportingNonexistentNamespace(t *testing.T) {
+ t.Parallel()
_, errs := setupTestExpectErrs(
map[string]string{
"dir1": `
@@ -402,6 +413,7 @@
}
func TestNamespacesDontInheritParentNamespaces(t *testing.T) {
+ t.Parallel()
_, errs := setupTestExpectErrs(
map[string]string{
"dir1": `
@@ -433,6 +445,7 @@
}
func TestModulesDoReceiveParentNamespace(t *testing.T) {
+ t.Parallel()
_ = setupTest(t,
map[string]string{
"dir1": `
@@ -455,6 +468,7 @@
}
func TestNamespaceImportsNotTransitive(t *testing.T) {
+ t.Parallel()
_, errs := setupTestExpectErrs(
map[string]string{
"dir1": `
@@ -496,6 +510,7 @@
}
func TestTwoNamepacesInSameDir(t *testing.T) {
+ t.Parallel()
_, errs := setupTestExpectErrs(
map[string]string{
"dir1": `
@@ -516,6 +531,7 @@
}
func TestNamespaceNotAtTopOfFile(t *testing.T) {
+ t.Parallel()
_, errs := setupTestExpectErrs(
map[string]string{
"dir1": `
@@ -537,6 +553,7 @@
}
func TestTwoModulesWithSameNameInSameNamespace(t *testing.T) {
+ t.Parallel()
_, errs := setupTestExpectErrs(
map[string]string{
"dir1": `
@@ -562,6 +579,7 @@
}
func TestDeclaringNamespaceInNonAndroidBpFile(t *testing.T) {
+ t.Parallel()
_, errs := setupTestFromFiles(
map[string][]byte{
"Android.bp": []byte(`
@@ -585,6 +603,7 @@
// so that the generated .ninja file will have consistent names
func TestConsistentNamespaceNames(t *testing.T) {
+ t.Parallel()
ctx := setupTest(t,
map[string]string{
"dir1": "soong_namespace{}",
@@ -604,6 +623,7 @@
// so that the generated .ninja file will have consistent names
func TestRename(t *testing.T) {
+ t.Parallel()
_ = setupTest(t,
map[string]string{
"dir1": `
diff --git a/android/neverallow_test.go b/android/neverallow_test.go
index 56a07dc..306c509 100644
--- a/android/neverallow_test.go
+++ b/android/neverallow_test.go
@@ -343,6 +343,7 @@
}
func TestNeverallow(t *testing.T) {
+ t.Parallel()
for _, test := range neverallowTests {
// Create a test per config to allow for test specific config, e.g. test rules.
config := TestConfig(buildDir, nil, "", test.fs)
diff --git a/android/onceper_test.go b/android/onceper_test.go
index 1a55ff4..da0b10d 100644
--- a/android/onceper_test.go
+++ b/android/onceper_test.go
@@ -20,6 +20,7 @@
)
func TestOncePer_Once(t *testing.T) {
+ t.Parallel()
once := OncePer{}
key := NewOnceKey("key")
@@ -36,6 +37,7 @@
}
func TestOncePer_Once_wait(t *testing.T) {
+ t.Parallel()
once := OncePer{}
key := NewOnceKey("key")
@@ -51,6 +53,7 @@
}
func TestOncePer_Get(t *testing.T) {
+ t.Parallel()
once := OncePer{}
key := NewOnceKey("key")
@@ -67,6 +70,7 @@
}
func TestOncePer_Get_panic(t *testing.T) {
+ t.Parallel()
once := OncePer{}
key := NewOnceKey("key")
@@ -82,6 +86,7 @@
}
func TestOncePer_Get_wait(t *testing.T) {
+ t.Parallel()
once := OncePer{}
key := NewOnceKey("key")
@@ -97,6 +102,7 @@
}
func TestOncePer_OnceStringSlice(t *testing.T) {
+ t.Parallel()
once := OncePer{}
key := NewOnceKey("key")
@@ -113,6 +119,7 @@
}
func TestOncePer_Once2StringSlice(t *testing.T) {
+ t.Parallel()
once := OncePer{}
key := NewOnceKey("key")
@@ -129,6 +136,7 @@
}
func TestNewOnceKey(t *testing.T) {
+ t.Parallel()
once := OncePer{}
key1 := NewOnceKey("key")
key2 := NewOnceKey("key")
@@ -146,6 +154,7 @@
}
func TestNewCustomOnceKey(t *testing.T) {
+ t.Parallel()
type key struct {
key string
}
@@ -166,6 +175,7 @@
}
func TestOncePerReentrant(t *testing.T) {
+ t.Parallel()
once := OncePer{}
key1 := NewOnceKey("key")
key2 := NewOnceKey("key")
@@ -178,6 +188,7 @@
// Test that a recovered panic in a Once function doesn't deadlock
func TestOncePerPanic(t *testing.T) {
+ t.Parallel()
once := OncePer{}
key := NewOnceKey("key")
diff --git a/android/package_test.go b/android/package_test.go
index 04dfc08..a4b4c60 100644
--- a/android/package_test.go
+++ b/android/package_test.go
@@ -56,6 +56,7 @@
}
func TestPackage(t *testing.T) {
+ t.Parallel()
for _, test := range packageTests {
t.Run(test.name, func(t *testing.T) {
_, errs := testPackage(test.fs)
diff --git a/android/path_properties_test.go b/android/path_properties_test.go
index f367b82..9bbb571 100644
--- a/android/path_properties_test.go
+++ b/android/path_properties_test.go
@@ -59,6 +59,7 @@
}
func TestPathDepsMutator(t *testing.T) {
+ t.Parallel()
tests := []struct {
name string
bp string
diff --git a/android/paths_test.go b/android/paths_test.go
index d099f65..03e1410 100644
--- a/android/paths_test.go
+++ b/android/paths_test.go
@@ -110,6 +110,7 @@
}...)
func TestValidateSafePath(t *testing.T) {
+ t.Parallel()
for _, testCase := range validateSafePathTestCases {
t.Run(strings.Join(testCase.in, ","), func(t *testing.T) {
ctx := &configErrorWrapper{}
@@ -123,6 +124,7 @@
}
func TestValidatePath(t *testing.T) {
+ t.Parallel()
for _, testCase := range validatePathTestCases {
t.Run(strings.Join(testCase.in, ","), func(t *testing.T) {
ctx := &configErrorWrapper{}
@@ -136,6 +138,7 @@
}
func TestOptionalPath(t *testing.T) {
+ t.Parallel()
var path OptionalPath
checkInvalidOptionalPath(t, path)
@@ -253,6 +256,7 @@
}
func TestPathForModuleInstall(t *testing.T) {
+ t.Parallel()
testConfig := pathTestConfig("")
hostTarget := Target{Os: Linux, Arch: Arch{ArchType: X86}}
@@ -657,6 +661,7 @@
}
func TestDirectorySortedPaths(t *testing.T) {
+ t.Parallel()
config := TestConfig("out", nil, "", map[string][]byte{
"Android.bp": nil,
"a.txt": nil,
@@ -739,6 +744,7 @@
}
func TestMaybeRel(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
base string
@@ -796,6 +802,7 @@
}
func TestPathForSource(t *testing.T) {
+ t.Parallel()
testCases := []struct {
name string
buildDir string
@@ -1028,6 +1035,7 @@
}
func TestPathsForModuleSrc(t *testing.T) {
+ t.Parallel()
tests := []pathForModuleSrcTestCase{
{
name: "path",
@@ -1123,6 +1131,7 @@
}
func TestPathForModuleSrc(t *testing.T) {
+ t.Parallel()
tests := []pathForModuleSrcTestCase{
{
name: "path",
@@ -1190,6 +1199,7 @@
}
func TestPathsForModuleSrc_AllowMissingDependencies(t *testing.T) {
+ t.Parallel()
bp := `
test {
name: "foo",
diff --git a/android/prebuilt_test.go b/android/prebuilt_test.go
index 854395e..40fced8 100644
--- a/android/prebuilt_test.go
+++ b/android/prebuilt_test.go
@@ -262,6 +262,7 @@
}
func TestPrebuilts(t *testing.T) {
+ t.Parallel()
fs := map[string][]byte{
"prebuilt_file": nil,
"source_file": nil,
diff --git a/android/rule_builder_test.go b/android/rule_builder_test.go
index c41b067..d205a5b 100644
--- a/android/rule_builder_test.go
+++ b/android/rule_builder_test.go
@@ -264,6 +264,7 @@
}
func TestRuleBuilder(t *testing.T) {
+ t.Parallel()
fs := map[string][]byte{
"dep_fixer": nil,
"input": nil,
@@ -455,6 +456,7 @@
}
func TestRuleBuilder_Build(t *testing.T) {
+ t.Parallel()
fs := map[string][]byte{
"bar": nil,
"cp": nil,
@@ -546,6 +548,7 @@
}
func Test_ninjaEscapeExceptForSpans(t *testing.T) {
+ t.Parallel()
type args struct {
s string
spans [][2]int
diff --git a/android/soong_config_modules_test.go b/android/soong_config_modules_test.go
index f905b1a..f0f1462 100644
--- a/android/soong_config_modules_test.go
+++ b/android/soong_config_modules_test.go
@@ -38,6 +38,7 @@
func (t soongConfigTestModule) GenerateAndroidBuildActions(ModuleContext) {}
func TestSoongConfigModule(t *testing.T) {
+ t.Parallel()
configBp := `
soong_config_module_type {
name: "acme_test_defaults",
diff --git a/android/soongconfig/modules_test.go b/android/soongconfig/modules_test.go
index 4190016..ff4883e 100644
--- a/android/soongconfig/modules_test.go
+++ b/android/soongconfig/modules_test.go
@@ -20,6 +20,7 @@
)
func Test_CanonicalizeToProperty(t *testing.T) {
+ t.Parallel()
tests := []struct {
name string
arg string
@@ -66,6 +67,7 @@
}
func Test_typeForPropertyFromPropertyStruct(t *testing.T) {
+ t.Parallel()
tests := []struct {
name string
ps interface{}
@@ -186,6 +188,7 @@
}
func Test_createAffectablePropertiesType(t *testing.T) {
+ t.Parallel()
tests := []struct {
name string
affectableProperties []string
diff --git a/android/util_test.go b/android/util_test.go
index 25b52ca..8c42157 100644
--- a/android/util_test.go
+++ b/android/util_test.go
@@ -60,6 +60,7 @@
}
func TestFirstUniqueStrings(t *testing.T) {
+ t.Parallel()
f := func(t *testing.T, imp func([]string) []string, in, want []string) {
t.Helper()
out := imp(in)
@@ -120,6 +121,7 @@
}
func TestLastUniqueStrings(t *testing.T) {
+ t.Parallel()
for _, testCase := range lastUniqueStringsTestCases {
out := LastUniqueStrings(testCase.in)
if !reflect.DeepEqual(out, testCase.out) {
@@ -132,6 +134,7 @@
}
func TestJoinWithPrefix(t *testing.T) {
+ t.Parallel()
testcases := []struct {
name string
input []string
@@ -171,6 +174,7 @@
}
func TestIndexList(t *testing.T) {
+ t.Parallel()
input := []string{"a", "b", "c"}
testcases := []struct {
@@ -210,6 +214,7 @@
}
func TestInList(t *testing.T) {
+ t.Parallel()
input := []string{"a"}
testcases := []struct {
@@ -241,6 +246,7 @@
}
func TestPrefixInList(t *testing.T) {
+ t.Parallel()
prefixes := []string{"a", "b"}
testcases := []struct {
@@ -276,6 +282,7 @@
}
func TestFilterList(t *testing.T) {
+ t.Parallel()
input := []string{"a", "b", "c", "c", "b", "d", "a"}
filter := []string{"a", "c"}
remainder, filtered := FilterList(input, filter)
@@ -300,6 +307,7 @@
}
func TestRemoveListFromList(t *testing.T) {
+ t.Parallel()
input := []string{"a", "b", "c", "d", "a", "c", "d"}
filter := []string{"a", "c"}
expected := []string{"b", "d", "d"}
@@ -314,6 +322,7 @@
}
func TestRemoveFromList(t *testing.T) {
+ t.Parallel()
testcases := []struct {
name string
key string
@@ -417,6 +426,7 @@
}
func TestSplitFileExt(t *testing.T) {
+ t.Parallel()
t.Run("soname with version", func(t *testing.T) {
root, suffix, ext := SplitFileExt("libtest.so.1.0.30")
expected := "libtest"
@@ -482,6 +492,7 @@
}
func Test_Shard(t *testing.T) {
+ t.Parallel()
type args struct {
strings []string
shardSize int
diff --git a/android/variable_test.go b/android/variable_test.go
index 9cafedd..9348b0d 100644
--- a/android/variable_test.go
+++ b/android/variable_test.go
@@ -112,6 +112,7 @@
}
func TestPrintfIntoProperty(t *testing.T) {
+ t.Parallel()
for _, testCase := range printfIntoPropertyTestCases {
s := testCase.in
v := reflect.ValueOf(&s).Elem()
@@ -157,6 +158,7 @@
}
func TestProductVariables(t *testing.T) {
+ t.Parallel()
ctx := NewTestContext()
// A module type that has a srcs property but not a cflags property.
ctx.RegisterModuleType("module1", testProductVariableModuleFactoryFactory(&struct {
@@ -265,6 +267,7 @@
// Test a defaults module that supports more product variable properties than the target module.
func TestProductVariablesDefaults(t *testing.T) {
+ t.Parallel()
bp := `
defaults {
name: "defaults",
diff --git a/android/visibility_test.go b/android/visibility_test.go
index 9d9e574..8de5fa9 100644
--- a/android/visibility_test.go
+++ b/android/visibility_test.go
@@ -1140,6 +1140,7 @@
}
func TestVisibility(t *testing.T) {
+ t.Parallel()
for _, test := range visibilityTests {
t.Run(test.name, func(t *testing.T) {
ctx, errs := testVisibility(buildDir, test.fs)
diff --git a/android/vts_config_test.go b/android/vts_config_test.go
index 254fa92..a95e589 100644
--- a/android/vts_config_test.go
+++ b/android/vts_config_test.go
@@ -32,6 +32,7 @@
}
func TestVtsConfig(t *testing.T) {
+ t.Parallel()
ctx := testVtsConfig(t, `
vts_config { name: "plain"}
vts_config { name: "with_manifest", test_config: "manifest.xml" }