aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSamuel Freilich <sfreilich@google.com>2019-10-04 11:19:43 -0400
committerc-parsons <cparsons@google.com>2019-10-04 11:19:43 -0400
commitf1475299afd41815c78c3768253468ea622669f3 (patch)
treeb93c51f26ffe0c6ea40831052e729fabb4419847
parent720f59405d95c5052a8e16762a8fd2a4d50baded (diff)
downloadbazel-skylib-f1475299afd41815c78c3768253468ea622669f3.tar.gz
Avoid some repetition in _make_analysis_test (#197)
-rw-r--r--lib/unittest.bzl18
1 files changed, 8 insertions, 10 deletions
diff --git a/lib/unittest.bzl b/lib/unittest.bzl
index 986a807..873d8f0 100644
--- a/lib/unittest.bzl
+++ b/lib/unittest.bzl
@@ -193,20 +193,18 @@ def _make_analysis_test(
if expect_failure:
changed_settings["//command_line_option:allow_analysis_failures"] = "True"
+ target_attr_kwargs = {}
if changed_settings:
test_transition = analysis_test_transition(
settings = changed_settings,
)
- attrs["target_under_test"] = attr.label(
- aspects = [_action_retrieving_aspect],
- cfg = test_transition,
- mandatory = True,
- )
- else:
- attrs["target_under_test"] = attr.label(
- aspects = [_action_retrieving_aspect],
- mandatory = True,
- )
+ target_attr_kwargs["cfg"] = test_transition
+
+ attrs["target_under_test"] = attr.label(
+ aspects = [_action_retrieving_aspect],
+ mandatory = True,
+ **target_attr_kwargs
+ )
return rule(
impl,