Fix type parsing errors on "always true" conditions. (#239)

Specifically:

selects.config_setting_group(
    name = "always_true",
    match_any = ["//conditions:default"],
)

and

selects.config_setting_group(
    name = "always_true",
    match_all = ["//conditions:default"],
)

These should, as expected, always evaluate to True.
Their implementation had a bug that failed the build outright.
This commit is contained in:
Greg 2020-03-25 14:05:24 -04:00 committed by GitHub
parent 2d620ba1f8
commit dfcfe82500
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 2 deletions

View File

@ -234,11 +234,11 @@ def _config_setting_always_true(name, visibility):
name_off = name + "_stamp_binary_off_check"
native.config_setting(
name = name_on,
values = {"stamp": True},
values = {"stamp": "1"},
)
native.config_setting(
name = name_off,
values = {"stamp": False},
values = {"stamp": "0"},
)
return _config_setting_or_group(name, [":" + name_on, ":" + name_off], visibility)

View File

@ -540,6 +540,54 @@ def _or_config_setting_group_single_setting_fails_test():
target_under_test = ":or_config_setting_group_single_setting_fails_rule",
)
###################################################
# always_true_match_all_test
###################################################
always_true_match_all_test = analysistest.make(_expect_matches)
def _always_true_match_all_test():
"""Tests that "match_all=['//conditions:default']" always matches."""
selects.config_setting_group(
name = "all_always_match",
match_all = ["//conditions:default"],
)
boolean_attr_rule(
name = "match_always_true_rule",
myboolean = select(
{
":all_always_match": True,
},
),
)
always_true_match_all_test(
name = "always_true_match_all_test",
target_under_test = ":match_always_true_rule",
)
###################################################
# always_true_match_any_test
###################################################
always_true_match_any_test = analysistest.make(_expect_matches)
def _always_true_match_any_test():
"""Tests that "match_any=['//conditions:default']" always matches."""
selects.config_setting_group(
name = "any_always_match",
match_any = ["//conditions:default"],
)
boolean_attr_rule(
name = "match_any_always_true_rule",
myboolean = select(
{
":any_always_match": True,
},
),
)
always_true_match_any_test(
name = "always_true_match_any_test",
target_under_test = ":match_any_always_true_rule",
)
###################################################
# empty_config_setting_group_not_allowed_test
###################################################
@ -587,5 +635,8 @@ def selects_test_suite():
_or_config_setting_group_single_setting_matches_test()
_or_config_setting_group_single_setting_fails_test()
_always_true_match_all_test()
_always_true_match_any_test()
# _empty_config_setting_group_not_allowed_test()
# _and_and_or_not_allowed_together_test()