Enable Android Lint tests for AndroidFrameworkLintChecker
Create AndroidFrameworkLintCheckerTest module and add .allowMissingSdk(true) to all tests to enable tests running on gerrit. "unit_test: true" marks the module as a unit test target which runs it on the host without a device and it automatically gets onboarded in the presubmit. Bug: 157626959 Test: atest AndroidFrameworkLintCheckerTest --host Change-Id: I66c6e331e72dfca45d341a49eb43fbd73ccd28ff
This commit is contained in:
@@ -31,16 +31,16 @@ java_library_host {
|
||||
],
|
||||
}
|
||||
|
||||
// TODO: (b/162368644) Implement these (working in gradle) Kotlin Tests to run on Soong
|
||||
//java_test_host {
|
||||
// name: "AndroidFrameworkLintCheckerTest",
|
||||
// srcs: [
|
||||
// "checks/src/test/java/**/*.kt",
|
||||
// "checks/src/main/java/**/*.kt",
|
||||
// ],
|
||||
// plugins: ["auto_service_plugin"],
|
||||
// static_libs: [
|
||||
// "auto_service_annotations",
|
||||
// "lint_api",
|
||||
// ],
|
||||
//}
|
||||
java_test_host {
|
||||
name: "AndroidFrameworkLintCheckerTest",
|
||||
srcs: ["checks/src/test/java/**/*.kt"],
|
||||
static_libs: [
|
||||
"AndroidFrameworkLintChecker",
|
||||
"junit",
|
||||
"lint",
|
||||
"lint_tests",
|
||||
],
|
||||
test_options: {
|
||||
unit_test: true,
|
||||
},
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.google.android.lint
|
||||
|
||||
import com.android.tools.lint.checks.infrastructure.LintDetectorTest
|
||||
import com.android.tools.lint.checks.infrastructure.TestFile
|
||||
import com.android.tools.lint.checks.infrastructure.TestLintTask
|
||||
import com.android.tools.lint.detector.api.Detector
|
||||
import com.android.tools.lint.detector.api.Issue
|
||||
|
||||
@@ -34,6 +35,8 @@ class CallingIdentityTokenDetectorTest : LintDetectorTest() {
|
||||
CallingIdentityTokenDetector.ISSUE_CLEAR_IDENTITY_CALL_NOT_FOLLOWED_BY_TRY_FINALLY
|
||||
)
|
||||
|
||||
override fun lint(): TestLintTask = super.lint().allowMissingSdk(true)
|
||||
|
||||
/** No issue scenario */
|
||||
|
||||
fun testDoesNotDetectIssuesInCorrectScenario() {
|
||||
|
||||
Reference in New Issue
Block a user