Do not propagate strict updatability linting to libcore/

propogation of this flag is determined by the location of the Android.bp
where a library is defined.
libcore/ libraries that are transtive deps of updatable apexes will
- inherit strict_updatability_linting:true if defined in libcore root
- not inherit strict_updatability_linting:true if defined in libcore
  subdir

Note that the module can explicitly list `lint:{strict_updatability_linting: true}'
in their Android.bp file, in which case they will not be allowed to
baseline NewApi errors

Test: m lint-check
Test: TH
Bug: 208656169
Bug: 182349282

Change-Id: I4c373b2960a7af16301d7f06aab448f39b937ea9
This commit is contained in:
Spandan Das
2022-02-10 02:34:13 +00:00
parent 08c911f4eb
commit d9c23abeca
2 changed files with 66 additions and 0 deletions

View File

@@ -8937,6 +8937,64 @@ func TestApexStrictUpdtabilityLint(t *testing.T) {
}
}
func TestUpdatabilityLintSkipLibcore(t *testing.T) {
bp := `
apex {
name: "myapex",
key: "myapex.key",
java_libs: ["myjavalib"],
updatable: true,
min_sdk_version: "29",
}
apex_key {
name: "myapex.key",
}
java_library {
name: "myjavalib",
srcs: ["MyClass.java"],
apex_available: [ "myapex" ],
sdk_version: "current",
min_sdk_version: "29",
}
`
testCases := []struct {
testCaseName string
moduleDirectory string
disallowedFlagExpected bool
}{
{
testCaseName: "lintable module defined outside libcore",
moduleDirectory: "",
disallowedFlagExpected: true,
},
{
testCaseName: "lintable module defined in libcore root directory",
moduleDirectory: "libcore/",
disallowedFlagExpected: false,
},
{
testCaseName: "lintable module defined in libcore child directory",
moduleDirectory: "libcore/childdir/",
disallowedFlagExpected: true,
},
}
for _, testCase := range testCases {
lintFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"lint-baseline.xml", "")
bpFileCreator := android.FixtureAddTextFile(testCase.moduleDirectory+"Android.bp", bp)
result := testApex(t, "", lintFileCreator, bpFileCreator)
myjavalib := result.ModuleForTests("myjavalib", "android_common_apex29")
sboxProto := android.RuleBuilderSboxProtoForTests(t, myjavalib.Output("lint.sbox.textproto"))
cmdFlags := fmt.Sprintf("--baseline %vlint-baseline.xml --disallowed_issues NewApi", testCase.moduleDirectory)
disallowedFlagActual := strings.Contains(*sboxProto.Commands[0].Command, cmdFlags)
if disallowedFlagActual != testCase.disallowedFlagExpected {
t.Errorf("Failed testcase: %v \nActual lint cmd: %v", testCase.testCaseName, *sboxProto.Commands[0].Command)
}
}
}
// checks transtive deps of an apex coming from bootclasspath_fragment
func TestApexStrictUpdtabilityLintBcpFragmentDeps(t *testing.T) {
bp := `