Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork33.7k
gh-84461: Use HOSTRUNNER to run regression tests (GH-93694)#93694
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Changes from2 commits
File filter
Filter by extension
Conversations
Uh oh!
There was an error while loading.Please reload this page.
Jump to
Uh oh!
There was an error while loading.Please reload this page.
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,2 @@ | ||
| ``run_tests.py`` now handles cross compiling env vars correctly and pass | ||
| ``HOSTRUNNER`` to regression tests. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -8,7 +8,9 @@ | ||
| """ | ||
| import os | ||
| import shlex | ||
| import sys | ||
| import sysconfig | ||
| import test.support | ||
| @@ -19,15 +21,38 @@ def is_multiprocess_flag(arg): | ||
| def is_resource_use_flag(arg): | ||
| return arg.startswith('-u') or arg.startswith('--use') | ||
| def is_python_flag(arg): | ||
| return arg.startswith('-p') or arg.startswith('--python') | ||
| def main(regrtest_args): | ||
| args = [sys.executable, | ||
| '-u', # Unbuffered stdout and stderr | ||
| '-W', 'default', # Warnings set to 'default' | ||
| '-bb', # Warnings about bytes/bytearray | ||
| ] | ||
| cross_compile = '_PYTHON_HOST_PLATFORM' in os.environ | ||
| hostrunner = os.environ.get("_PYTHON_HOSTRUNNER") | ||
| if hostrunner is None: | ||
tiran marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| hostrunner = sysconfig.get_config_var("HOSTRUNNER") | ||
| if cross_compile: | ||
| # emulate -E, but keep PYTHONPATH + cross compile env vars, so | ||
| # test executable can load correct sysconfigdata file. | ||
| keep = { | ||
| '_PYTHON_PROJECT_BASE', | ||
| '_PYTHON_HOST_PLATFORM', | ||
| '_PYTHON_SYSCONFIGDATA_NAME', | ||
| 'PYTHONPATH' | ||
| } | ||
| environ = { | ||
| name: value for name, value in os.environ.items() | ||
| if not name.startswith(('PYTHON', '_PYTHON')) or name in keep | ||
| } | ||
| else: | ||
| environ = os.environ.copy() | ||
| args.append("-E") | ||
| # Allow user-specified interpreter options to override our defaults. | ||
| args.extend(test.support.args_from_interpreter_flags()) | ||
| @@ -38,16 +63,30 @@ def main(regrtest_args): | ||
| if sys.platform == 'win32': | ||
| args.append('-n') # Silence alerts under Windows | ||
| if not any(is_multiprocess_flag(arg) for arg in regrtest_args): | ||
| if cross_compile and hostrunner: | ||
| # For now use only one core for cross compiled builds. | ||
| # hostrunner can be expensive. | ||
tiran marked this conversation as resolved. OutdatedShow resolvedHide resolvedUh oh!There was an error while loading.Please reload this page. | ||
| args.extend(['-j', '1']) | ||
| else: | ||
| args.extend(['-j', '0']) # Use all CPU cores | ||
| if not any(is_resource_use_flag(arg) for arg in regrtest_args): | ||
| args.extend(['-u', 'all,-largefile,-audio,-gui']) | ||
| if cross_compile and hostrunner: | ||
| # If HOSTRUNNER is set and -p/--python option is not given, then | ||
| # use hostrunner to execute python binary for tests. | ||
| if not any(is_python_flag(arg) for arg in regrtest_args): | ||
| buildpython = sysconfig.get_config_var("BUILDPYTHON") | ||
| args.extend(["--python", f"{hostrunner} {buildpython}"]) | ||
| args.extend(regrtest_args) | ||
| print(shlex.join(args)) | ||
| if sys.platform == 'win32': | ||
| from subprocess import call | ||
| sys.exit(call(args)) | ||
| else: | ||
| os.execve(sys.executable, args, environ) | ||
| if __name__ == '__main__': | ||
Some generated files are not rendered by default. Learn more abouthow customized files appear on GitHub.
Uh oh!
There was an error while loading.Please reload this page.