diff --git a/docs/BUILD.bazel b/docs/BUILD.bazel index d3d32485..5958d6cd 100644 --- a/docs/BUILD.bazel +++ b/docs/BUILD.bazel @@ -3,8 +3,8 @@ load("@aspect_bazel_lib//lib:docs.bzl", "stardoc_with_diff_test", "update_docs") stardoc_with_diff_test( - name = "assert_no_lint_warnings", - bzl_library_target = "//lint:assert_no_lint_warnings", + name = "lint_test", + bzl_library_target = "//lint:lint_test", ) stardoc_with_diff_test( diff --git a/docs/assert_no_lint_warnings.md b/docs/lint_test.md similarity index 69% rename from docs/assert_no_lint_warnings.md rename to docs/lint_test.md index 4b368f5a..78caf2bb 100644 --- a/docs/assert_no_lint_warnings.md +++ b/docs/lint_test.md @@ -9,7 +9,7 @@ To use this, in your `lint.bzl` where you define the aspect, just create a test For example, with `flake8`: ```starlark -load("@aspect_rules_lint//lint:assert_no_lint_warnings.bzl", "assert_no_lint_warnings") +load("@aspect_rules_lint//lint:lint_test.bzl", "make_lint_test") load("@aspect_rules_lint//lint:flake8.bzl", "flake8_aspect") flake8 = flake8_aspect( @@ -17,7 +17,7 @@ flake8 = flake8_aspect( config = "@@//:.flake8", ) -flake8_test = assert_no_lint_warnings(aspect = flake8) +flake8_test = make_lint_test(aspect = flake8) ``` Now in your BUILD files you can add a test: @@ -37,12 +37,12 @@ flake8_test( ``` - + -## assert_no_lint_warnings +## make_lint_test
-assert_no_lint_warnings(aspect) +make_lint_test(aspect)@@ -52,6 +52,6 @@ assert_no_lint_warnings(aspect) | Name | Description | Default Value | | :------------- | :------------- | :------------- | -| aspect |
-
| none | +| aspect |-
| none | diff --git a/example/tools/lint.bzl b/example/tools/lint.bzl index ace6bc20..4e0dd113 100644 --- a/example/tools/lint.bzl +++ b/example/tools/lint.bzl @@ -1,9 +1,9 @@ "Define linter aspects" -load("@aspect_rules_lint//lint:assert_no_lint_warnings.bzl", "assert_no_lint_warnings") load("@aspect_rules_lint//lint:buf.bzl", "buf_lint_aspect") load("@aspect_rules_lint//lint:eslint.bzl", "eslint_aspect") load("@aspect_rules_lint//lint:flake8.bzl", "flake8_aspect") +load("@aspect_rules_lint//lint:lint_test.bzl", "make_lint_test") load("@aspect_rules_lint//lint:pmd.bzl", "pmd_aspect") buf = buf_lint_aspect( @@ -20,11 +20,11 @@ flake8 = flake8_aspect( config = "@@//:.flake8", ) -flake8_test = assert_no_lint_warnings(aspect = flake8) +flake8_test = make_lint_test(aspect = flake8) pmd = pmd_aspect( binary = "@@//:pmd", rulesets = ["@@//:pmd.xml"], ) -pmd_test = assert_no_lint_warnings(aspect = pmd) +pmd_test = make_lint_test(aspect = pmd) diff --git a/lint/BUILD.bazel b/lint/BUILD.bazel index bf0ad844..564c0b5b 100644 --- a/lint/BUILD.bazel +++ b/lint/BUILD.bazel @@ -1,6 +1,6 @@ load("@bazel_skylib//:bzl_library.bzl", "bzl_library") -exports_files(glob(["*.bzl"]) + ["assert_no_lint_warnings.sh"]) +exports_files(glob(["*.bzl"]) + ["lint_test.sh"]) bzl_library( name = "buf", @@ -20,8 +20,8 @@ bzl_library( ) bzl_library( - name = "assert_no_lint_warnings", - srcs = ["assert_no_lint_warnings.bzl"], + name = "lint_test", + srcs = ["lint_test.bzl"], visibility = ["//visibility:public"], deps = ["@aspect_bazel_lib//lib:paths"], ) diff --git a/lint/assert_no_lint_warnings.bzl b/lint/lint_test.bzl similarity index 76% rename from lint/assert_no_lint_warnings.bzl rename to lint/lint_test.bzl index cd0dceb1..1affa4cf 100644 --- a/lint/assert_no_lint_warnings.bzl +++ b/lint/lint_test.bzl @@ -7,7 +7,7 @@ To use this, in your `lint.bzl` where you define the aspect, just create a test For example, with `flake8`: ```starlark -load("@aspect_rules_lint//lint:assert_no_lint_warnings.bzl", "assert_no_lint_warnings") +load("@aspect_rules_lint//lint:lint_test.bzl", "make_lint_test") load("@aspect_rules_lint//lint:flake8.bzl", "flake8_aspect") flake8 = flake8_aspect( @@ -15,7 +15,7 @@ flake8 = flake8_aspect( config = "@@//:.flake8", ) -flake8_test = assert_no_lint_warnings(aspect = flake8) +flake8_test = make_lint_test(aspect = flake8) ``` Now in your BUILD files you can add a test: @@ -43,7 +43,7 @@ def _test_impl(ctx): for report in src[OutputGroupInfo].report.to_list(): reports.append(report) - bin = ctx.actions.declare_file("assert_no_lint_warnings.sh") + bin = ctx.actions.declare_file("lint_test.sh") ctx.actions.expand_template( template = ctx.file._bin, output = bin, @@ -55,13 +55,15 @@ def _test_impl(ctx): runfiles = ctx.runfiles(reports + [ctx.file._runfiles_lib]), )] -def assert_no_lint_warnings(aspect): +def make_lint_test(aspect): return rule( implementation = _test_impl, attrs = { "srcs": attr.label_list(doc = "*_library targets", aspects = [aspect]), + # Note, we don't use this in the test, but the user passes an aspect that has this aspect_attribute, + # and that requires that we list it here as well. "fail_on_violation": attr.bool(), - "_bin": attr.label(default = ":assert_no_lint_warnings.sh", allow_single_file = True, executable = True, cfg = "exec"), + "_bin": attr.label(default = ":lint_test.sh", allow_single_file = True, executable = True, cfg = "exec"), "_runfiles_lib": attr.label(default = "@bazel_tools//tools/bash/runfiles", allow_single_file = True), }, test = True, diff --git a/lint/assert_no_lint_warnings.sh b/lint/lint_test.sh similarity index 100% rename from lint/assert_no_lint_warnings.sh rename to lint/lint_test.sh