Add support for java_test in sdk

Adds java_test_import module type for use by the sdk snapshot and
adds java_tests property to the sdk and sdk_snapshot module type.

This is needed for the conscrypt test sdk.

Bug: 143678475
Test: m nothing
Change-Id: Ied4c56c978dac2f92a9b3bc34b3235d7eeba2fd3
This commit is contained in:
Paul Duffin
2019-12-03 18:06:47 +00:00
parent e602918294
commit 1b82e6a108
4 changed files with 221 additions and 6 deletions

View File

@@ -321,6 +321,112 @@ aidl/foo/bar/Test.aidl -> aidl/aidl/foo/bar/Test.aidl
)
}
func TestSnapshotWithJavaTest(t *testing.T) {
result := testSdkWithJava(t, `
module_exports {
name: "myexports",
java_tests: ["myjavatests"],
}
java_test {
name: "myjavatests",
srcs: ["Test.java"],
system_modules: "none",
sdk_version: "none",
compile_dex: true,
host_supported: true,
}
`)
result.CheckSnapshot("myexports", "android_common", "",
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_test_import {
name: "myexports_myjavatests@current",
sdk_member_name: "myjavatests",
jars: ["java/myjavatests.jar"],
test_config: "java/myjavatests-AndroidTest.xml",
}
java_test_import {
name: "myjavatests",
prefer: false,
jars: ["java/myjavatests.jar"],
test_config: "java/myjavatests-AndroidTest.xml",
}
module_exports_snapshot {
name: "myexports@current",
java_tests: ["myexports_myjavatests@current"],
}
`),
checkAllCopyRules(`
.intermediates/myjavatests/android_common/javac/myjavatests.jar -> java/myjavatests.jar
.intermediates/myjavatests/android_common/myjavatests.config -> java/myjavatests-AndroidTest.xml
`),
)
}
func TestHostSnapshotWithJavaTest(t *testing.T) {
// b/145598135 - Generating host snapshots for anything other than linux is not supported.
SkipIfNotLinux(t)
result := testSdkWithJava(t, `
module_exports {
name: "myexports",
device_supported: false,
host_supported: true,
java_tests: ["myjavatests"],
}
java_test {
name: "myjavatests",
device_supported: false,
host_supported: true,
srcs: ["Test.java"],
system_modules: "none",
sdk_version: "none",
compile_dex: true,
}
`)
result.CheckSnapshot("myexports", "linux_glibc_common", "",
checkAndroidBpContents(`
// This is auto-generated. DO NOT EDIT.
java_test_import {
name: "myexports_myjavatests@current",
sdk_member_name: "myjavatests",
device_supported: false,
host_supported: true,
jars: ["java/myjavatests.jar"],
test_config: "java/myjavatests-AndroidTest.xml",
}
java_test_import {
name: "myjavatests",
prefer: false,
device_supported: false,
host_supported: true,
jars: ["java/myjavatests.jar"],
test_config: "java/myjavatests-AndroidTest.xml",
}
module_exports_snapshot {
name: "myexports@current",
device_supported: false,
host_supported: true,
java_tests: ["myexports_myjavatests@current"],
}
`),
checkAllCopyRules(`
.intermediates/myjavatests/linux_glibc_common/javac/myjavatests.jar -> java/myjavatests.jar
.intermediates/myjavatests/linux_glibc_common/myjavatests.config -> java/myjavatests-AndroidTest.xml
`),
)
}
func testSdkWithDroidstubs(t *testing.T, bp string) *testSdkResult {
t.Helper()