From 8a68934c2d66d69415fdadccef048aaf0e78efa8 Mon Sep 17 00:00:00 2001 From: Martin Medler Date: Thu, 28 Dec 2023 11:28:48 +0100 Subject: [PATCH] Less repetition and better naming for integration test aspects --- test/aspect/aspect.bzl | 3 ++- test/aspect/implementation_deps/aspect.bzl | 3 --- test/aspect/implementation_deps/test_proper_deps.py | 2 +- .../implementation_deps/test_superfluous_public_dep.py | 2 +- test/aspect/recursion/aspect.bzl | 4 ++-- test/aspect/recursion/rule.bzl | 10 +++++----- .../recursion/test_find_transitive_problem_via_deps.py | 2 +- .../test_find_transitive_problem_via_iml_deps.py | 2 +- test/aspect/skip_tags/aspect.bzl | 2 +- test/aspect/skip_tags/test_skip_custom_tag.py | 2 +- test/aspect/test_case.py | 2 +- test/aspect/unused_dep/aspect.bzl | 3 --- test/aspect/unused_dep/test_detect_unused_impl_dep.py | 2 +- test/aspect/using_transitive_dep/aspect.bzl | 3 --- .../test_detect_using_transitive_impl_dep.py | 2 +- 15 files changed, 18 insertions(+), 26 deletions(-) delete mode 100644 test/aspect/implementation_deps/aspect.bzl delete mode 100644 test/aspect/unused_dep/aspect.bzl delete mode 100644 test/aspect/using_transitive_dep/aspect.bzl diff --git a/test/aspect/aspect.bzl b/test/aspect/aspect.bzl index aaad17ce..af951ad4 100644 --- a/test/aspect/aspect.bzl +++ b/test/aspect/aspect.bzl @@ -1,3 +1,4 @@ load("//:defs.bzl", "dwyu_aspect_factory") -dwyu_default_aspect = dwyu_aspect_factory() +dwyu = dwyu_aspect_factory() +dwyu_impl_deps = dwyu_aspect_factory(use_implementation_deps = True) diff --git a/test/aspect/implementation_deps/aspect.bzl b/test/aspect/implementation_deps/aspect.bzl deleted file mode 100644 index 46686e05..00000000 --- a/test/aspect/implementation_deps/aspect.bzl +++ /dev/null @@ -1,3 +0,0 @@ -load("//:defs.bzl", "dwyu_aspect_factory") - -implementation_deps_aspect = dwyu_aspect_factory(use_implementation_deps = True) diff --git a/test/aspect/implementation_deps/test_proper_deps.py b/test/aspect/implementation_deps/test_proper_deps.py index 3f2ab4ac..3bf09764 100644 --- a/test/aspect/implementation_deps/test_proper_deps.py +++ b/test/aspect/implementation_deps/test_proper_deps.py @@ -11,7 +11,7 @@ def execute_test_logic(self) -> Result: "//test/aspect/implementation_deps:binary_using_foo", "//test/aspect/implementation_deps:test_using_foo", ], - aspect="//test/aspect/implementation_deps:aspect.bzl%implementation_deps_aspect", + aspect="//test/aspect:aspect.bzl%dwyu_impl_deps", extra_args=["--experimental_cc_implementation_deps"], ) diff --git a/test/aspect/implementation_deps/test_superfluous_public_dep.py b/test/aspect/implementation_deps/test_superfluous_public_dep.py index 2bc6ee50..93b66080 100644 --- a/test/aspect/implementation_deps/test_superfluous_public_dep.py +++ b/test/aspect/implementation_deps/test_superfluous_public_dep.py @@ -7,7 +7,7 @@ def execute_test_logic(self) -> Result: expected = ExpectedResult(success=False, deps_which_should_be_private=["//test/aspect/implementation_deps:foo"]) actual = self._run_dwyu( target="//test/aspect/implementation_deps:superfluous_public_dep", - aspect="//test/aspect/implementation_deps:aspect.bzl%implementation_deps_aspect", + aspect="//test/aspect:aspect.bzl%dwyu_impl_deps", extra_args=["--experimental_cc_implementation_deps"], ) diff --git a/test/aspect/recursion/aspect.bzl b/test/aspect/recursion/aspect.bzl index 522b789f..b6df64c1 100644 --- a/test/aspect/recursion/aspect.bzl +++ b/test/aspect/recursion/aspect.bzl @@ -1,4 +1,4 @@ load("//:defs.bzl", "dwyu_aspect_factory") -recursive_aspect = dwyu_aspect_factory(recursive = True) -recursive_impl_deps_aspect = dwyu_aspect_factory(recursive = True, use_implementation_deps = True) +dwyu_recursive = dwyu_aspect_factory(recursive = True) +dwyu_recursive_impl_deps = dwyu_aspect_factory(recursive = True, use_implementation_deps = True) diff --git a/test/aspect/recursion/rule.bzl b/test/aspect/recursion/rule.bzl index 2e71618e..8bdae77f 100644 --- a/test/aspect/recursion/rule.bzl +++ b/test/aspect/recursion/rule.bzl @@ -1,5 +1,5 @@ -load("//test/aspect:aspect.bzl", "dwyu_default_aspect") -load("//test/aspect/recursion:aspect.bzl", "recursive_aspect", "recursive_impl_deps_aspect") +load("//test/aspect:aspect.bzl", "dwyu") +load("//test/aspect/recursion:aspect.bzl", "dwyu_recursive", "dwyu_recursive_impl_deps") def _dwyu_rule_impl(ctx): # gather artifacts to make sure the aspect is executed @@ -9,20 +9,20 @@ def _dwyu_rule_impl(ctx): dwyu_rule_direct = rule( implementation = _dwyu_rule_impl, attrs = { - "deps": attr.label_list(aspects = [dwyu_default_aspect]), + "deps": attr.label_list(aspects = [dwyu]), }, ) dwyu_rule_recursive = rule( implementation = _dwyu_rule_impl, attrs = { - "deps": attr.label_list(aspects = [recursive_aspect]), + "deps": attr.label_list(aspects = [dwyu_recursive]), }, ) dwyu_rule_recursive_with_impl_deps = rule( implementation = _dwyu_rule_impl, attrs = { - "deps": attr.label_list(aspects = [recursive_impl_deps_aspect]), + "deps": attr.label_list(aspects = [dwyu_recursive_impl_deps]), }, ) diff --git a/test/aspect/recursion/test_find_transitive_problem_via_deps.py b/test/aspect/recursion/test_find_transitive_problem_via_deps.py index c901ec34..650027c8 100644 --- a/test/aspect/recursion/test_find_transitive_problem_via_deps.py +++ b/test/aspect/recursion/test_find_transitive_problem_via_deps.py @@ -6,7 +6,7 @@ class TestCase(TestCaseBase): def execute_test_logic(self) -> Result: expected = ExpectedResult(success=False, unused_public_deps=["//test/aspect/recursion:e"]) actual = self._run_dwyu( - target="//test/aspect/recursion:main", aspect="//test/aspect/recursion:aspect.bzl%recursive_aspect" + target="//test/aspect/recursion:main", aspect="//test/aspect/recursion:aspect.bzl%dwyu_recursive" ) return self._check_result(actual=actual, expected=expected) diff --git a/test/aspect/recursion/test_find_transitive_problem_via_iml_deps.py b/test/aspect/recursion/test_find_transitive_problem_via_iml_deps.py index d35ef8ee..85811621 100644 --- a/test/aspect/recursion/test_find_transitive_problem_via_iml_deps.py +++ b/test/aspect/recursion/test_find_transitive_problem_via_iml_deps.py @@ -7,7 +7,7 @@ def execute_test_logic(self) -> Result: expected = ExpectedResult(success=False, unused_public_deps=["//test/aspect/recursion:e"]) actual = self._run_dwyu( target="//test/aspect/recursion:use_impl_deps", - aspect="//test/aspect/recursion:aspect.bzl%recursive_impl_deps_aspect", + aspect="//test/aspect/recursion:aspect.bzl%dwyu_recursive_impl_deps", extra_args=["--experimental_cc_implementation_deps"], ) diff --git a/test/aspect/skip_tags/aspect.bzl b/test/aspect/skip_tags/aspect.bzl index 12d74d82..008463c1 100644 --- a/test/aspect/skip_tags/aspect.bzl +++ b/test/aspect/skip_tags/aspect.bzl @@ -1,3 +1,3 @@ load("//:defs.bzl", "dwyu_aspect_factory") -test_aspect = dwyu_aspect_factory(skipped_tags = ["tag_marking_skipping"]) +dwyu_custom_tags = dwyu_aspect_factory(skipped_tags = ["tag_marking_skipping"]) diff --git a/test/aspect/skip_tags/test_skip_custom_tag.py b/test/aspect/skip_tags/test_skip_custom_tag.py index 5321e31e..723feec0 100644 --- a/test/aspect/skip_tags/test_skip_custom_tag.py +++ b/test/aspect/skip_tags/test_skip_custom_tag.py @@ -7,7 +7,7 @@ def execute_test_logic(self) -> Result: expected = ExpectedResult(success=True) actual = self._run_dwyu( target="//test/aspect/skip_tags:ignored_by_custom_tag", - aspect="//test/aspect/skip_tags:aspect.bzl%test_aspect", + aspect="//test/aspect/skip_tags:aspect.bzl%dwyu_custom_tags", ) return self._check_result(actual=actual, expected=expected) diff --git a/test/aspect/test_case.py b/test/aspect/test_case.py index 784a3851..7bfd5054 100644 --- a/test/aspect/test_case.py +++ b/test/aspect/test_case.py @@ -47,7 +47,7 @@ def name(self) -> str: @property def default_aspect(self) -> str: - return "//test/aspect:aspect.bzl%dwyu_default_aspect" + return "//test/aspect:aspect.bzl%dwyu" def execute_test(self, version: TestedVersions, output_base: Path, extra_args: List[str]) -> Result: self._tested_versions = version diff --git a/test/aspect/unused_dep/aspect.bzl b/test/aspect/unused_dep/aspect.bzl deleted file mode 100644 index 46686e05..00000000 --- a/test/aspect/unused_dep/aspect.bzl +++ /dev/null @@ -1,3 +0,0 @@ -load("//:defs.bzl", "dwyu_aspect_factory") - -implementation_deps_aspect = dwyu_aspect_factory(use_implementation_deps = True) diff --git a/test/aspect/unused_dep/test_detect_unused_impl_dep.py b/test/aspect/unused_dep/test_detect_unused_impl_dep.py index d469280c..43060a6c 100644 --- a/test/aspect/unused_dep/test_detect_unused_impl_dep.py +++ b/test/aspect/unused_dep/test_detect_unused_impl_dep.py @@ -7,7 +7,7 @@ def execute_test_logic(self) -> Result: expected = ExpectedResult(success=False, unused_private_deps=["//test/aspect/unused_dep:foo"]) actual = self._run_dwyu( target="//test/aspect/unused_dep/implementation_deps:implementation_deps_lib", - aspect="//test/aspect/unused_dep:aspect.bzl%implementation_deps_aspect", + aspect="//test/aspect:aspect.bzl%dwyu_impl_deps", extra_args=["--experimental_cc_implementation_deps"], ) diff --git a/test/aspect/using_transitive_dep/aspect.bzl b/test/aspect/using_transitive_dep/aspect.bzl deleted file mode 100644 index 46686e05..00000000 --- a/test/aspect/using_transitive_dep/aspect.bzl +++ /dev/null @@ -1,3 +0,0 @@ -load("//:defs.bzl", "dwyu_aspect_factory") - -implementation_deps_aspect = dwyu_aspect_factory(use_implementation_deps = True) diff --git a/test/aspect/using_transitive_dep/test_detect_using_transitive_impl_dep.py b/test/aspect/using_transitive_dep/test_detect_using_transitive_impl_dep.py index 62695ec1..1223f05a 100644 --- a/test/aspect/using_transitive_dep/test_detect_using_transitive_impl_dep.py +++ b/test/aspect/using_transitive_dep/test_detect_using_transitive_impl_dep.py @@ -12,7 +12,7 @@ def execute_test_logic(self) -> Result: ) actual = self._run_dwyu( target="//test/aspect/using_transitive_dep:transitive_usage_through_impl_deps", - aspect="//test/aspect/using_transitive_dep:aspect.bzl%implementation_deps_aspect", + aspect="//test/aspect:aspect.bzl%dwyu_impl_deps", extra_args=["--experimental_cc_implementation_deps"], )