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/java/androidmk_test.go b/java/androidmk_test.go
index 075b7aa..359d8d7 100644
--- a/java/androidmk_test.go
+++ b/java/androidmk_test.go
@@ -23,6 +23,7 @@
 )
 
 func TestRequired(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_library {
 			name: "foo",
@@ -42,6 +43,7 @@
 }
 
 func TestHostdex(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_library {
 			name: "foo",
@@ -72,6 +74,7 @@
 }
 
 func TestHostdexRequired(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_library {
 			name: "foo",
@@ -103,6 +106,7 @@
 }
 
 func TestHostdexSpecificRequired(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_library {
 			name: "foo",
@@ -136,6 +140,7 @@
 }
 
 func TestDistWithTag(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_library {
 			name: "foo_without_tag",
@@ -172,6 +177,7 @@
 }
 
 func TestDistWithDest(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_library {
 			name: "foo",
@@ -208,6 +214,7 @@
 }
 
 func TestDistsWithAllProperties(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_library {
 			name: "foo",
@@ -265,6 +272,7 @@
 }
 
 func TestDistsWithTag(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_library {
 			name: "foo_without_tag",
@@ -312,6 +320,7 @@
 }
 
 func TestJavaSdkLibrary_RequireXmlPermissionFile(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_sdk_library {
 			name: "foo-shared_library",
diff --git a/java/app_test.go b/java/app_test.go
index 4347db8..2ee3d15 100644
--- a/java/app_test.go
+++ b/java/app_test.go
@@ -67,6 +67,7 @@
 }
 
 func TestApp(t *testing.T) {
+	t.Parallel()
 	for _, moduleType := range []string{"android_app", "android_library"} {
 		t.Run(moduleType, func(t *testing.T) {
 			ctx := testApp(t, moduleType+` {
@@ -113,6 +114,7 @@
 }
 
 func TestAppSplits(t *testing.T) {
+	t.Parallel()
 	ctx := testApp(t, `
 				android_app {
 					name: "foo",
@@ -142,6 +144,7 @@
 }
 
 func TestAndroidAppSet(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		android_app_set {
 			name: "foo",
@@ -170,6 +173,7 @@
 }
 
 func TestAndroidAppSet_Variants(t *testing.T) {
+	t.Parallel()
 	bp := `
 		android_app_set {
 			name: "foo",
@@ -235,6 +239,7 @@
 }
 
 func TestPlatformAPIs(t *testing.T) {
+	t.Parallel()
 	testJava(t, `
 		android_app {
 			name: "foo",
@@ -269,6 +274,7 @@
 }
 
 func TestAndroidAppLinkType(t *testing.T) {
+	t.Parallel()
 	testJava(t, `
 		android_app {
 			name: "foo",
@@ -358,6 +364,7 @@
 }
 
 func TestUpdatableApps(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name          string
 		bp            string
@@ -479,6 +486,7 @@
 }
 
 func TestUpdatableApps_TransitiveDepsShouldSetMinSdkVersion(t *testing.T) {
+	t.Parallel()
 	testJavaError(t, `module "bar".*: should support min_sdk_version\(29\)`, cc.GatherRequiredDepsForTest(android.Android)+`
 		android_app {
 			name: "foo",
@@ -497,6 +505,7 @@
 }
 
 func TestUpdatableApps_JniLibsShouldShouldSupportMinSdkVersion(t *testing.T) {
+	t.Parallel()
 	testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
 		android_app {
 			name: "foo",
@@ -517,6 +526,7 @@
 }
 
 func TestUpdatableApps_JniLibShouldBeBuiltAgainstMinSdkVersion(t *testing.T) {
+	t.Parallel()
 	bp := cc.GatherRequiredDepsForTest(android.Android) + `
 		android_app {
 			name: "foo",
@@ -571,6 +581,7 @@
 }
 
 func TestUpdatableApps_ErrorIfJniLibDoesntSupportMinSdkVersion(t *testing.T) {
+	t.Parallel()
 	bp := cc.GatherRequiredDepsForTest(android.Android) + `
 		android_app {
 			name: "foo",
@@ -591,6 +602,7 @@
 }
 
 func TestUpdatableApps_ErrorIfDepSdkVersionIsHigher(t *testing.T) {
+	t.Parallel()
 	bp := cc.GatherRequiredDepsForTest(android.Android) + `
 		android_app {
 			name: "foo",
@@ -620,6 +632,7 @@
 }
 
 func TestResourceDirs(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name      string
 		prop      string
@@ -679,6 +692,7 @@
 }
 
 func TestLibraryAssets(t *testing.T) {
+	t.Parallel()
 	bp := `
 			android_app {
 				name: "foo",
@@ -780,6 +794,7 @@
 }
 
 func TestAndroidResources(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name                       string
 		enforceRROTargets          []string
@@ -1070,6 +1085,7 @@
 }
 
 func TestAppSdkVersion(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name                  string
 		sdkVersion            string
@@ -1152,6 +1168,7 @@
 }
 
 func TestVendorAppSdkVersion(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name                                  string
 		sdkVersion                            string
@@ -1215,6 +1232,7 @@
 }
 
 func TestJNIABI(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
 		cc_library {
 			name: "libjni",
@@ -1289,6 +1307,7 @@
 }
 
 func TestAppSdkVersionByPartition(t *testing.T) {
+	t.Parallel()
 	testJavaError(t, "sdk_version must have a value when the module is located at vendor or product", `
 		android_app {
 			name: "foo",
@@ -1327,6 +1346,7 @@
 }
 
 func TestJNIPackaging(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
 		cc_library {
 			name: "libjni",
@@ -1418,6 +1438,7 @@
 }
 
 func TestJNISDK(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
 		cc_library {
 			name: "libjni",
@@ -1535,6 +1556,7 @@
 }
 
 func TestCertificates(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name                string
 		bp                  string
@@ -1655,6 +1677,7 @@
 }
 
 func TestRequestV4SigningFlag(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name     string
 		bp       string
@@ -1715,6 +1738,7 @@
 }
 
 func TestPackageNameOverride(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name                string
 		bp                  string
@@ -1780,6 +1804,7 @@
 }
 
 func TestInstrumentationTargetOverridden(t *testing.T) {
+	t.Parallel()
 	bp := `
 		android_app {
 			name: "foo",
@@ -1809,6 +1834,7 @@
 }
 
 func TestOverrideAndroidApp(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		android_app {
 			name: "foo",
@@ -2010,6 +2036,7 @@
 }
 
 func TestOverrideAndroidAppDependency(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		android_app {
 			name: "foo",
@@ -2052,6 +2079,7 @@
 }
 
 func TestOverrideAndroidTest(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		android_app {
 			name: "foo",
@@ -2148,6 +2176,7 @@
 }
 
 func TestAndroidTest_FixTestConfig(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		android_app {
 			name: "foo",
@@ -2229,6 +2258,7 @@
 }
 
 func TestAndroidAppImport(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		android_app_import {
 			name: "foo",
@@ -2258,6 +2288,7 @@
 }
 
 func TestAndroidAppImport_NoDexPreopt(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		android_app_import {
 			name: "foo",
@@ -2279,6 +2310,7 @@
 }
 
 func TestAndroidAppImport_Presigned(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		android_app_import {
 			name: "foo",
@@ -2307,6 +2339,7 @@
 }
 
 func TestAndroidAppImport_SigningLineage(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 	  android_app_import {
 			name: "foo",
@@ -2328,6 +2361,7 @@
 }
 
 func TestAndroidAppImport_DefaultDevCert(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		android_app_import {
 			name: "foo",
@@ -2357,6 +2391,7 @@
 }
 
 func TestAndroidAppImport_DpiVariants(t *testing.T) {
+	t.Parallel()
 	bp := `
 		android_app_import {
 			name: "foo",
@@ -2435,6 +2470,7 @@
 }
 
 func TestAndroidAppImport_Filename(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		android_app_import {
 			name: "foo",
@@ -2482,6 +2518,7 @@
 }
 
 func TestAndroidAppImport_ArchVariants(t *testing.T) {
+	t.Parallel()
 	// The test config's target arch is ARM64.
 	testCases := []struct {
 		name     string
@@ -2545,6 +2582,7 @@
 }
 
 func TestAndroidTestImport(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		android_test_import {
 			name: "foo",
@@ -2573,6 +2611,7 @@
 }
 
 func TestAndroidTestImport_NoJinUncompressForPresigned(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		android_test_import {
 			name: "foo",
@@ -2610,6 +2649,7 @@
 }
 
 func TestAndroidTestImport_Preprocessed(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		android_test_import {
 			name: "foo",
@@ -2646,6 +2686,7 @@
 }
 
 func TestStl(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, cc.GatherRequiredDepsForTest(android.Android)+`
 		cc_library {
 			name: "libjni",
@@ -2709,6 +2750,7 @@
 }
 
 func TestUsesLibraries(t *testing.T) {
+	t.Parallel()
 	bp := `
 		java_sdk_library {
 			name: "foo",
@@ -2852,6 +2894,7 @@
 }
 
 func TestCodelessApp(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name   string
 		bp     string
@@ -2928,6 +2971,7 @@
 }
 
 func TestEmbedNotice(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJavaWithFS(t, cc.GatherRequiredDepsForTest(android.Android)+`
 		android_app {
 			name: "foo",
@@ -3037,6 +3081,7 @@
 }
 
 func TestUncompressDex(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name string
 		bp   string
@@ -3164,6 +3209,7 @@
 }
 
 func TestRuntimeResourceOverlay(t *testing.T) {
+	t.Parallel()
 	fs := map[string][]byte{
 		"baz/res/res/values/strings.xml": nil,
 		"bar/res/res/values/strings.xml": nil,
@@ -3268,6 +3314,7 @@
 }
 
 func TestRuntimeResourceOverlay_JavaDefaults(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_defaults {
 			name: "rro_defaults",
@@ -3327,6 +3374,7 @@
 }
 
 func TestOverrideRuntimeResourceOverlay(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		runtime_resource_overlay {
 			name: "foo_overlay",
diff --git a/java/device_host_converter_test.go b/java/device_host_converter_test.go
index 3c9a0f3..208ea57 100644
--- a/java/device_host_converter_test.go
+++ b/java/device_host_converter_test.go
@@ -22,6 +22,7 @@
 )
 
 func TestDeviceForHost(t *testing.T) {
+	t.Parallel()
 	bp := `
 		java_library {
 			name: "device_module",
@@ -102,6 +103,7 @@
 }
 
 func TestHostForDevice(t *testing.T) {
+	t.Parallel()
 	bp := `
 		java_library_host {
 			name: "host_module",
diff --git a/java/dexpreopt_bootjars_test.go b/java/dexpreopt_bootjars_test.go
index 4a8d3cd..00bd80c 100644
--- a/java/dexpreopt_bootjars_test.go
+++ b/java/dexpreopt_bootjars_test.go
@@ -84,6 +84,7 @@
 }
 
 func TestDexpreoptBootJars(t *testing.T) {
+	t.Parallel()
 	ruleFile := "boot-foo.art"
 
 	expectedInputs := []string{
@@ -114,6 +115,7 @@
 
 // Changes to the boot.zip structure may break the ART APK scanner.
 func TestDexpreoptBootZip(t *testing.T) {
+	t.Parallel()
 	ruleFile := "boot.zip"
 
 	ctx := android.PathContextForTesting(testConfig(nil, "", nil))
diff --git a/java/dexpreopt_test.go b/java/dexpreopt_test.go
index 5550a4c..0bb3ac9 100644
--- a/java/dexpreopt_test.go
+++ b/java/dexpreopt_test.go
@@ -19,6 +19,7 @@
 )
 
 func TestDexpreoptEnabled(t *testing.T) {
+	t.Parallel()
 	tests := []struct {
 		name    string
 		bp      string
diff --git a/java/hiddenapi_singleton_test.go b/java/hiddenapi_singleton_test.go
index dbdab7a..97dd125 100644
--- a/java/hiddenapi_singleton_test.go
+++ b/java/hiddenapi_singleton_test.go
@@ -58,6 +58,7 @@
 }
 
 func TestHiddenAPISingleton(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testHiddenAPIBootJars(t, `
 		java_library {
 			name: "foo",
@@ -75,6 +76,7 @@
 }
 
 func TestHiddenAPISingletonWithPrebuilt(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testHiddenAPIBootJars(t, `
 		java_import {
 			name: "foo",
@@ -92,6 +94,7 @@
 }
 
 func TestHiddenAPISingletonWithPrebuiltUseSource(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testHiddenAPIBootJars(t, `
 		java_library {
 			name: "foo",
@@ -121,6 +124,7 @@
 }
 
 func TestHiddenAPISingletonWithPrebuiltOverrideSource(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testHiddenAPIBootJars(t, `
 		java_library {
 			name: "foo",
@@ -150,6 +154,7 @@
 }
 
 func TestHiddenAPISingletonSdks(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name             string
 		unbundledBuild   bool
diff --git a/java/jacoco_test.go b/java/jacoco_test.go
index 91f0553..d77c916 100644
--- a/java/jacoco_test.go
+++ b/java/jacoco_test.go
@@ -17,6 +17,7 @@
 import "testing"
 
 func TestJacocoFilterToSpecs(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name, in, out string
 	}{
@@ -66,6 +67,7 @@
 }
 
 func TestJacocoFiltersToZipCommand(t *testing.T) {
+	t.Parallel()
 	testCases := []struct {
 		name               string
 		includes, excludes []string
diff --git a/java/java_test.go b/java/java_test.go
index f16639a..4424999 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -177,6 +177,7 @@
 }
 
 func TestJavaLinkType(t *testing.T) {
+	t.Parallel()
 	testJava(t, `
 		java_library {
 			name: "foo",
@@ -265,6 +266,7 @@
 }
 
 func TestSimple(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -309,6 +311,7 @@
 }
 
 func TestExportedPlugins(t *testing.T) {
+	t.Parallel()
 	type Result struct {
 		library    string
 		processors string
@@ -392,6 +395,7 @@
 }
 
 func TestSdkVersionByPartition(t *testing.T) {
+	t.Parallel()
 	testJavaError(t, "sdk_version must have a value when the module is located at vendor or product", `
 		java_library {
 			name: "foo",
@@ -427,6 +431,7 @@
 }
 
 func TestArchSpecific(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -446,6 +451,7 @@
 }
 
 func TestBinary(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library_host {
 			name: "foo",
@@ -474,6 +480,7 @@
 }
 
 func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) {
+	t.Parallel()
 	bp := `
 		java_library {
 			name: "target_library",
@@ -509,6 +516,7 @@
 }
 
 func TestPrebuilts(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -604,6 +612,7 @@
 }
 
 func TestJavaSdkLibraryImport(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -660,6 +669,7 @@
 }
 
 func TestJavaSdkLibraryImport_WithSource(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_sdk_library {
 			name: "sdklib",
@@ -699,6 +709,7 @@
 }
 
 func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_sdk_library {
 			name: "sdklib",
@@ -736,6 +747,7 @@
 }
 
 func TestDefaults(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_defaults {
 			name: "defaults",
@@ -811,6 +823,7 @@
 }
 
 func TestResources(t *testing.T) {
+	t.Parallel()
 	var table = []struct {
 		name  string
 		prop  string
@@ -917,6 +930,7 @@
 }
 
 func TestIncludeSrcs(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJavaWithFS(t, `
 		java_library {
 			name: "foo",
@@ -984,6 +998,7 @@
 }
 
 func TestGeneratedSources(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJavaWithFS(t, `
 		java_library {
 			name: "foo",
@@ -1020,6 +1035,7 @@
 }
 
 func TestTurbine(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -1069,6 +1085,7 @@
 }
 
 func TestSharding(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "bar",
@@ -1087,6 +1104,7 @@
 }
 
 func TestDroiddoc(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJavaWithFS(t, `
 		droiddoc_exported_dir {
 		    name: "droiddoc-templates-sdk",
@@ -1165,6 +1183,7 @@
 }
 
 func TestDroiddocArgsAndFlagsCausesError(t *testing.T) {
+	t.Parallel()
 	testJavaError(t, "flags is set. Cannot set args", `
 		droiddoc_exported_dir {
 		    name: "droiddoc-templates-sdk",
@@ -1211,6 +1230,7 @@
 }
 
 func TestDroidstubs(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJavaWithFS(t, `
 		droiddoc_exported_dir {
 		    name: "droiddoc-templates-sdk",
@@ -1267,6 +1287,7 @@
 }
 
 func TestDroidstubsWithSystemModules(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		droidstubs {
 		    name: "stubs-source-system-modules",
@@ -1326,6 +1347,7 @@
 }
 
 func TestJarGenrules(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -1380,6 +1402,7 @@
 }
 
 func TestExcludeFileGroupInSrcs(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -1406,6 +1429,7 @@
 }
 
 func TestJavaLibrary(t *testing.T) {
+	t.Parallel()
 	config := testConfig(nil, "", map[string][]byte{
 		"libcore/Android.bp": []byte(`
 				java_library {
@@ -1419,6 +1443,7 @@
 }
 
 func TestJavaSdkLibrary(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		droiddoc_exported_dir {
 			name: "droiddoc-templates-sdk",
@@ -1557,6 +1582,7 @@
 }
 
 func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_sdk_library {
 			name: "foo",
@@ -1582,6 +1608,7 @@
 }
 
 func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) {
+	t.Parallel()
 	testJava(t, `
 		java_sdk_library {
 			name: "foo",
@@ -1600,6 +1627,7 @@
 }
 
 func TestJavaSdkLibrary_AccessOutputFiles_MissingScope(t *testing.T) {
+	t.Parallel()
 	testJavaError(t, `"foo" does not provide api scope system`, `
 		java_sdk_library {
 			name: "foo",
@@ -1618,6 +1646,7 @@
 }
 
 func TestJavaSdkLibrary_Deps(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_sdk_library {
 			name: "sdklib",
@@ -1640,6 +1669,7 @@
 }
 
 func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) {
+	t.Parallel()
 	testJava(t, `
 		java_sdk_library_import {
 			name: "foo",
@@ -1663,6 +1693,7 @@
 }
 
 func TestJavaSdkLibraryImport_AccessOutputFiles_Invalid(t *testing.T) {
+	t.Parallel()
 	bp := `
 		java_sdk_library_import {
 			name: "foo",
@@ -1711,6 +1742,7 @@
 }
 
 func TestJavaSdkLibrary_InvalidScopes(t *testing.T) {
+	t.Parallel()
 	testJavaError(t, `module "foo": enabled api scope "system" depends on disabled scope "public"`, `
 		java_sdk_library {
 			name: "foo",
@@ -1729,6 +1761,7 @@
 }
 
 func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
+	t.Parallel()
 	testJava(t, `
 		java_sdk_library {
 			name: "foo",
@@ -1743,6 +1776,7 @@
 }
 
 func TestJavaSdkLibrary_ModuleLib(t *testing.T) {
+	t.Parallel()
 	testJava(t, `
 		java_sdk_library {
 			name: "foo",
@@ -1759,6 +1793,7 @@
 }
 
 func TestJavaSdkLibrary_SystemServer(t *testing.T) {
+	t.Parallel()
 	testJava(t, `
 		java_sdk_library {
 			name: "foo",
@@ -1775,6 +1810,7 @@
 }
 
 func TestJavaSdkLibrary_MissingScope(t *testing.T) {
+	t.Parallel()
 	testJavaError(t, `requires api scope module-lib from foo but it only has \[\] available`, `
 		java_sdk_library {
 			name: "foo",
@@ -1794,6 +1830,7 @@
 }
 
 func TestJavaSdkLibrary_FallbackScope(t *testing.T) {
+	t.Parallel()
 	testJava(t, `
 		java_sdk_library {
 			name: "foo",
@@ -1814,6 +1851,7 @@
 }
 
 func TestJavaSdkLibrary_DefaultToStubs(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_sdk_library {
 			name: "foo",
@@ -1889,6 +1927,7 @@
 }
 
 func TestCompilerFlags(t *testing.T) {
+	t.Parallel()
 	for _, testCase := range compilerFlagsTestCases {
 		ctx := &mockContext{result: true}
 		CheckKotlincFlags(ctx, []string{testCase.in})
@@ -1919,6 +1958,7 @@
 }
 
 func TestPatchModule(t *testing.T) {
+	t.Parallel()
 	t.Run("Java language level 8", func(t *testing.T) {
 		// Test with legacy javac -source 1.8 -target 1.8
 		bp := `
@@ -1984,6 +2024,7 @@
 }
 
 func TestJavaSystemModules(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_system_modules {
 			name: "system-modules",
@@ -2018,6 +2059,7 @@
 }
 
 func TestJavaSystemModulesImport(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_system_modules_import {
 			name: "system-modules",
@@ -2048,6 +2090,7 @@
 }
 
 func TestJavaLibraryWithSystemModules(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 		    name: "lib-with-source-system-modules",
@@ -2104,6 +2147,7 @@
 }
 
 func TestAidlExportIncludeDirsFromImports(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -2128,6 +2172,7 @@
 }
 
 func TestDataNativeBinaries(t *testing.T) {
+	t.Parallel()
 	ctx, config := testJava(t, `
 		java_test_host {
 			name: "foo",
diff --git a/java/jdeps_test.go b/java/jdeps_test.go
index 874d1d7..46e7296 100644
--- a/java/jdeps_test.go
+++ b/java/jdeps_test.go
@@ -22,6 +22,7 @@
 )
 
 func TestCollectJavaLibraryPropertiesAddLibsDeps(t *testing.T) {
+	t.Parallel()
 	expected := []string{"Foo", "Bar"}
 	module := LibraryFactory().(*Library)
 	module.properties.Libs = append(module.properties.Libs, expected...)
@@ -35,6 +36,7 @@
 }
 
 func TestCollectJavaLibraryPropertiesAddStaticLibsDeps(t *testing.T) {
+	t.Parallel()
 	expected := []string{"Foo", "Bar"}
 	module := LibraryFactory().(*Library)
 	module.properties.Static_libs = append(module.properties.Static_libs, expected...)
@@ -48,6 +50,7 @@
 }
 
 func TestCollectJavaLibraryPropertiesAddScrs(t *testing.T) {
+	t.Parallel()
 	expected := []string{"Foo", "Bar"}
 	module := LibraryFactory().(*Library)
 	module.expandIDEInfoCompiledSrcs = append(module.expandIDEInfoCompiledSrcs, expected...)
@@ -61,6 +64,7 @@
 }
 
 func TestCollectJavaLibraryPropertiesAddAidlIncludeDirs(t *testing.T) {
+	t.Parallel()
 	expected := []string{"Foo", "Bar"}
 	module := LibraryFactory().(*Library)
 	module.deviceProperties.Aidl.Include_dirs = append(module.deviceProperties.Aidl.Include_dirs, expected...)
@@ -74,6 +78,7 @@
 }
 
 func TestCollectJavaLibraryPropertiesAddJarjarRules(t *testing.T) {
+	t.Parallel()
 	expected := "Jarjar_rules.txt"
 	module := LibraryFactory().(*Library)
 	module.expandJarjarRules = android.PathForTesting(expected)
diff --git a/java/kotlin_test.go b/java/kotlin_test.go
index 60ca1c4..530f7fe 100644
--- a/java/kotlin_test.go
+++ b/java/kotlin_test.go
@@ -22,6 +22,7 @@
 )
 
 func TestKotlin(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -84,6 +85,7 @@
 }
 
 func TestKapt(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -163,6 +165,7 @@
 }
 
 func TestKaptEncodeFlags(t *testing.T) {
+	t.Parallel()
 	// Compares the kaptEncodeFlags against the results of the example implementation at
 	// https://kotlinlang.org/docs/reference/kapt.html#apjavac-options-encoding
 	tests := []struct {
diff --git a/java/plugin_test.go b/java/plugin_test.go
index c7913d3..3eb0215 100644
--- a/java/plugin_test.go
+++ b/java/plugin_test.go
@@ -20,6 +20,7 @@
 )
 
 func TestNoPlugin(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -44,6 +45,7 @@
 }
 
 func TestPlugin(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
@@ -83,6 +85,7 @@
 }
 
 func TestPluginGeneratesApi(t *testing.T) {
+	t.Parallel()
 	ctx, _ := testJava(t, `
 		java_library {
 			name: "foo",
diff --git a/java/sdk_test.go b/java/sdk_test.go
index 776069d..374da11 100644
--- a/java/sdk_test.go
+++ b/java/sdk_test.go
@@ -27,6 +27,7 @@
 )
 
 func TestClasspath(t *testing.T) {
+	t.Parallel()
 	var classpathTestcases = []struct {
 		name       string
 		unbundled  bool