fix a number of warnings found by Starlark analyzer
diff --git a/lib/unittest.bzl b/lib/unittest.bzl index de81a4d..116bb0a 100644 --- a/lib/unittest.bzl +++ b/lib/unittest.bzl
@@ -64,6 +64,12 @@ """Derives the name of the given rule implementation function. This can be used for better test feedback. + + Args: + impl: the rule implementation function + + Returns: + The name of the given function """ # Starlark currently stringifies a function as "<function NAME>", so we use @@ -123,6 +129,7 @@ _ActionInfo = provider(fields = ["actions"]) def _action_retrieving_aspect_impl(target, ctx): + _ignore = [ctx] return [_ActionInfo(actions = target.actions)] _action_retrieving_aspect = aspect( @@ -282,6 +289,9 @@ Args: env: The test environment returned by `analysistest.begin`. + + Returns: + A list of providers needed to automatically register the analysis test result. """ return [AnalysisTestResultInfo( success = (len(env.failures) == 0), @@ -296,6 +306,9 @@ Args: env: The test environment returned by `unittest.begin`. + + Returns: + A list of providers needed to automatically register the test result. """ tc = env.ctx.toolchains[TOOLCHAIN_TYPE].unittest_toolchain_info @@ -419,7 +432,6 @@ """ dep = _target_under_test(env) if AnalysisFailureInfo in dep: - dep_failure = dep[AnalysisFailureInfo] actual_errors = "" for cause in dep[AnalysisFailureInfo].causes.to_list(): actual_errors += cause.message + "\n" @@ -435,6 +447,9 @@ Args: env: The test environment returned by `analysistest.begin`. + + Returns: + A list of actions registered by the target under test """ # Validate? @@ -446,6 +461,9 @@ Args: env: The test environment returned by `analysistest.begin`. + + Returns: + The target under test. """ result = getattr(env.ctx.attr, "target_under_test") if types.is_list(result):
diff --git a/rules/analysis_test.bzl b/rules/analysis_test.bzl index 0ac404b..a43ef90 100644 --- a/rules/analysis_test.bzl +++ b/rules/analysis_test.bzl
@@ -16,6 +16,7 @@ def _analysis_test_impl(ctx): """Implementation function for analysis_test. """ + _ignore = [ctx] return [AnalysisTestResultInfo( success = True, message = "All targets succeeded analysis",
diff --git a/tests/unittest_tests.bzl b/tests/unittest_tests.bzl index 20fd890..01ea4de 100644 --- a/tests/unittest_tests.bzl +++ b/tests/unittest_tests.bzl
@@ -69,6 +69,7 @@ return analysistest.end(env) def _failure_testing_fake_rule(ctx): + ignore = [ctx] fail("This rule should never work") failure_testing_fake_rule = rule( @@ -92,6 +93,7 @@ return analysistest.end(env) def _fail_unexpected_passing_fake_rule(ctx): + _ignore = [ctx] return [] fail_unexpected_passing_fake_rule = rule( @@ -168,7 +170,8 @@ Not all tests are included. Some unittest.bzl tests verify a test fails when assertions are not met. Such tests must be run in an e2e shell test. - This suite only includes tests which verify success tests.""" + This suite only includes tests which verify success tests. + """ unittest.suite( "unittest_tests", basic_passing_test,