summaryrefslogtreecommitdiff
path: root/java/lint.go
diff options
context:
space:
mode:
author Cole Faust <colefaust@google.com> 2022-08-11 11:59:04 -0700
committer Cole Faust <colefaust@google.com> 2022-08-11 12:26:51 -0700
commitd57e8b2c2a55359c86def86a06dfdc7f7678d3c3 (patch)
treef8a50beb318eaecebbb3e7cd9f318357fb472cfc /java/lint.go
parent50e02aaf7623b29eda65a7b3f57bbed54ef3c75b (diff)
Add lint test property
Some libraries are only used for tests, but are not test module types. These modules get warnings about @VisibleForTesting usages when they really shouldn't. Expose a test flag that module authors can use to make lint treat a module as test code. Bug: 235339747 Test: Manually tested applying it to SystemUI-tests Change-Id: I1356749a669dc80a7725605d7159da27c9a211b4
Diffstat (limited to 'java/lint.go')
-rw-r--r--java/lint.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/java/lint.go b/java/lint.go
index c27ca9821..8f14bbee8 100644
--- a/java/lint.go
+++ b/java/lint.go
@@ -61,6 +61,11 @@ type LintProperties struct {
// If true, baselining updatability lint checks (e.g. NewApi) is prohibited. Defaults to false.
Strict_updatability_linting *bool
+
+ // Treat the code in this module as test code for @VisibleForTesting enforcement.
+ // This will be true by default for test module types, false otherwise.
+ // If soong gets support for testonly, this flag should be replaced with that.
+ Test *bool
}
}
@@ -74,7 +79,6 @@ type linter struct {
classpath android.Paths
classes android.Path
extraLintCheckJars android.Paths
- test bool
library bool
minSdkVersion int
targetSdkVersion int
@@ -229,7 +233,7 @@ func (l *linter) writeLintProjectXML(ctx android.ModuleContext, rule *android.Ru
if l.library {
cmd.Flag("--library")
}
- if l.test {
+ if proptools.BoolDefault(l.properties.Lint.Test, false) {
cmd.Flag("--test")
}
if l.manifest != nil {