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
This commit is contained in:
@@ -1055,7 +1055,7 @@ func AndroidTestFactory() android.Module {
|
||||
module.appProperties.Use_embedded_native_libs = proptools.BoolPtr(true)
|
||||
module.appProperties.AlwaysPackageNativeLibs = true
|
||||
module.Module.dexpreopter.isTest = true
|
||||
module.Module.linter.test = true
|
||||
module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
|
||||
|
||||
module.addHostAndDeviceProperties()
|
||||
module.AddProperties(
|
||||
@@ -1108,7 +1108,7 @@ func AndroidTestHelperAppFactory() android.Module {
|
||||
module.appProperties.Use_embedded_native_libs = proptools.BoolPtr(true)
|
||||
module.appProperties.AlwaysPackageNativeLibs = true
|
||||
module.Module.dexpreopter.isTest = true
|
||||
module.Module.linter.test = true
|
||||
module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
|
||||
|
||||
module.addHostAndDeviceProperties()
|
||||
module.AddProperties(
|
||||
|
@@ -1262,7 +1262,7 @@ func TestFactory() android.Module {
|
||||
|
||||
module.Module.properties.Installable = proptools.BoolPtr(true)
|
||||
module.Module.dexpreopter.isTest = true
|
||||
module.Module.linter.test = true
|
||||
module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
|
||||
|
||||
android.InitSdkAwareModule(module)
|
||||
InitJavaModule(module, android.HostAndDeviceSupported)
|
||||
@@ -1278,7 +1278,7 @@ func TestHelperLibraryFactory() android.Module {
|
||||
|
||||
module.Module.properties.Installable = proptools.BoolPtr(true)
|
||||
module.Module.dexpreopter.isTest = true
|
||||
module.Module.linter.test = true
|
||||
module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
|
||||
|
||||
InitJavaModule(module, android.HostAndDeviceSupported)
|
||||
return module
|
||||
|
@@ -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 {
|
||||
|
@@ -23,6 +23,7 @@ import (
|
||||
"android/soong/android"
|
||||
"android/soong/java/config"
|
||||
"android/soong/tradefed"
|
||||
"github.com/google/blueprint/proptools"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -344,7 +345,7 @@ func RobolectricTestFactory() android.Module {
|
||||
&module.testProperties)
|
||||
|
||||
module.Module.dexpreopter.isTest = true
|
||||
module.Module.linter.test = true
|
||||
module.Module.linter.properties.Lint.Test = proptools.BoolPtr(true)
|
||||
|
||||
module.testProperties.Test_suites = []string{"robolectric-tests"}
|
||||
|
||||
|
Reference in New Issue
Block a user