_test module types shouldn't override user-set test property
Android lint considers code "test" code depending on if the --test flag
is passed. We pass it by default for *_test module types, but also allow
the user to control it via the "lint: { test: true }" property. However,
the module types were overriding the user-defined test property if
the user-defined one was supplied via a defaults module. Split the
test property into two so that modules can use a separate lower priority
one from the user-controlled one.
Fixes: 358643466
Test: m nothing --no-skip-soong-tests
Change-Id: I1b1ef7a73ca9f413aa29e0c6025134fc52dc7caf
diff --git a/java/lint.go b/java/lint.go
index 9c6b93b..cee25a8 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -69,6 +69,11 @@
// If soong gets support for testonly, this flag should be replaced with that.
Test *bool
+ // Same as the regular Test property, but set by internal soong code based on if the module
+ // type is a test module type. This will act as the default value for the test property,
+ // but can be overridden by the user.
+ Test_module_type *bool `blueprint:"mutated"`
+
// Whether to ignore the exit code of Android lint. This is the --exit_code
// option. Defaults to false.
Suppress_exit_code *bool
@@ -257,7 +262,12 @@
if l.library {
cmd.Flag("--library")
}
- if proptools.BoolDefault(l.properties.Lint.Test, false) {
+
+ test := proptools.BoolDefault(l.properties.Lint.Test_module_type, false)
+ if l.properties.Lint.Test != nil {
+ test = *l.properties.Lint.Test
+ }
+ if test {
cmd.Flag("--test")
}
if l.manifest != nil {