diff options
Diffstat (limited to 'java/lint_test.go')
-rw-r--r-- | java/lint_test.go | 81 |
1 files changed, 34 insertions, 47 deletions
diff --git a/java/lint_test.go b/java/lint_test.go index 1ab416c9e..ec901aa70 100644 --- a/java/lint_test.go +++ b/java/lint_test.go @@ -113,8 +113,9 @@ func TestJavaLintUsesCorrectBpConfig(t *testing.T) { t.Error("did not use the correct file for baseline") } - if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check NewApi") { - t.Error("should check NewApi errors") + if !strings.Contains(*sboxProto.Commands[0].Command, "--warning_check NewApi") { + // TODO(b/268261262): Change this to check for --error_check + t.Error("should check NewApi warnings") } if !strings.Contains(*sboxProto.Commands[0].Command, "--error_check SomeCheck") { @@ -222,8 +223,35 @@ func TestJavaLintBypassUpdatableChecks(t *testing.T) { //} func TestJavaLintDatabaseSelectionFull(t *testing.T) { - testCases := []string{ - "current", "core_platform", "system_current", "S", "30", "10000", + testCases := []struct { + sdk_version string + expected_file string + }{ + { + "current", + "api_versions_public.xml", + }, { + "core_platform", + "api_versions_public.xml", + }, { + "system_current", + "api_versions_system.xml", + }, { + "module_current", + "api_versions_module_lib.xml", + }, { + "system_server_current", + "api_versions_system_server.xml", + }, { + "S", + "api_versions_public.xml", + }, { + "30", + "api_versions_public.xml", + }, { + "10000", + "api_versions_public.xml", + }, } bp := ` java_library { @@ -239,7 +267,7 @@ func TestJavaLintDatabaseSelectionFull(t *testing.T) { } ` for _, testCase := range testCases { - thisBp := strings.Replace(bp, "XXX", testCase, 1) + thisBp := strings.Replace(bp, "XXX", testCase.sdk_version, 1) result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules, FixtureWithPrebuiltApis(map[string][]string{ "30": {"foo"}, @@ -249,49 +277,8 @@ func TestJavaLintDatabaseSelectionFull(t *testing.T) { foo := result.ModuleForTests("foo", "android_common") sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto")) - if strings.Contains(*sboxProto.Commands[0].Command, - "/api_versions_public_filtered.xml") { - t.Error("used public-filtered lint api database for case", testCase) - } - if !strings.Contains(*sboxProto.Commands[0].Command, - "/api_versions.xml") { + if !strings.Contains(*sboxProto.Commands[0].Command, "/"+testCase.expected_file) { t.Error("did not use full api database for case", testCase) } } - -} - -func TestJavaLintDatabaseSelectionPublicFiltered(t *testing.T) { - testCases := []string{ - "module_current", "system_server_current", - } - bp := ` - java_library { - name: "foo", - srcs: [ - "a.java", - ], - min_sdk_version: "29", - sdk_version: "XXX", - lint: { - strict_updatability_linting: true, - }, - } -` - for _, testCase := range testCases { - thisBp := strings.Replace(bp, "XXX", testCase, 1) - result := android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules). - RunTestWithBp(t, thisBp) - - foo := result.ModuleForTests("foo", "android_common") - sboxProto := android.RuleBuilderSboxProtoForTests(t, foo.Output("lint.sbox.textproto")) - if !strings.Contains(*sboxProto.Commands[0].Command, - "/api_versions_public_filtered.xml") { - t.Error("did not use public-filtered lint api database for case", testCase) - } - if strings.Contains(*sboxProto.Commands[0].Command, - "/api_versions.xml") { - t.Error("used full api database for case", testCase) - } - } } |