-
Notifications
You must be signed in to change notification settings - Fork 89
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,6 @@ _IOS_TEST_KWARGS = [ | |
"bundle_id", | ||
"bundle_name", | ||
"env", | ||
"features", | ||
"flaky", | ||
"frameworks", | ||
"infoplists", | ||
|
@@ -34,7 +33,6 @@ _APPLE_BUNDLE_ATTRS = { | |
"bundle_id", | ||
"bundle_name", | ||
"families", | ||
"features", | ||
"frameworks", | ||
"infoplists", | ||
"linkopts", | ||
|
@@ -45,6 +43,22 @@ _APPLE_BUNDLE_ATTRS = { | |
] | ||
} | ||
|
||
# See: https://bazel.build/reference/be/common-definitions#common-attributes | ||
# NOTE: `testonly` arent listed because we have custom logic for them in here. | ||
_ALWAYS_AVAILABLE_ATTRS = [ | ||
"compatible_with", | ||
"deprecation", | ||
"distribs", | ||
"exec_compatible_with", | ||
"exec_properties", | ||
"features", | ||
"restricted_to", | ||
"tags", | ||
"target_compatible_with", | ||
"toolchains", | ||
"visibility", | ||
] | ||
|
||
_DEFAULT_APPLE_TEST_RUNNER = "@build_bazel_rules_apple//apple/testing/default_runner:ios_default_runner" | ||
|
||
def _make_runner_split(name, runner, **in_split): | ||
|
@@ -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 commentThe 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 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do you mean adding a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yeah but do it temp. during the testing |
||
|
||
test_rule( | ||
name = name, | ||
|
@@ -159,7 +173,7 @@ def _ios_test(name, bundle_rule, test_rule, test_factory, apple_library, infopli | |
""" | ||
|
||
testonly = kwargs.pop("testonly", True) | ||
ios_test_kwargs = {arg: kwargs.pop(arg) for arg in _IOS_TEST_KWARGS if arg in kwargs} | ||
ios_test_kwargs = {arg: kwargs.pop(arg) for arg in (_IOS_TEST_KWARGS + _ALWAYS_AVAILABLE_ATTRS) if arg in kwargs} | ||
ios_test_kwargs["data"] = kwargs.pop("test_data", []) | ||
|
||
test_exec_properties = kwargs.pop("test_exec_properties", None) | ||
|
@@ -218,7 +232,7 @@ def _ios_test(name, bundle_rule, test_rule, test_factory, apple_library, infopli | |
|
||
# Set this to a single __internal__ test bundle. | ||
test_bundle_name = name + ".__internal__.__test_bundle" | ||
bundle_attrs = {k: v for (k, v) in ios_test_kwargs.items() if k in _APPLE_BUNDLE_ATTRS} | ||
bundle_attrs = {k: v for (k, v) in ios_test_kwargs.items() if (k in _APPLE_BUNDLE_ATTRS) or (k in _ALWAYS_AVAILABLE_ATTRS)} | ||
bundle_name = bundle_attrs.pop("bundle_name", name) | ||
bundle_rule( | ||
name = test_bundle_name, | ||
|
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