[Python-checkins] gh-84461: Fix parallel testing on WebAssembly (GH-93768)
miss-islington
webhook-mailer at python.org
Mon Jun 13 14:16:02 EDT 2022
https://github.com/python/cpython/commit/02ff1ccfb702e740d08cd4f546cf0e51f929c718
commit: 02ff1ccfb702e740d08cd4f546cf0e51f929c718
branch: 3.11
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: miss-islington <31488909+miss-islington at users.noreply.github.com>
date: 2022-06-13T11:15:46-07:00
summary:
gh-84461: Fix parallel testing on WebAssembly (GH-93768)
(cherry picked from commit c2007573dd449ae054f9fd5227e49ac9eef00ae8)
Co-authored-by: Christian Heimes <christian at python.org>
files:
M Lib/test/libregrtest/main.py
M Tools/scripts/run_tests.py
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 0cacccfc0b5e3..85bf6e1d48e3a 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -628,11 +628,16 @@ def create_temp_dir(self):
# Define a writable temp dir that will be used as cwd while running
# the tests. The name of the dir includes the pid to allow parallel
# testing (see the -j option).
- pid = os.getpid()
+ # Emscripten and WASI have stubbed getpid(), Emscripten has only
+ # milisecond clock resolution. Use randint() instead.
+ if sys.platform in {"emscripten", "wasi"}:
+ nounce = random.randint(0, 1_000_000)
+ else:
+ nounce = os.getpid()
if self.worker_test_name is not None:
- test_cwd = 'test_python_worker_{}'.format(pid)
+ test_cwd = 'test_python_worker_{}'.format(nounce)
else:
- test_cwd = 'test_python_{}'.format(pid)
+ test_cwd = 'test_python_{}'.format(nounce)
test_cwd += os_helper.FS_NONASCII
test_cwd = os.path.join(self.tmp_dir, test_cwd)
return test_cwd
diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
index 8dbcade923855..445a34ae3e8ee 100644
--- a/Tools/scripts/run_tests.py
+++ b/Tools/scripts/run_tests.py
@@ -63,9 +63,9 @@ def main(regrtest_args):
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;
+ # For now use only two cores for cross-compiled builds;
# hostrunner can be expensive.
- args.extend(['-j', '1'])
+ args.extend(['-j', '2'])
else:
args.extend(['-j', '0']) # Use all CPU cores
if not any(is_resource_use_flag(arg) for arg in regrtest_args):
More information about the Python-checkins
mailing list