mirror of
https://github.com/python/cpython.git
synced 2025-12-22 00:19:14 +00:00
Use test.support.is_wasm32 flag for is_emscripten or is_wasi for generic checks (GH-136815)
Co-authored-by: Brett Cannon <brett@python.org>
This commit is contained in:
parent
d6cf05b5d0
commit
aafb1435d8
9 changed files with 19 additions and 15 deletions
|
|
@ -762,6 +762,7 @@ def collect_support(info_add):
|
||||||
'is_emscripten',
|
'is_emscripten',
|
||||||
'is_jython',
|
'is_jython',
|
||||||
'is_wasi',
|
'is_wasi',
|
||||||
|
'is_wasm32',
|
||||||
)
|
)
|
||||||
copy_attributes(info_add, support, 'support.%s', attributes)
|
copy_attributes(info_add, support, 'support.%s', attributes)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -569,6 +569,9 @@ else:
|
||||||
is_emscripten = sys.platform == "emscripten"
|
is_emscripten = sys.platform == "emscripten"
|
||||||
is_wasi = sys.platform == "wasi"
|
is_wasi = sys.platform == "wasi"
|
||||||
|
|
||||||
|
# Use is_wasm32 as a generic check for WebAssembly platforms.
|
||||||
|
is_wasm32 = is_emscripten or is_wasi
|
||||||
|
|
||||||
def skip_emscripten_stack_overflow():
|
def skip_emscripten_stack_overflow():
|
||||||
return unittest.skipIf(is_emscripten, "Exhausts stack on Emscripten")
|
return unittest.skipIf(is_emscripten, "Exhausts stack on Emscripten")
|
||||||
|
|
||||||
|
|
@ -3148,7 +3151,7 @@ def linked_to_musl():
|
||||||
|
|
||||||
# emscripten (at least as far as we're concerned) and wasi use musl,
|
# emscripten (at least as far as we're concerned) and wasi use musl,
|
||||||
# but platform doesn't know how to get the version, so set it to zero.
|
# but platform doesn't know how to get the version, so set it to zero.
|
||||||
if is_emscripten or is_wasi:
|
if is_wasm32:
|
||||||
_linked_to_musl = (0, 0, 0)
|
_linked_to_musl = (0, 0, 0)
|
||||||
return _linked_to_musl
|
return _linked_to_musl
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@ import sysconfig
|
||||||
import string
|
import string
|
||||||
import unittest
|
import unittest
|
||||||
|
|
||||||
from test.support import is_android, is_apple_mobile, is_emscripten, is_wasi
|
from test.support import is_android, is_apple_mobile, is_wasm32
|
||||||
|
|
||||||
|
|
||||||
class FormatTestsBase:
|
class FormatTestsBase:
|
||||||
|
|
@ -91,7 +91,7 @@ needs_installed_python = unittest.skipIf(
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(os.name != 'posix', 'Feature only implemented on POSIX right now')
|
@unittest.skipIf(os.name != 'posix', 'Feature only implemented on POSIX right now')
|
||||||
@unittest.skipIf(is_wasi or is_emscripten, 'Feature not available on WebAssembly builds')
|
@unittest.skipIf(is_wasm32, 'Feature not available on WebAssembly builds')
|
||||||
class CPythonBuildDetailsTests(unittest.TestCase, FormatTestsBase):
|
class CPythonBuildDetailsTests(unittest.TestCase, FormatTestsBase):
|
||||||
"""Test CPython's install details file implementation."""
|
"""Test CPython's install details file implementation."""
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -35,7 +35,7 @@ from test.support import (
|
||||||
cpython_only,
|
cpython_only,
|
||||||
is_apple_mobile,
|
is_apple_mobile,
|
||||||
is_emscripten,
|
is_emscripten,
|
||||||
is_wasi,
|
is_wasm32,
|
||||||
run_in_subinterp,
|
run_in_subinterp,
|
||||||
run_in_subinterp_with_config,
|
run_in_subinterp_with_config,
|
||||||
Py_TRACE_REFS,
|
Py_TRACE_REFS,
|
||||||
|
|
@ -1257,7 +1257,7 @@ class FilePermissionTests(unittest.TestCase):
|
||||||
@unittest.skipUnless(os.name == 'posix',
|
@unittest.skipUnless(os.name == 'posix',
|
||||||
"test meaningful only on posix systems")
|
"test meaningful only on posix systems")
|
||||||
@unittest.skipIf(
|
@unittest.skipIf(
|
||||||
is_emscripten or is_wasi,
|
is_wasm32,
|
||||||
"Emscripten's/WASI's umask is a stub."
|
"Emscripten's/WASI's umask is a stub."
|
||||||
)
|
)
|
||||||
def test_creation_mode(self):
|
def test_creation_mode(self):
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@ from urllib.request import pathname2url
|
||||||
|
|
||||||
from test.support import import_helper
|
from test.support import import_helper
|
||||||
from test.support import cpython_only
|
from test.support import cpython_only
|
||||||
from test.support import is_emscripten, is_wasi
|
from test.support import is_emscripten, is_wasi, is_wasm32
|
||||||
from test.support import infinite_recursion
|
from test.support import infinite_recursion
|
||||||
from test.support import os_helper
|
from test.support import os_helper
|
||||||
from test.support.os_helper import TESTFN, FS_NONASCII, FakePath
|
from test.support.os_helper import TESTFN, FS_NONASCII, FakePath
|
||||||
|
|
@ -3158,7 +3158,7 @@ class PathTest(PurePathTest):
|
||||||
self.assertEqual(str(P('//a/b').absolute()), '//a/b')
|
self.assertEqual(str(P('//a/b').absolute()), '//a/b')
|
||||||
|
|
||||||
@unittest.skipIf(
|
@unittest.skipIf(
|
||||||
is_emscripten or is_wasi,
|
is_wasm32,
|
||||||
"umask is not implemented on Emscripten/WASI."
|
"umask is not implemented on Emscripten/WASI."
|
||||||
)
|
)
|
||||||
@needs_posix
|
@needs_posix
|
||||||
|
|
@ -3189,7 +3189,7 @@ class PathTest(PurePathTest):
|
||||||
os.chdir(current_directory)
|
os.chdir(current_directory)
|
||||||
|
|
||||||
@unittest.skipIf(
|
@unittest.skipIf(
|
||||||
is_emscripten or is_wasi,
|
is_wasm32,
|
||||||
"umask is not implemented on Emscripten/WASI."
|
"umask is not implemented on Emscripten/WASI."
|
||||||
)
|
)
|
||||||
@needs_posix
|
@needs_posix
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import unittest
|
import unittest
|
||||||
from test.support import (
|
from test.support import (
|
||||||
is_android, is_apple_mobile, is_emscripten, is_wasi, reap_children, verbose
|
is_android, is_apple_mobile, is_wasm32, reap_children, verbose
|
||||||
)
|
)
|
||||||
from test.support.import_helper import import_module
|
from test.support.import_helper import import_module
|
||||||
from test.support.os_helper import TESTFN, unlink
|
from test.support.os_helper import TESTFN, unlink
|
||||||
|
|
@ -8,7 +8,7 @@ from test.support.os_helper import TESTFN, unlink
|
||||||
# Skip these tests if termios is not available
|
# Skip these tests if termios is not available
|
||||||
import_module('termios')
|
import_module('termios')
|
||||||
|
|
||||||
if is_android or is_apple_mobile or is_emscripten or is_wasi:
|
if is_android or is_apple_mobile or is_wasm32:
|
||||||
raise unittest.SkipTest("pty is not available on this platform")
|
raise unittest.SkipTest("pty is not available on this platform")
|
||||||
|
|
||||||
import errno
|
import errno
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ from test.support.script_helper import (assert_python_ok,
|
||||||
assert_python_failure, spawn_python)
|
assert_python_failure, spawn_python)
|
||||||
from test.support import threading_helper
|
from test.support import threading_helper
|
||||||
from test.support import (reap_children, captured_stdout,
|
from test.support import (reap_children, captured_stdout,
|
||||||
captured_stderr, is_emscripten, is_wasi,
|
captured_stderr, is_wasm32,
|
||||||
requires_docstrings, MISSING_C_DOCSTRINGS)
|
requires_docstrings, MISSING_C_DOCSTRINGS)
|
||||||
from test.support.os_helper import (TESTFN, rmtree, unlink)
|
from test.support.os_helper import (TESTFN, rmtree, unlink)
|
||||||
from test.test_pydoc import pydoc_mod
|
from test.test_pydoc import pydoc_mod
|
||||||
|
|
@ -2081,7 +2081,7 @@ class PydocFodderTest(unittest.TestCase):
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipIf(
|
@unittest.skipIf(
|
||||||
is_emscripten or is_wasi,
|
is_wasm32,
|
||||||
"Socket server not available on Emscripten/WASI."
|
"Socket server not available on Emscripten/WASI."
|
||||||
)
|
)
|
||||||
class PydocServerTest(unittest.TestCase):
|
class PydocServerTest(unittest.TestCase):
|
||||||
|
|
|
||||||
|
|
@ -787,7 +787,7 @@ class TestSupport(unittest.TestCase):
|
||||||
def test_linked_to_musl(self):
|
def test_linked_to_musl(self):
|
||||||
linked = support.linked_to_musl()
|
linked = support.linked_to_musl()
|
||||||
self.assertIsNotNone(linked)
|
self.assertIsNotNone(linked)
|
||||||
if support.is_wasi or support.is_emscripten:
|
if support.is_wasm32:
|
||||||
self.assertTrue(linked)
|
self.assertTrue(linked)
|
||||||
# The value is cached, so make sure it returns the same value again.
|
# The value is cached, so make sure it returns the same value again.
|
||||||
self.assertIs(linked, support.linked_to_musl())
|
self.assertIs(linked, support.linked_to_musl())
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,7 @@ import shlex
|
||||||
from test.support import (captured_stdout, captured_stderr,
|
from test.support import (captured_stdout, captured_stderr,
|
||||||
skip_if_broken_multiprocessing_synchronize, verbose,
|
skip_if_broken_multiprocessing_synchronize, verbose,
|
||||||
requires_subprocess, is_android, is_apple_mobile,
|
requires_subprocess, is_android, is_apple_mobile,
|
||||||
is_emscripten, is_wasi,
|
is_wasm32,
|
||||||
requires_venv_with_pip, TEST_HOME_DIR,
|
requires_venv_with_pip, TEST_HOME_DIR,
|
||||||
requires_resource, copy_python_src_ignore)
|
requires_resource, copy_python_src_ignore)
|
||||||
from test.support.os_helper import (can_symlink, EnvironmentVarGuard, rmtree,
|
from test.support.os_helper import (can_symlink, EnvironmentVarGuard, rmtree,
|
||||||
|
|
@ -42,7 +42,7 @@ requireVenvCreate = unittest.skipUnless(
|
||||||
or sys._base_executable != sys.executable,
|
or sys._base_executable != sys.executable,
|
||||||
'cannot run venv.create from within a venv on this platform')
|
'cannot run venv.create from within a venv on this platform')
|
||||||
|
|
||||||
if is_android or is_apple_mobile or is_emscripten or is_wasi:
|
if is_android or is_apple_mobile or is_wasm32:
|
||||||
raise unittest.SkipTest("venv is not available on this platform")
|
raise unittest.SkipTest("venv is not available on this platform")
|
||||||
|
|
||||||
@requires_subprocess()
|
@requires_subprocess()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue