aboutsummaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go84
1 files changed, 83 insertions, 1 deletions
diff --git a/java/java_test.go b/java/java_test.go
index 9e6357792..245654d1e 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -177,6 +177,7 @@ func moduleToPath(name string) string {
}
func TestJavaLinkType(t *testing.T) {
+ t.Parallel()
testJava(t, `
java_library {
name: "foo",
@@ -265,6 +266,7 @@ func TestJavaLinkType(t *testing.T) {
}
func TestSimple(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -309,6 +311,7 @@ func TestSimple(t *testing.T) {
}
func TestExportedPlugins(t *testing.T) {
+ t.Parallel()
type Result struct {
library string
processors string
@@ -392,6 +395,7 @@ func TestExportedPlugins(t *testing.T) {
}
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 TestSdkVersionByPartition(t *testing.T) {
}
func TestArchSpecific(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -446,6 +451,7 @@ func TestArchSpecific(t *testing.T) {
}
func TestBinary(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library_host {
name: "foo",
@@ -474,6 +480,7 @@ func TestBinary(t *testing.T) {
}
func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) {
+ t.Parallel()
bp := `
java_library {
name: "target_library",
@@ -509,6 +516,7 @@ func TestHostBinaryNoJavaDebugInfoOverride(t *testing.T) {
}
func TestPrebuilts(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -604,6 +612,7 @@ func assertDeepEquals(t *testing.T, message string, expected interface{}, actual
}
func TestJavaSdkLibraryImport(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -660,6 +669,7 @@ func TestJavaSdkLibraryImport(t *testing.T) {
}
func TestJavaSdkLibraryImport_WithSource(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_sdk_library {
name: "sdklib",
@@ -699,6 +709,7 @@ func TestJavaSdkLibraryImport_WithSource(t *testing.T) {
}
func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_sdk_library {
name: "sdklib",
@@ -736,6 +747,7 @@ func TestJavaSdkLibraryImport_Preferred(t *testing.T) {
}
func TestDefaults(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_defaults {
name: "defaults",
@@ -811,6 +823,7 @@ func TestDefaults(t *testing.T) {
}
func TestResources(t *testing.T) {
+ t.Parallel()
var table = []struct {
name string
prop string
@@ -917,6 +930,7 @@ func TestResources(t *testing.T) {
}
func TestIncludeSrcs(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
@@ -984,6 +998,7 @@ func TestIncludeSrcs(t *testing.T) {
}
func TestGeneratedSources(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
java_library {
name: "foo",
@@ -1020,6 +1035,7 @@ func TestGeneratedSources(t *testing.T) {
}
func TestTurbine(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -1069,6 +1085,7 @@ func TestTurbine(t *testing.T) {
}
func TestSharding(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "bar",
@@ -1087,6 +1104,7 @@ func TestSharding(t *testing.T) {
}
func TestDroiddoc(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
@@ -1165,6 +1183,7 @@ func TestDroiddoc(t *testing.T) {
}
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 TestDroiddocArgsAndFlagsCausesError(t *testing.T) {
}
func TestDroidstubs(t *testing.T) {
+ t.Parallel()
ctx, _ := testJavaWithFS(t, `
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
@@ -1267,6 +1287,7 @@ func TestDroidstubs(t *testing.T) {
}
func TestDroidstubsWithSystemModules(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
droidstubs {
name: "stubs-source-system-modules",
@@ -1326,6 +1347,7 @@ func checkSystemModulesUseByDroidstubs(t *testing.T, ctx *android.TestContext, m
}
func TestJarGenrules(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -1380,6 +1402,7 @@ func TestJarGenrules(t *testing.T) {
}
func TestExcludeFileGroupInSrcs(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -1406,19 +1429,45 @@ func TestExcludeFileGroupInSrcs(t *testing.T) {
}
func TestJavaLibrary(t *testing.T) {
+ t.Parallel()
config := testConfig(nil, "", map[string][]byte{
"libcore/Android.bp": []byte(`
java_library {
name: "core",
sdk_version: "none",
system_modules: "none",
- }`),
+ }
+
+ filegroup {
+ name: "core-jar",
+ srcs: [":core{.jar}"],
+ }
+`),
+ })
+ ctx := testContext()
+ run(t, ctx, config)
+}
+
+func TestJavaImport(t *testing.T) {
+ config := testConfig(nil, "", map[string][]byte{
+ "libcore/Android.bp": []byte(`
+ java_import {
+ name: "core",
+ sdk_version: "none",
+ }
+
+ filegroup {
+ name: "core-jar",
+ srcs: [":core{.jar}"],
+ }
+`),
})
ctx := testContext()
run(t, ctx, config)
}
func TestJavaSdkLibrary(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
droiddoc_exported_dir {
name: "droiddoc-templates-sdk",
@@ -1487,6 +1536,12 @@ func TestJavaSdkLibrary(t *testing.T) {
libs: ["foo"],
sdk_version: "system_29",
}
+ java_library {
+ name: "baz-module-30",
+ srcs: ["c.java"],
+ libs: ["foo"],
+ sdk_version: "module_30",
+ }
`)
// check the existence of the internal modules
@@ -1533,6 +1588,13 @@ func TestJavaSdkLibrary(t *testing.T) {
"prebuilts/sdk/29/system/foo.jar")
}
+ bazModule30Javac := ctx.ModuleForTests("baz-module-30", "android_common").Rule("javac")
+ // tests if "baz-module-30" is actually linked to the module 30 stubs lib
+ if !strings.Contains(bazModule30Javac.Args["classpath"], "prebuilts/sdk/30/module-lib/foo.jar") {
+ t.Errorf("baz-module-30 javac classpath %v does not contain %q", bazModule30Javac.Args["classpath"],
+ "prebuilts/sdk/30/module-lib/foo.jar")
+ }
+
// test if baz has exported SDK lib names foo and bar to qux
qux := ctx.ModuleForTests("qux", "android_common")
if quxLib, ok := qux.Module().(*Library); ok {
@@ -1544,6 +1606,7 @@ func TestJavaSdkLibrary(t *testing.T) {
}
func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_sdk_library {
name: "foo",
@@ -1569,6 +1632,7 @@ func TestJavaSdkLibrary_DoNotAccessImplWhenItIsNotBuilt(t *testing.T) {
}
func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) {
+ t.Parallel()
testJava(t, `
java_sdk_library {
name: "foo",
@@ -1587,6 +1651,7 @@ func TestJavaSdkLibrary_UseSourcesFromAnotherSdkLibrary(t *testing.T) {
}
func TestJavaSdkLibrary_AccessOutputFiles_MissingScope(t *testing.T) {
+ t.Parallel()
testJavaError(t, `"foo" does not provide api scope system`, `
java_sdk_library {
name: "foo",
@@ -1605,6 +1670,7 @@ func TestJavaSdkLibrary_AccessOutputFiles_MissingScope(t *testing.T) {
}
func TestJavaSdkLibrary_Deps(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_sdk_library {
name: "sdklib",
@@ -1627,6 +1693,7 @@ func TestJavaSdkLibrary_Deps(t *testing.T) {
}
func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) {
+ t.Parallel()
testJava(t, `
java_sdk_library_import {
name: "foo",
@@ -1650,6 +1717,7 @@ func TestJavaSdkLibraryImport_AccessOutputFiles(t *testing.T) {
}
func TestJavaSdkLibraryImport_AccessOutputFiles_Invalid(t *testing.T) {
+ t.Parallel()
bp := `
java_sdk_library_import {
name: "foo",
@@ -1698,6 +1766,7 @@ func TestJavaSdkLibraryImport_AccessOutputFiles_Invalid(t *testing.T) {
}
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",
@@ -1716,6 +1785,7 @@ func TestJavaSdkLibrary_InvalidScopes(t *testing.T) {
}
func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
+ t.Parallel()
testJava(t, `
java_sdk_library {
name: "foo",
@@ -1730,6 +1800,7 @@ func TestJavaSdkLibrary_SdkVersion_ForScope(t *testing.T) {
}
func TestJavaSdkLibrary_ModuleLib(t *testing.T) {
+ t.Parallel()
testJava(t, `
java_sdk_library {
name: "foo",
@@ -1746,6 +1817,7 @@ func TestJavaSdkLibrary_ModuleLib(t *testing.T) {
}
func TestJavaSdkLibrary_SystemServer(t *testing.T) {
+ t.Parallel()
testJava(t, `
java_sdk_library {
name: "foo",
@@ -1762,6 +1834,7 @@ func TestJavaSdkLibrary_SystemServer(t *testing.T) {
}
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",
@@ -1781,6 +1854,7 @@ func TestJavaSdkLibrary_MissingScope(t *testing.T) {
}
func TestJavaSdkLibrary_FallbackScope(t *testing.T) {
+ t.Parallel()
testJava(t, `
java_sdk_library {
name: "foo",
@@ -1801,6 +1875,7 @@ func TestJavaSdkLibrary_FallbackScope(t *testing.T) {
}
func TestJavaSdkLibrary_DefaultToStubs(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_sdk_library {
name: "foo",
@@ -1876,6 +1951,7 @@ func (ctx *mockContext) PropertyErrorf(property, format string, args ...interfac
}
func TestCompilerFlags(t *testing.T) {
+ t.Parallel()
for _, testCase := range compilerFlagsTestCases {
ctx := &mockContext{result: true}
CheckKotlincFlags(ctx, []string{testCase.in})
@@ -1906,6 +1982,7 @@ func checkPatchModuleFlag(t *testing.T, ctx *android.TestContext, moduleName str
}
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 := `
@@ -1971,6 +2048,7 @@ func TestPatchModule(t *testing.T) {
}
func TestJavaSystemModules(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_system_modules {
name: "system-modules",
@@ -2005,6 +2083,7 @@ func TestJavaSystemModules(t *testing.T) {
}
func TestJavaSystemModulesImport(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_system_modules_import {
name: "system-modules",
@@ -2035,6 +2114,7 @@ func TestJavaSystemModulesImport(t *testing.T) {
}
func TestJavaLibraryWithSystemModules(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "lib-with-source-system-modules",
@@ -2091,6 +2171,7 @@ func checkBootClasspathForSystemModule(t *testing.T, ctx *android.TestContext, m
}
func TestAidlExportIncludeDirsFromImports(t *testing.T) {
+ t.Parallel()
ctx, _ := testJava(t, `
java_library {
name: "foo",
@@ -2115,6 +2196,7 @@ func TestAidlExportIncludeDirsFromImports(t *testing.T) {
}
func TestDataNativeBinaries(t *testing.T) {
+ t.Parallel()
ctx, config := testJava(t, `
java_test_host {
name: "foo",