Skip to content
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

tests: make some tests compatible with Bazel 9 fix various tests relying on Bazel builtin providers existing #2433

Merged
merged 1 commit into from
Nov 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion tests/base_rules/base_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ _produces_builtin_py_info = rule(
)

def _produces_py_info_impl(ctx):
return _create_py_info(ctx, BuiltinPyInfo)
return _create_py_info(ctx, PyInfo)

_produces_py_info = rule(
implementation = _produces_py_info_impl,
Expand Down Expand Up @@ -86,6 +86,9 @@ def _py_info_propagation_test_impl(env, target, provider_type):
info.imports().contains("custom-import")

def _test_py_info_propagation_builtin(name, config):
if not BuiltinPyInfo:
rt_util.skip_test(name = name)
return
_py_info_propagation_setup(
name,
config,
Expand Down
2 changes: 1 addition & 1 deletion tests/base_rules/py_info/py_info_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ def _provide_py_info_impl(ctx):
providers.append(PyInfo(**kwargs))

# Handle Bazel 6 or if Bazel autoloading is enabled
if not config.enable_pystar or PyInfo != BuiltinPyInfo:
if not config.enable_pystar or (BuiltinPyInfo and PyInfo != BuiltinPyInfo):
providers.append(BuiltinPyInfo(**{
k: kwargs[k]
for k in (
Expand Down
6 changes: 4 additions & 2 deletions tests/config_settings/transition/multi_version_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ def _test_py_test_with_transition(name):
def _test_py_test_with_transition_impl(env, target):
# Nothing to assert; we just want to make sure it builds
env.expect.that_target(target).has_provider(PyInfo)
env.expect.that_target(target).has_provider(BuiltinPyInfo)
if BuiltinPyInfo:
env.expect.that_target(target).has_provider(BuiltinPyInfo)

_tests.append(_test_py_test_with_transition)

Expand All @@ -70,7 +71,8 @@ def _test_py_binary_with_transition(name):
def _test_py_binary_with_transition_impl(env, target):
# Nothing to assert; we just want to make sure it builds
env.expect.that_target(target).has_provider(PyInfo)
env.expect.that_target(target).has_provider(BuiltinPyInfo)
if BuiltinPyInfo:
env.expect.that_target(target).has_provider(BuiltinPyInfo)

_tests.append(_test_py_binary_with_transition)

Expand Down
3 changes: 3 additions & 0 deletions tests/py_runtime_pair/py_runtime_pair_tests.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,9 @@ def _test_basic_impl(env, target):
_tests.append(_test_basic)

def _test_builtin_py_info_accepted(name):
if not BuiltinPyRuntimeInfo:
rt_util.skip_test(name = name)
return
rt_util.helper_target(
_provides_builtin_py_runtime_info,
name = name + "_runtime",
Expand Down