]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-84461: Fix parallel testing on WebAssembly (GH-93768)
authorChristian Heimes <christian@python.org>
Mon, 13 Jun 2022 17:51:04 +0000 (19:51 +0200)
committerGitHub <noreply@github.com>
Mon, 13 Jun 2022 17:51:04 +0000 (19:51 +0200)
Lib/test/libregrtest/main.py
Tools/scripts/run_tests.py

index 0cacccfc0b5e3917d132d73245b8b5ec7c6a91ad..85bf6e1d48e3a745fdca24add084671a95668e8e 100644 (file)
@@ -628,11 +628,16 @@ class Regrtest:
         # 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
index 8dbcade9238551c31b26ad67a81541132f45fec9..445a34ae3e8eeeb21a32432e1cf51d0f5c74a7ca 100644 (file)
@@ -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):