Print the modules that had strict_updatability_linting set
strict_updatability_linting imposes requirements on all of a module's
transitive dependencies. So you may start getting errors on a module
due to some random other module that is hard to track down. Print out
the modules that caused the current module to use strict updatability
linting so that these errors are easier to debug.
Ignore-AOSP-First: The lint code in internal has diverged from AOSP quite a bit now
Bug: 323366771
Test: m lint-check
Change-Id: I43f2b1adb1ffa5b6e9516694c2bb87c7f94fed7d
diff --git a/java/lint_test.go b/java/lint_test.go
index b51753f..6b24daa 100644
--- a/java/lint_test.go
+++ b/java/lint_test.go
@@ -202,6 +202,71 @@
}
}
+func TestJavaLintStrictUpdatabilityLintingMultipleParents(t *testing.T) {
+ bp := `
+ java_library {
+ name: "a",
+ srcs: ["a.java"],
+ static_libs: ["b"],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ lint: {
+ strict_updatability_linting: true,
+ baseline_filename: "lint-baseline.xml",
+ },
+ }
+
+ java_library {
+ name: "b",
+ srcs: ["b.java"],
+ static_libs: ["c"],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ lint: {
+ strict_updatability_linting: true,
+ },
+ }
+
+ java_library {
+ name: "d",
+ srcs: ["d.java"],
+ static_libs: ["c"],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ lint: {
+ strict_updatability_linting: true,
+ },
+ }
+
+ java_library {
+ name: "c",
+ srcs: ["c.java"],
+ min_sdk_version: "29",
+ sdk_version: "current",
+ lint: {
+ baseline_filename: "lint-baseline.xml",
+ }
+ }
+ `
+ fs := android.MockFS{
+ "lint-baseline.xml": nil,
+ }
+
+ result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, fs.AddToFixture()).
+ RunTestWithBp(t, bp)
+
+ c := result.ModuleForTests("c", "android_common")
+ sboxProto := android.RuleBuilderSboxProtoForTests(t, result.TestContext, c.Output("lint.sbox.textproto"))
+ if !strings.Contains(*sboxProto.Commands[0].Command,
+ "--baseline lint-baseline.xml --disallowed_issues NewApi") {
+ t.Error("did not restrict baselining NewApi")
+ }
+ if !strings.Contains(*sboxProto.Commands[0].Command,
+ "--strict_updatability_parents a,b,d") {
+ t.Errorf("Did not find correct strict_updatability_parents in command %q", *sboxProto.Commands[0].Command)
+ }
+}
+
func TestJavaLintDatabaseSelectionFull(t *testing.T) {
testCases := []struct {
sdk_version string