summaryrefslogtreecommitdiffstats
path: root/Lib/test
diff options
context:
space:
mode:
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>2022-06-13 18:15:46 (GMT)
committerGitHub <noreply@github.com>2022-06-13 18:15:46 (GMT)
commit02ff1ccfb702e740d08cd4f546cf0e51f929c718 (patch)
tree0a9509e13b3be180ca7e97a83cbfcbf11b91abb6 /Lib/test
parentdc6dd8ee873ed96027d30c8a2e96518657d46241 (diff)
downloadcpython-02ff1ccfb702e740d08cd4f546cf0e51f929c718.zip
cpython-02ff1ccfb702e740d08cd4f546cf0e51f929c718.tar.gz
cpython-02ff1ccfb702e740d08cd4f546cf0e51f929c718.tar.bz2
gh-84461: Fix parallel testing on WebAssembly (GH-93768)
(cherry picked from commit c2007573dd449ae054f9fd5227e49ac9eef00ae8) Co-authored-by: Christian Heimes <christian@python.org>
Diffstat (limited to 'Lib/test')
-rw-r--r--Lib/test/libregrtest/main.py11
1 files changed, 8 insertions, 3 deletions
diff --git a/Lib/test/libregrtest/main.py b/Lib/test/libregrtest/main.py
index 0cacccf..85bf6e1 100644
--- a/Lib/test/libregrtest/main.py
+++ b/Lib/test/libregrtest/main.py
@@ -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