Skip to content

GH-114013: fix setting HOSTRUNNER for Tools/wasm/wasi.py #114097

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Jan 16, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Lib/test/test_isinstance.py
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ class X:
@property
def __bases__(self):
return self.__bases__
with support.infinite_recursion():
with support.infinite_recursion(25):
self.assertRaises(RecursionError, issubclass, X(), int)
self.assertRaises(RecursionError, issubclass, int, X())
self.assertRaises(RecursionError, isinstance, 1, X())
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_richcmp.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ def do(bad):
self.assertRaises(Exc, func, Bad())

@support.no_tracing
@support.infinite_recursion()
@support.infinite_recursion(25)
def test_recursion(self):
# Check that comparison for recursive objects fails gracefully
from collections import UserList
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -5684,7 +5684,7 @@ def fun(x: a): pass
def cmp(o1, o2):
return o1 == o2

with infinite_recursion():
with infinite_recursion(25):
r1 = namespace1()
r2 = namespace2()
self.assertIsNot(r1, r2)
Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_userdict.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ class G(collections.UserDict):

# Decorate existing test with recursion limit, because
# the test is for C structure, but `UserDict` is a Python structure.
test_repr_deep = support.infinite_recursion()(
test_repr_deep = support.infinite_recursion(25)(
mapping_tests.TestHashMappingProtocol.test_repr_deep,
)

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_userlist.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ def test_userlist_copy(self):

# Decorate existing test with recursion limit, because
# the test is for C structure, but `UserList` is a Python structure.
test_repr_deep = support.infinite_recursion()(
test_repr_deep = support.infinite_recursion(25)(
list_tests.CommonTest.test_repr_deep,
)

Expand Down
2 changes: 1 addition & 1 deletion Lib/test/test_xml_etree.py
Original file line number Diff line number Diff line change
Expand Up @@ -2535,7 +2535,7 @@ def __eq__(self, o):
e.extend([ET.Element('bar')])
self.assertRaises(ValueError, e.remove, X('baz'))

@support.infinite_recursion()
@support.infinite_recursion(25)
def test_recursive_repr(self):
# Issue #25455
e = ET.Element('foo')
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
Fix ``Tools/wasm/wasi.py`` to not include the path to ``python.wasm`` as
part of ``HOSTRUNNER``. The environment variable is meant to specify how to
run the WASI host only, having ``python.wasm`` and relevant flags appended
to the ``HOSTRUNNER``. This fixes ``make test`` work.
11 changes: 5 additions & 6 deletions Tools/wasm/wasi.py
Original file line number Diff line number Diff line change
Expand Up @@ -233,9 +233,10 @@ def configure_wasi_python(context, working_dir):
env=updated_env(env_additions | wasi_sdk_env(context)),
quiet=context.quiet)

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

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

context = parser.parse_args()
Expand Down