Skip to content

Commit

Permalink
tests: make some tests compatible with Bazel 9 fix various tests rely…
Browse files Browse the repository at this point in the history
…ing on Bazel builtin providers existing (#2433)

In Bazel 9, the builtin symbols don't exist. This fixes some tests that
fail when those symbols
are missing.
  • Loading branch information
rickeylev authored Nov 22, 2024
1 parent fe3f7a4 commit 5913816
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 4 deletions.
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

0 comments on commit 5913816

Please sign in to comment.