(regrtest_args)
| 26 | |
| 27 | |
| 28 | def main(regrtest_args): |
| 29 | args = [sys.executable, |
| 30 | '-u', # Unbuffered stdout and stderr |
| 31 | '-W', 'default', # Warnings set to 'default' |
| 32 | '-bb', # Warnings about bytes/bytearray |
| 33 | ] |
| 34 | |
| 35 | cross_compile = '_PYTHON_HOST_PLATFORM' in os.environ |
| 36 | if (hostrunner := os.environ.get("_PYTHON_HOSTRUNNER")) is None: |
| 37 | hostrunner = sysconfig.get_config_var("HOSTRUNNER") |
| 38 | if cross_compile: |
| 39 | # emulate -E, but keep PYTHONPATH + cross compile env vars, so |
| 40 | # test executable can load correct sysconfigdata file. |
| 41 | keep = { |
| 42 | '_PYTHON_PROJECT_BASE', |
| 43 | '_PYTHON_HOST_PLATFORM', |
| 44 | '_PYTHON_SYSCONFIGDATA_NAME', |
| 45 | 'PYTHONPATH' |
| 46 | } |
| 47 | environ = { |
| 48 | name: value for name, value in os.environ.items() |
| 49 | if not name.startswith(('PYTHON', '_PYTHON')) or name in keep |
| 50 | } |
| 51 | else: |
| 52 | environ = os.environ.copy() |
| 53 | args.append("-E") |
| 54 | |
| 55 | # Allow user-specified interpreter options to override our defaults. |
| 56 | args.extend(test.support.args_from_interpreter_flags()) |
| 57 | |
| 58 | args.extend(['-m', 'test', # Run the test suite |
| 59 | '-r', # Randomize test order |
| 60 | '-w', # Re-run failed tests in verbose mode |
| 61 | ]) |
| 62 | if sys.platform == 'win32': |
| 63 | args.append('-n') # Silence alerts under Windows |
| 64 | if not any(is_multiprocess_flag(arg) for arg in regrtest_args): |
| 65 | if cross_compile and hostrunner: |
| 66 | # For now use only two cores for cross-compiled builds; |
| 67 | # hostrunner can be expensive. |
| 68 | args.extend(['-j', '2']) |
| 69 | else: |
| 70 | args.extend(['-j', '0']) # Use all CPU cores |
| 71 | if not any(is_resource_use_flag(arg) for arg in regrtest_args): |
| 72 | args.extend(['-u', 'all,-largefile,-audio,-gui']) |
| 73 | |
| 74 | if cross_compile and hostrunner: |
| 75 | # If HOSTRUNNER is set and -p/--python option is not given, then |
| 76 | # use hostrunner to execute python binary for tests. |
| 77 | if not any(is_python_flag(arg) for arg in regrtest_args): |
| 78 | buildpython = sysconfig.get_config_var("BUILDPYTHON") |
| 79 | args.extend(["--python", f"{hostrunner} {buildpython}"]) |
| 80 | |
| 81 | args.extend(regrtest_args) |
| 82 | |
| 83 | print(shlex.join(args)) |
| 84 | if sys.platform == 'win32': |
| 85 | from subprocess import call |
no test coverage detected