Skip to content

Commit 0d59fcf

Browse files
authored
tests: make analysis tests support --incompatible_enable_cc_toolchain_resolution (#1281)
The analysis tests transition to different platforms to test some platform-specific logic. When cc toolchain registration is enabled, this also requires that a more complete toolchain be defined and available.
1 parent 00962c4 commit 0d59fcf

File tree

2 files changed

+17
-0
lines changed

2 files changed

+17
-0
lines changed

tools/build_defs/python/tests/BUILD.bazel

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,13 @@ cc_toolchain(
5353
toolchain_identifier = "mac-toolchain",
5454
)
5555

56+
toolchain(
57+
name = "mac_toolchain_definition",
58+
target_compatible_with = ["@platforms//os:macos"],
59+
toolchain = ":mac_toolchain",
60+
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
61+
)
62+
5663
fake_cc_toolchain_config(
5764
name = "mac_toolchain_config",
5865
target_cpu = "darwin_x86_64",
@@ -72,6 +79,13 @@ cc_toolchain(
7279
toolchain_identifier = "linux-toolchain",
7380
)
7481

82+
toolchain(
83+
name = "linux_toolchain_definition",
84+
target_compatible_with = ["@platforms//os:linux"],
85+
toolchain = ":linux_toolchain",
86+
toolchain_type = "@bazel_tools//tools/cpp:toolchain_type",
87+
)
88+
7589
fake_cc_toolchain_config(
7690
name = "linux_toolchain_config",
7791
target_cpu = "k8",

tools/build_defs/python/tests/py_test/py_test_tests.bzl

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ load("//tools/build_defs/python/tests:util.bzl", pt_util = "util")
2525
# Explicit Label() calls are required so that it resolves in @rules_python context instead of
2626
# @rules_testing context.
2727
_FAKE_CC_TOOLCHAIN = Label("//tools/build_defs/python/tests:cc_toolchain_suite")
28+
_FAKE_CC_TOOLCHAINS = [str(Label("//tools/build_defs/python/tests:all"))]
2829
_PLATFORM_MAC = Label("//tools/build_defs/python/tests:mac")
2930
_PLATFORM_LINUX = Label("//tools/build_defs/python/tests:linux")
3031

@@ -51,6 +52,7 @@ def _test_mac_requires_darwin_for_execution(name, config):
5152
config_settings = {
5253
"//command_line_option:cpu": "darwin_x86_64",
5354
"//command_line_option:crosstool_top": _FAKE_CC_TOOLCHAIN,
55+
"//command_line_option:extra_toolchains": _FAKE_CC_TOOLCHAINS,
5456
"//command_line_option:platforms": [_PLATFORM_MAC],
5557
},
5658
)
@@ -82,6 +84,7 @@ def _test_non_mac_doesnt_require_darwin_for_execution(name, config):
8284
config_settings = {
8385
"//command_line_option:cpu": "k8",
8486
"//command_line_option:crosstool_top": _FAKE_CC_TOOLCHAIN,
87+
"//command_line_option:extra_toolchains": _FAKE_CC_TOOLCHAINS,
8588
"//command_line_option:platforms": [_PLATFORM_LINUX],
8689
},
8790
)

0 commit comments

Comments
 (0)