Skip to content

Commit

Permalink
Run Android Lint against the sources in rules_android_lint (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bencodes authored Oct 25, 2023
1 parent 082f0a4 commit 6ed9412
Show file tree
Hide file tree
Showing 5 changed files with 63 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .bazelrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Required until this is the default; expected in Bazel 7
common --enable_bzlmod
common --experimental_google_legacy_api

try-import %workspace%/.bazelrc.user
8 changes: 8 additions & 0 deletions src/cli/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("@rules_java//java:defs.bzl", "java_binary")
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test")
load("//rules:defs.bzl", "android_lint_test")

java_binary(
name = "cli",
Expand Down Expand Up @@ -32,3 +33,10 @@ ktlint_fix(
config = "//:editorconfig",
visibility = ["//visibility:private"],
)

android_lint_test(
name = "lint_lint_test",
srcs = glob(["*.kt"]),
lib = ":lint",
visibility = ["//visibility:private"],
)
12 changes: 10 additions & 2 deletions src/worker/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_library")
load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test")
load("//rules:defs.bzl", "android_lint_test")

kt_jvm_library(
name = "worker",
Expand All @@ -15,15 +16,22 @@ kt_jvm_library(
)

ktlint_test(
name = "lint_ktlint_test",
name = "worker_ktlint_test",
srcs = glob(["*.kt"]),
config = "//:editorconfig",
visibility = ["//visibility:private"],
)

ktlint_fix(
name = "lint_ktlint_fix",
name = "worker_ktlint_fix",
srcs = glob(["*.kt"]),
config = "//:editorconfig",
visibility = ["//visibility:private"],
)

android_lint_test(
name = "worker_lint_test",
srcs = glob(["*.kt"]),
lib = ":worker",
visibility = ["//visibility:private"],
)
29 changes: 29 additions & 0 deletions tests/src/cli/BUILD
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test")
load("@rules_kotlin//kotlin:lint.bzl", "ktlint_fix", "ktlint_test")
load("//rules:defs.bzl", "android_lint_test")

kt_jvm_test(
name = "AndroidLintActionArgsTest",
Expand All @@ -12,6 +13,13 @@ kt_jvm_test(
],
)

android_lint_test(
name = "AndroidLintActionArgsTest_lint_test",
srcs = ["AndroidLintActionArgsTest.kt"],
lib = ":AndroidLintActionArgsTest",
visibility = ["//visibility:private"],
)

kt_jvm_test(
name = "AndroidLintActionTest",
srcs = ["AndroidLintActionTest.kt"],
Expand All @@ -23,6 +31,13 @@ kt_jvm_test(
],
)

android_lint_test(
name = "AndroidLintActionTest_lint_test",
srcs = ["AndroidLintActionTest.kt"],
lib = ":AndroidLintActionTest",
visibility = ["//visibility:private"],
)

kt_jvm_test(
name = "AndroidLintProjectTest",
srcs = ["AndroidLintProjectTest.kt"],
Expand All @@ -34,6 +49,13 @@ kt_jvm_test(
],
)

android_lint_test(
name = "AndroidLintProjectTest_lint_test",
srcs = ["AndroidLintProjectTest.kt"],
lib = ":AndroidLintProjectTest",
visibility = ["//visibility:private"],
)

kt_jvm_test(
name = "AndroidLintBaselineSanitizerTest",
srcs = ["AndroidLintBaselineSanitizerTest.kt"],
Expand All @@ -45,6 +67,13 @@ kt_jvm_test(
],
)

android_lint_test(
name = "AndroidLintBaselineSanitizerTest_lint_test",
srcs = ["AndroidLintBaselineSanitizerTest.kt"],
lib = ":AndroidLintBaselineSanitizerTest",
visibility = ["//visibility:private"],
)

ktlint_test(
name = "lint_ktlint_test",
srcs = glob(["*.kt"]),
Expand Down
15 changes: 15 additions & 0 deletions tests/src/worker/BUILD
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
load("@rules_kotlin//kotlin:jvm.bzl", "kt_jvm_test")
load("//rules:defs.bzl", "android_lint_test")

kt_jvm_test(
name = "WorkerIOTest",
Expand All @@ -22,6 +23,20 @@ kt_jvm_test(
],
)

android_lint_test(
name = "WorkerIOTest_lint_test",
srcs = ["WorkerIOTest.kt"],
lib = ":WorkerIOTest",
visibility = ["//visibility:private"],
)

android_lint_test(
name = "WorkerJsonMessageProcessorTest_lint_test",
srcs = ["WorkerJsonMessageProcessorTest.kt"],
lib = ":WorkerJsonMessageProcessorTest",
visibility = ["//visibility:private"],
)

test_suite(
name = "tests",
tests = [
Expand Down

0 comments on commit 6ed9412

Please sign in to comment.