Skip to content

Commit a7119c9

Browse files
authored
tests: make multi_python_versions pass with Bazel 9 workspace (#2474)
This is basically part of #2395, but for the workspace test. Same as that PR, the `$(rootpath)` expansion isn't valid for a target with multiple outputs. To fix, use `$(rootpaths)` and parse out the particular value of interest. Work towards #2469
1 parent 9b2b70a commit a7119c9

File tree

2 files changed

+11
-7
lines changed

2 files changed

+11
-7
lines changed

examples/multi_python_versions/tests/BUILD.bazel

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,7 @@ py_test(
131131
data = [":version_3_10"],
132132
env = {
133133
"SUBPROCESS_VERSION_CHECK": "3.10",
134-
"SUBPROCESS_VERSION_PY_BINARY": "$(rootpath :version_3_10)",
134+
"SUBPROCESS_VERSION_PY_BINARY": "$(rootpaths :version_3_10)",
135135
"VERSION_CHECK": "3.9",
136136
},
137137
main = "cross_version_test.py",
@@ -143,7 +143,7 @@ py_test_3_10(
143143
data = [":version_3_9"],
144144
env = {
145145
"SUBPROCESS_VERSION_CHECK": "3.9",
146-
"SUBPROCESS_VERSION_PY_BINARY": "$(rootpath :version_3_9)",
146+
"SUBPROCESS_VERSION_PY_BINARY": "$(rootpaths :version_3_9)",
147147
"VERSION_CHECK": "3.10",
148148
},
149149
main = "cross_version_test.py",
@@ -155,7 +155,7 @@ sh_test(
155155
data = [":version_default"],
156156
env = {
157157
"VERSION_CHECK": "3.9", # The default defined in the WORKSPACE.
158-
"VERSION_PY_BINARY": "$(rootpath :version_default)",
158+
"VERSION_PY_BINARY": "$(rootpaths :version_default)",
159159
},
160160
)
161161

@@ -165,7 +165,7 @@ sh_test(
165165
data = [":version_3_8"],
166166
env = {
167167
"VERSION_CHECK": "3.8",
168-
"VERSION_PY_BINARY": "$(rootpath :version_3_8)",
168+
"VERSION_PY_BINARY": "$(rootpaths :version_3_8)",
169169
},
170170
)
171171

@@ -175,7 +175,7 @@ sh_test(
175175
data = [":version_3_9"],
176176
env = {
177177
"VERSION_CHECK": "3.9",
178-
"VERSION_PY_BINARY": "$(rootpath :version_3_9)",
178+
"VERSION_PY_BINARY": "$(rootpaths :version_3_9)",
179179
},
180180
)
181181

@@ -185,7 +185,7 @@ sh_test(
185185
data = [":version_3_10"],
186186
env = {
187187
"VERSION_CHECK": "3.10",
188-
"VERSION_PY_BINARY": "$(rootpath :version_3_10)",
188+
"VERSION_PY_BINARY": "$(rootpaths :version_3_10)",
189189
},
190190
)
191191

examples/multi_python_versions/tests/version_test.sh

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,11 @@
1616

1717
set -o errexit -o nounset -o pipefail
1818

19-
version_py_binary=$("${VERSION_PY_BINARY}")
19+
# VERSION_PY_BINARY is a space separate list of the executable and its main
20+
# py file. We just want the executable.
21+
bin=($VERSION_PY_BINARY)
22+
bin="${bin[@]//*.py}"
23+
version_py_binary=$($bin)
2024

2125
if [[ "${version_py_binary}" != "${VERSION_CHECK}" ]]; then
2226
echo >&2 "expected version '${VERSION_CHECK}' is different than returned '${version_py_binary}'"

0 commit comments

Comments
 (0)