Skip to content

Commit 03f7839

Browse files
authored
GH-114013: fix setting HOSTRUNNER for Tools/wasm/wasi.py (GH-114097)
Also fix tests found failing under a pydebug build of WASI thanks to `make test` working due to this change.
1 parent 3d5df54 commit 03f7839

8 files changed

+15
-12
lines changed

Lib/test/test_isinstance.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ class X:
310310
@property
311311
def __bases__(self):
312312
return self.__bases__
313-
with support.infinite_recursion():
313+
with support.infinite_recursion(25):
314314
self.assertRaises(RecursionError, issubclass, X(), int)
315315
self.assertRaises(RecursionError, issubclass, int, X())
316316
self.assertRaises(RecursionError, isinstance, 1, X())

Lib/test/test_richcmp.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def do(bad):
221221
self.assertRaises(Exc, func, Bad())
222222

223223
@support.no_tracing
224-
@support.infinite_recursion()
224+
@support.infinite_recursion(25)
225225
def test_recursion(self):
226226
# Check that comparison for recursive objects fails gracefully
227227
from collections import UserList

Lib/test/test_typing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5684,7 +5684,7 @@ def fun(x: a): pass
56845684
def cmp(o1, o2):
56855685
return o1 == o2
56865686

5687-
with infinite_recursion():
5687+
with infinite_recursion(25):
56885688
r1 = namespace1()
56895689
r2 = namespace2()
56905690
self.assertIsNot(r1, r2)

Lib/test/test_userdict.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -215,7 +215,7 @@ class G(collections.UserDict):
215215

216216
# Decorate existing test with recursion limit, because
217217
# the test is for C structure, but `UserDict` is a Python structure.
218-
test_repr_deep = support.infinite_recursion()(
218+
test_repr_deep = support.infinite_recursion(25)(
219219
mapping_tests.TestHashMappingProtocol.test_repr_deep,
220220
)
221221

Lib/test/test_userlist.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ def test_userlist_copy(self):
6969

7070
# Decorate existing test with recursion limit, because
7171
# the test is for C structure, but `UserList` is a Python structure.
72-
test_repr_deep = support.infinite_recursion()(
72+
test_repr_deep = support.infinite_recursion(25)(
7373
list_tests.CommonTest.test_repr_deep,
7474
)
7575

Lib/test/test_xml_etree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2535,7 +2535,7 @@ def __eq__(self, o):
25352535
e.extend([ET.Element('bar')])
25362536
self.assertRaises(ValueError, e.remove, X('baz'))
25372537

2538-
@support.infinite_recursion()
2538+
@support.infinite_recursion(25)
25392539
def test_recursive_repr(self):
25402540
# Issue #25455
25412541
e = ET.Element('foo')
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
Fix ``Tools/wasm/wasi.py`` to not include the path to ``python.wasm`` as
2+
part of ``HOSTRUNNER``. The environment variable is meant to specify how to
3+
run the WASI host only, having ``python.wasm`` and relevant flags appended
4+
to the ``HOSTRUNNER``. This fixes ``make test`` work.

Tools/wasm/wasi.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -233,9 +233,10 @@ def configure_wasi_python(context, working_dir):
233233
env=updated_env(env_additions | wasi_sdk_env(context)),
234234
quiet=context.quiet)
235235

236+
python_wasm = working_dir / "python.wasm"
236237
exec_script = working_dir / "python.sh"
237238
with exec_script.open("w", encoding="utf-8") as file:
238-
file.write(f'#!/bin/sh\nexec {host_runner} "$@"\n')
239+
file.write(f'#!/bin/sh\nexec {host_runner} {python_wasm} "$@"\n')
239240
exec_script.chmod(0o755)
240241
print(f"🏃‍♀️ Created {exec_script} ... ")
241242
sys.stdout.flush()
@@ -272,9 +273,7 @@ def main():
272273
# Map the checkout to / to load the stdlib from /Lib.
273274
"--dir {HOST_DIR}::{GUEST_DIR} "
274275
# Set PYTHONPATH to the sysconfig data.
275-
"--env {ENV_VAR_NAME}={ENV_VAR_VALUE} "
276-
# Path to the WASM binary.
277-
"{PYTHON_WASM}")
276+
"--env {ENV_VAR_NAME}={ENV_VAR_VALUE}")
278277

279278
parser = argparse.ArgumentParser()
280279
subcommands = parser.add_subparsers(dest="subcommand")
@@ -310,8 +309,8 @@ def main():
310309
"$WASI_SDK_PATH or /opt/wasi-sdk")
311310
subcommand.add_argument("--host-runner", action="store",
312311
default=default_host_runner, dest="host_runner",
313-
help="Command template for running the WebAssembly "
314-
"code (default meant for wasmtime 14 or newer: "
312+
help="Command template for running the WASI host "
313+
"(default designed for wasmtime 14 or newer: "
315314
f"`{default_host_runner}`)")
316315

317316
context = parser.parse_args()

0 commit comments

Comments
 (0)