Skip to content

Commit 532f07a

Browse files
authored
tests: Force analysis test labels to resolve within @rules_python context (bazel-contrib#1187)
When a string label is passed to the `@rules_testing` analysis_test functions, the strings are evaluated within the context of @rules_testing because that is where the actual rule invocation happens. Without bzlmod, this just requires qualifying the labels with the repo name (which is what was being done) because there's just a flat global namespace of repos. With bzlmod enabled, repo mapping happens, so rules_testing tries to resolve those repo names using its repo mapping, which doesn't work because rules_testing's mapping doesn't include every repo using it.
1 parent fc94642 commit 532f07a

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

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

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,12 @@ load(
2222
)
2323
load("//tools/build_defs/python/tests:util.bzl", pt_util = "util")
2424

25+
# Explicit Label() calls are required so that it resolves in @rules_python context instead of
26+
# @rules_testing context.
27+
_FAKE_CC_TOOLCHAIN = Label("//tools/build_defs/python/tests:cc_toolchain_suite")
28+
_PLATFORM_MAC = Label("//tools/build_defs/python/tests:mac")
29+
_PLATFORM_LINUX = Label("//tools/build_defs/python/tests:linux")
30+
2531
_tests = []
2632

2733
def _test_mac_requires_darwin_for_execution(name, config):
@@ -44,8 +50,8 @@ def _test_mac_requires_darwin_for_execution(name, config):
4450
target = name + "_subject",
4551
config_settings = {
4652
"//command_line_option:cpu": "darwin_x86_64",
47-
"//command_line_option:crosstool_top": "@rules_python//tools/build_defs/python/tests:cc_toolchain_suite",
48-
"//command_line_option:platforms": "@rules_python//tools/build_defs/python/tests:mac",
53+
"//command_line_option:crosstool_top": _FAKE_CC_TOOLCHAIN,
54+
"//command_line_option:platforms": [_PLATFORM_MAC],
4955
},
5056
)
5157

@@ -75,8 +81,8 @@ def _test_non_mac_doesnt_require_darwin_for_execution(name, config):
7581
target = name + "_subject",
7682
config_settings = {
7783
"//command_line_option:cpu": "k8",
78-
"//command_line_option:crosstool_top": "@rules_python//tools/build_defs/python/tests:cc_toolchain_suite",
79-
"//command_line_option:platforms": "@rules_python//tools/build_defs/python/tests:linux",
84+
"//command_line_option:crosstool_top": _FAKE_CC_TOOLCHAIN,
85+
"//command_line_option:platforms": [_PLATFORM_LINUX],
8086
},
8187
)
8288

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy