-
Notifications
You must be signed in to change notification settings - Fork 86
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix unit test attr forwarding #927
Conversation
rules/test.bzl
Outdated
test_attrs = {k: v for (k, v) in kwargs.items() if k not in _APPLE_BUNDLE_ATTRS} | ||
test_attrs = {k: v for (k, v) in kwargs.items() if k in _IOS_TEST_KWARGS} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This has been broken for a while it seems but afaik the right logic here is to grab the attrs for the unit test rule.. not what it was originally doing. Without this change features
is dropped because it appars in _APPLE_BUNDLE_ATTRS
(because every rule supports the features
attr).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
My guess is this might have been to support custom rules with attributes unknown to this macro?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated this to maintain the original logic with the addition of including implicit rule attrs as well (like features
)
The `test.bzl` macros were incorrectly forwarding some of the attrs like `features`. This was leading to silent errors where things passed via `features` were dropped (such as main thread checking). This PR fixes the macro by properly forwarding ALL supported unit test attrs to the unit test rule.
5c042d8
to
37659c1
Compare
@@ -45,6 +43,22 @@ _APPLE_BUNDLE_ATTRS = { | |||
] | |||
} | |||
|
|||
# See: https://bazel.build/reference/be/common-definitions#common-attributes |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
so if bazel's newer version contains new common attribute, we need to update this list right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally yeah, however most of these attrs are unused
@@ -104,7 +118,7 @@ def _make_test(name, test_rule, **kwargs): | |||
Helper to create an individual test | |||
""" | |||
runner = kwargs.pop("runner", None) or _DEFAULT_APPLE_TEST_RUNNER | |||
test_attrs = {k: v for (k, v) in kwargs.items() if k not in _APPLE_BUNDLE_ATTRS} | |||
test_attrs = {k: v for (k, v) in kwargs.items() if (k not in _APPLE_BUNDLE_ATTRS) or (k in _ALWAYS_AVAILABLE_ATTRS)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
when downstream project point to this commit, probably worth printing out what is dropped before VS after, to see if anything other than features
are dropped also
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you mean adding a print
here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah but do it temp. during the testing
The
test.bzl
macros were incorrectly forwarding some of the attrs likefeatures
. This was leading to silent errors where things passed viafeatures
were dropped (such as main thread checking). This PR fixes the macro by properly forwarding ALL supported unit test attrs to the unit test rule.