summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
author Colin Cross <ccross@android.com> 2017-12-05 13:42:45 -0800
committer Colin Cross <ccross@android.com> 2017-12-06 04:16:21 +0000
commit6b4a32d7712726a21ef153c964fee1f3c508ac30 (patch)
tree55ad862236f276101d1898a4a39909afa0cd7830 /java/java_test.go
parent0db5568612385e014ad40832660a34d935aba954 (diff)
Split java_binary modules into common and binary variants
Add a common_first multilib type and use it for java.Binary so that the java part is compiled as a "common" arch type but the wrapper script is installed as a "linux_glibc" arch type. This allows java_binary to be used as a tool dependency for a genrule. Bug: 68397812 Test: TestJavaBinary Change-Id: I809060839ce8878300da3fb76426ceb1ea6b0e8e
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go35
1 files changed, 35 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go
index 58b27c30f..78fbd41e0 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -62,6 +62,7 @@ func testContext(config android.Config, bp string,
ctx := android.NewTestArchContext()
ctx.RegisterModuleType("android_app", android.ModuleFactoryAdaptor(AndroidAppFactory))
+ ctx.RegisterModuleType("java_binary_host", android.ModuleFactoryAdaptor(BinaryHostFactory))
ctx.RegisterModuleType("java_library", android.ModuleFactoryAdaptor(LibraryFactory(true)))
ctx.RegisterModuleType("java_library_host", android.ModuleFactoryAdaptor(LibraryHostFactory))
ctx.RegisterModuleType("java_import", android.ModuleFactoryAdaptor(ImportFactory))
@@ -147,6 +148,8 @@ func testContext(config android.Config, bp string,
// For framework-res, which is an implicit dependency for framework
"AndroidManifest.xml": nil,
"build/target/product/security/testkey": nil,
+
+ "build/soong/scripts/jar-wrapper.sh": nil,
}
for k, v := range fs {
@@ -159,6 +162,7 @@ func testContext(config android.Config, bp string,
}
func run(t *testing.T, ctx *android.TestContext, config android.Config) {
+ t.Helper()
_, errs := ctx.ParseFileList(".", []string{"Android.bp"})
fail(t, errs)
_, errs = ctx.PrepareBuildActions(config)
@@ -166,6 +170,7 @@ func run(t *testing.T, ctx *android.TestContext, config android.Config) {
}
func testJava(t *testing.T, bp string) *android.TestContext {
+ t.Helper()
config := testConfig(nil)
ctx := testContext(config, bp, nil)
run(t, ctx, config)
@@ -250,6 +255,35 @@ func TestArchSpecific(t *testing.T) {
}
}
+func TestBinary(t *testing.T) {
+ ctx := testJava(t, `
+ java_library_host {
+ name: "foo",
+ srcs: ["a.java"],
+ }
+
+ java_binary_host {
+ name: "bar",
+ srcs: ["b.java"],
+ static_libs: ["foo"],
+ }
+ `)
+
+ buildOS := android.BuildOs.String()
+
+ bar := ctx.ModuleForTests("bar", buildOS+"_common")
+ barJar := bar.Output("bar.jar").Output.String()
+ barWrapper := ctx.ModuleForTests("bar", buildOS+"_x86_64")
+ barWrapperDeps := barWrapper.Output("bar").Implicits.Strings()
+
+ // Test that the install binary wrapper depends on the installed jar file
+ if len(barWrapperDeps) != 1 || barWrapperDeps[0] != barJar {
+ t.Errorf("expected binary wrapper implicits [%q], got %v",
+ barJar, barWrapperDeps)
+ }
+
+}
+
var classpathTestcases = []struct {
name string
moduleType string
@@ -831,6 +865,7 @@ func TestJarGenrules(t *testing.T) {
}
func fail(t *testing.T, errs []error) {
+ t.Helper()
if len(errs) > 0 {
for _, err := range errs {
t.Error(err)