Skip to content

Commit

Permalink
Less repetition and better naming for integration test aspects
Browse files Browse the repository at this point in the history
  • Loading branch information
martis42 committed Dec 28, 2023
1 parent c06b4cb commit 8a68934
Show file tree
Hide file tree
Showing 15 changed files with 18 additions and 26 deletions.
3 changes: 2 additions & 1 deletion test/aspect/aspect.bzl
Original file line number Diff line number Diff line change
@@ -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)
3 changes: 0 additions & 3 deletions test/aspect/implementation_deps/aspect.bzl

This file was deleted.

2 changes: 1 addition & 1 deletion test/aspect/implementation_deps/test_proper_deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)

Expand Down
4 changes: 2 additions & 2 deletions test/aspect/recursion/aspect.bzl
Original file line number Diff line number Diff line change
@@ -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)
10 changes: 5 additions & 5 deletions test/aspect/recursion/rule.bzl
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]),
},
)
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)

Expand Down
2 changes: 1 addition & 1 deletion test/aspect/skip_tags/aspect.bzl
Original file line number Diff line number Diff line change
@@ -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"])
2 changes: 1 addition & 1 deletion test/aspect/skip_tags/test_skip_custom_tag.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
2 changes: 1 addition & 1 deletion test/aspect/test_case.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions test/aspect/unused_dep/aspect.bzl

This file was deleted.

2 changes: 1 addition & 1 deletion test/aspect/unused_dep/test_detect_unused_impl_dep.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)

Expand Down
3 changes: 0 additions & 3 deletions test/aspect/using_transitive_dep/aspect.bzl

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -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"],
)

Expand Down

0 comments on commit 8a68934

Please sign in to comment.