gh-84461: Fix parallel testing on WebAssembly (GH-93768)

(cherry picked from commit c2007573dd)

Co-authored-by: Christian Heimes <christian@python.org>
This commit is contained in:
Miss Islington (bot) 2022-06-13 11:15:46 -07:00 committed by GitHub
parent dc6dd8ee87
commit 02ff1ccfb7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 6 deletions

View file

@ -628,11 +628,16 @@ class Regrtest:
# Define a writable temp dir that will be used as cwd while running # 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 # the tests. The name of the dir includes the pid to allow parallel
# testing (see the -j option). # testing (see the -j option).
pid = os.getpid() # Emscripten and WASI have stubbed getpid(), Emscripten has only
if self.worker_test_name is not None: # milisecond clock resolution. Use randint() instead.
test_cwd = 'test_python_worker_{}'.format(pid) if sys.platform in {"emscripten", "wasi"}:
nounce = random.randint(0, 1_000_000)
else: else:
test_cwd = 'test_python_{}'.format(pid) nounce = os.getpid()
if self.worker_test_name is not None:
test_cwd = 'test_python_worker_{}'.format(nounce)
else:
test_cwd = 'test_python_{}'.format(nounce)
test_cwd += os_helper.FS_NONASCII test_cwd += os_helper.FS_NONASCII
test_cwd = os.path.join(self.tmp_dir, test_cwd) test_cwd = os.path.join(self.tmp_dir, test_cwd)
return test_cwd return test_cwd

View file

@ -63,9 +63,9 @@ def main(regrtest_args):
args.append('-n') # Silence alerts under Windows args.append('-n') # Silence alerts under Windows
if not any(is_multiprocess_flag(arg) for arg in regrtest_args): if not any(is_multiprocess_flag(arg) for arg in regrtest_args):
if cross_compile and hostrunner: 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. # hostrunner can be expensive.
args.extend(['-j', '1']) args.extend(['-j', '2'])
else: else:
args.extend(['-j', '0']) # Use all CPU cores args.extend(['-j', '0']) # Use all CPU cores
if not any(is_resource_use_flag(arg) for arg in regrtest_args): if not any(is_resource_use_flag(arg) for arg in regrtest_args):