summaryrefslogtreecommitdiff
path: root/java/java_test.go
diff options
context:
space:
mode:
author Treehugger Robot <treehugger-gerrit@google.com> 2021-06-15 00:50:29 +0000
committer Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> 2021-06-15 00:50:29 +0000
commite7e443b82093c9fe4d805202127ba2f2602fc87a (patch)
tree5898b78aa4cee0c56a8b492b767c1b99a681ab1f /java/java_test.go
parente63e0cc94eee9f7a01e56c56da6855e3afecc902 (diff)
parent768692bc698ef6e1be4acf1539651a751182d7f7 (diff)
Merge "Add a build flag to always enable errorprone per-target" am: 768692bc69
Original change: https://android-review.googlesource.com/c/platform/build/soong/+/1735975 Change-Id: I7fc8b462d0a8b504e3aa4066c9e27fb158483851
Diffstat (limited to 'java/java_test.go')
-rw-r--r--java/java_test.go28
1 files changed, 28 insertions, 0 deletions
diff --git a/java/java_test.go b/java/java_test.go
index bd373c177..78d9ab4c7 100644
--- a/java/java_test.go
+++ b/java/java_test.go
@@ -1392,3 +1392,31 @@ func TestDefaultInstallable(t *testing.T) {
assertDeepEquals(t, "Default installable value should be true.", proptools.BoolPtr(true),
module.properties.Installable)
}
+
+func TestErrorproneEnabled(t *testing.T) {
+ ctx, _ := testJava(t, `
+ java_library {
+ name: "foo",
+ srcs: ["a.java"],
+ errorprone: {
+ enabled: true,
+ },
+ }
+ `)
+
+ javac := ctx.ModuleForTests("foo", "android_common").Description("javac")
+
+ // Test that the errorprone plugins are passed to javac
+ expectedSubstring := "-Xplugin:ErrorProne"
+ if !strings.Contains(javac.Args["javacFlags"], expectedSubstring) {
+ t.Errorf("expected javacFlags to conain %q, got %q", expectedSubstring, javac.Args["javacFlags"])
+ }
+
+ // Modules with errorprone { enabled: true } will include errorprone checks
+ // in the main javac build rule. Only when RUN_ERROR_PRONE is true will
+ // the explicit errorprone build rule be created.
+ errorprone := ctx.ModuleForTests("foo", "android_common").MaybeDescription("errorprone")
+ if errorprone.RuleParams.Description != "" {
+ t.Errorf("expected errorprone build rule to not exist, but it did")
+ }
+}