summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2022-10-31 20:13:10 +0000
committer Gerrit Code Review <noreply-gerritcodereview@google.com> 2022-10-31 20:13:10 +0000
commit0fc368cff78e088aa6787b4c848d128812ae0b44 (patch)
tree612d460b32ee5b2f28eccc11be288129d497e83d /java/java_test.go
parent3bb3763afdc89eeb30dbae63ab33c98398bb02c8 (diff)
parentca65b40fa02f7103363772c2d020dec04a8f93ec (diff)
Merge "Generate a default wrapper for device java_binary"
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go
index 3b86f9aa4..f06b520d5 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1783,3 +1783,26 @@ func TestGenAidlIncludeFlagsForMixedBuilds(t *testing.T) {
t.Errorf("expected flags to be %q; was %q", expectedFlags, flags)
}
}
+
+func TestDeviceBinaryWrapperGeneration(t *testing.T) {
+ // Scenario 1: java_binary has main_class property in its bp
+ ctx, _ := testJava(t, `
+ java_binary {
+ name: "foo",
+ srcs: ["foo.java"],
+ main_class: "foo.bar.jb",
+ }
+ `)
+ wrapperPath := fmt.Sprint(ctx.ModuleForTests("foo", "android_arm64_armv8-a").AllOutputs())
+ if !strings.Contains(wrapperPath, "foo.sh") {
+ t.Errorf("wrapper file foo.sh is not generated")
+ }
+
+ // Scenario 2: java_binary has neither wrapper nor main_class, its build
+ // is expected to be failed.
+ testJavaError(t, "main_class property is required for device binary if no default wrapper is assigned", `
+ java_binary {
+ name: "foo",
+ srcs: ["foo.java"],
+ }`)
+}