diff options
| author | 2021-04-21 14:01:55 -0700 | |
|---|---|---|
| committer | 2021-04-21 16:56:19 -0700 | |
| commit | 79e6f6bfccbc2f7209e8e3ce1872951be64a41d5 (patch) | |
| tree | 53078730bdac4493dc45bbfbb4deb9d6c44490bc /java/lint_test.go | |
| parent | 4949557d507ee5cf5f56a5c92bbda5f8e5da4254 (diff) | |
Forbid bypassing updatability lint checks.
Test: lint_test.go
Bug: 182349282
Change-Id: Iac7c01493b449c2ddd6df6c68f8a74dfe72dfd7a
Diffstat (limited to 'java/lint_test.go')
| -rw-r--r-- | java/lint_test.go | 73 |
1 files changed, 73 insertions, 0 deletions
diff --git a/java/lint_test.go b/java/lint_test.go new file mode 100644 index 000000000..c257f63ac --- /dev/null +++ b/java/lint_test.go @@ -0,0 +1,73 @@ +// Copyright 2021 Google Inc. All rights reserved. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package java + +import ( + "testing" + + "android/soong/android" +) + +func TestJavaLintBypassUpdatableChecks(t *testing.T) { + testCases := []struct { + name string + bp string + error string + }{ + { + name: "warning_checks", + bp: ` + java_library { + name: "foo", + srcs: [ + "a.java", + ], + min_sdk_version: "29", + sdk_version: "current", + lint: { + warning_checks: ["NewApi"], + }, + } + `, + error: "lint.warning_checks: Can't treat \\[NewApi\\] checks as warnings if min_sdk_version is different from sdk_version.", + }, + { + name: "disable_checks", + bp: ` + java_library { + name: "foo", + srcs: [ + "a.java", + ], + min_sdk_version: "29", + sdk_version: "current", + lint: { + disabled_checks: ["NewApi"], + }, + } + `, + error: "lint.disabled_checks: Can't disable \\[NewApi\\] checks if min_sdk_version is different from sdk_version.", + }, + } + + for _, testCase := range testCases { + t.Run(testCase.name, func(t *testing.T) { + errorHandler := android.FixtureExpectsAtLeastOneErrorMatchingPattern(testCase.error) + android.GroupFixturePreparers(PrepareForTestWithJavaDefaultModules). + ExtendWithErrorHandler(errorHandler). + RunTestWithBp(t, testCase.bp) + }) + } +} |