From ada543ed86dc4828cecdb937844c6468c872d3e3 Mon Sep 17 00:00:00 2001 From: Cole Faust Date: Thu, 1 Feb 2024 17:36:57 -0800 Subject: 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 --- java/lint_test.go | 65 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 65 insertions(+) (limited to 'java/lint_test.go') diff --git a/java/lint_test.go b/java/lint_test.go index b51753f71..6b24daa5f 100644 --- a/java/lint_test.go +++ b/java/lint_test.go @@ -202,6 +202,71 @@ func TestJavaLintStrictUpdatabilityLinting(t *testing.T) { } } +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 -- cgit v1.2.3-59-g8ed1b