| 303 | |
| 304 | @support.requires_subprocess() |
| 305 | def run_test_script(script): |
| 306 | # use -u to try to get the full output if the test hangs or crash |
| 307 | if support.verbose: |
| 308 | def title(text): |
| 309 | return f"===== {text} ======" |
| 310 | |
| 311 | name = f"script {os.path.basename(script)}" |
| 312 | print() |
| 313 | print(title(name), flush=True) |
| 314 | # In verbose mode, the child process inherit stdout and stdout, |
| 315 | # to see output in realtime and reduce the risk of losing output. |
| 316 | args = [sys.executable, "-E", "-X", "faulthandler", "-u", script, "-v"] |
| 317 | proc = subprocess.run(args) |
| 318 | print(title(f"{name} completed: exit code {proc.returncode}"), |
| 319 | flush=True) |
| 320 | if proc.returncode: |
| 321 | raise AssertionError(f"{name} failed") |
| 322 | else: |
| 323 | assert_python_ok("-u", script, "-v") |