Skip to content

Commit d20fdb2

Browse files
committed
bpo-40280: Skip subprocess tests on wasm32-emscripten / wasi
1 parent d75a51b commit d20fdb2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

42 files changed

+139
-23
lines changed

Lib/distutils/tests/test_build_clib.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,9 @@
44
import sys
55
import sysconfig
66

7-
from test.support import run_unittest, missing_compiler_executable
7+
from test.support import (
8+
run_unittest, missing_compiler_executable, requires_subprocess
9+
)
810

911
from distutils.command.build_clib import build_clib
1012
from distutils.errors import DistutilsSetupError
@@ -112,6 +114,7 @@ def test_finalize_options(self):
112114
self.assertRaises(DistutilsSetupError, cmd.finalize_options)
113115

114116
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
117+
@requires_subprocess()
115118
def test_run(self):
116119
pkg_dir, dist = self.create_dist()
117120
cmd = build_clib(dist)

Lib/distutils/tests/test_build_ext.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ def tearDown(self):
5656
def build_ext(self, *args, **kwargs):
5757
return build_ext(*args, **kwargs)
5858

59+
@support.requires_subprocess()
5960
def test_build_ext(self):
6061
cmd = support.missing_compiler_executable()
6162
if cmd is not None:
@@ -332,6 +333,7 @@ def test_compiler_option(self):
332333
cmd.run()
333334
self.assertEqual(cmd.compiler, 'unix')
334335

336+
@support.requires_subprocess()
335337
def test_get_outputs(self):
336338
cmd = support.missing_compiler_executable()
337339
if cmd is not None:

Lib/distutils/tests/test_build_py.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from distutils.errors import DistutilsFileError
1010

1111
from distutils.tests import support
12-
from test.support import run_unittest
12+
from test.support import run_unittest, requires_subprocess
1313

1414

1515
class BuildPyTestCase(support.TempdirManager,
@@ -89,6 +89,7 @@ def test_empty_package_dir(self):
8989
self.fail("failed package_data test when package_dir is ''")
9090

9191
@unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
92+
@requires_subprocess()
9293
def test_byte_compile(self):
9394
project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
9495
os.chdir(project_dir)
@@ -106,6 +107,7 @@ def test_byte_compile(self):
106107
['boiledeggs.%s.pyc' % sys.implementation.cache_tag])
107108

108109
@unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
110+
@requires_subprocess()
109111
def test_byte_compile_optimized(self):
110112
project_dir, dist = self.create_dist(py_modules=['boiledeggs'])
111113
os.chdir(project_dir)

Lib/distutils/tests/test_config_cmd.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,9 @@
33
import os
44
import sys
55
import sysconfig
6-
from test.support import run_unittest, missing_compiler_executable
6+
from test.support import (
7+
run_unittest, missing_compiler_executable, requires_subprocess
8+
)
79

810
from distutils.command.config import dump_file, config
911
from distutils.tests import support
@@ -42,6 +44,7 @@ def test_dump_file(self):
4244
self.assertEqual(len(self._logs), numlines+1)
4345

4446
@unittest.skipIf(sys.platform == 'win32', "can't test on Windows")
47+
@requires_subprocess()
4548
def test_search_cpp(self):
4649
cmd = missing_compiler_executable(['preprocessor'])
4750
if cmd is not None:

Lib/distutils/tests/test_install.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import unittest
66
import site
77

8-
from test.support import captured_stdout, run_unittest
8+
from test.support import captured_stdout, run_unittest, requires_subprocess
99

1010
from distutils import sysconfig
1111
from distutils.command.install import install, HAS_USER_SITE
@@ -208,6 +208,7 @@ def test_record(self):
208208
'UNKNOWN-0.0.0-py%s.%s.egg-info' % sys.version_info[:2]]
209209
self.assertEqual(found, expected)
210210

211+
@requires_subprocess()
211212
def test_record_extensions(self):
212213
cmd = test_support.missing_compiler_executable()
213214
if cmd is not None:

Lib/distutils/tests/test_install_lib.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
from distutils.extension import Extension
99
from distutils.tests import support
1010
from distutils.errors import DistutilsOptionError
11-
from test.support import run_unittest
11+
from test.support import run_unittest, requires_subprocess
1212

1313

1414
class InstallLibTestCase(support.TempdirManager,
@@ -35,6 +35,7 @@ def test_finalize_options(self):
3535
self.assertEqual(cmd.optimize, 2)
3636

3737
@unittest.skipIf(sys.dont_write_bytecode, 'byte-compile disabled')
38+
@requires_subprocess()
3839
def test_byte_compile(self):
3940
project_dir, dist = self.create_dist()
4041
os.chdir(project_dir)
@@ -90,6 +91,7 @@ def test_get_inputs(self):
9091
inputs = cmd.get_inputs()
9192
self.assertEqual(len(inputs), 2, inputs)
9293

94+
@requires_subprocess()
9395
def test_dont_write_bytecode(self):
9496
# makes sure byte_compile is not used
9597
dist = self.create_dist()[1]

Lib/distutils/tests/test_spawn.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,16 @@
33
import stat
44
import sys
55
import unittest.mock
6-
from test.support import run_unittest, unix_shell
6+
from test.support import run_unittest, unix_shell, requires_subprocess
77
from test.support import os_helper
88

99
from distutils.spawn import find_executable
1010
from distutils.spawn import spawn
1111
from distutils.errors import DistutilsExecError
1212
from distutils.tests import support
1313

14+
15+
@requires_subprocess()
1416
class SpawnTestCase(support.TempdirManager,
1517
support.LoggingSilencer,
1618
unittest.TestCase):

Lib/distutils/tests/test_sysconfig.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from distutils import sysconfig
1111
from distutils.ccompiler import get_default_compiler
1212
from distutils.tests import support
13-
from test.support import run_unittest, swap_item
13+
from test.support import run_unittest, swap_item, requires_subprocess
1414
from test.support.os_helper import TESTFN
1515
from test.support.warnings_helper import check_warnings
1616

@@ -247,6 +247,7 @@ def test_SO_in_vars(self):
247247
self.assertIsNotNone(vars['SO'])
248248
self.assertEqual(vars['SO'], vars['EXT_SUFFIX'])
249249

250+
@requires_subprocess()
250251
def test_customize_compiler_before_get_config_vars(self):
251252
# Issue #21923: test that a Distribution compiler
252253
# instance can be called without an explicit call to

Lib/lib2to3/tests/test_parser.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ def test_load_grammar_from_pickle(self):
6161
shutil.rmtree(tmpdir)
6262

6363
@unittest.skipIf(sys.executable is None, 'sys.executable required')
64+
@unittest.skipIf(
65+
sys.platform == 'emscripten', 'requires working subprocess'
66+
)
6467
def test_load_grammar_from_subprocess(self):
6568
tmpdir = tempfile.mkdtemp()
6669
tmpsubdir = os.path.join(tmpdir, 'subdir')

Lib/test/support/__init__.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,11 +40,12 @@
4040
"bigmemtest", "bigaddrspacetest", "cpython_only", "get_attribute",
4141
"requires_IEEE_754", "requires_zlib",
4242
"has_fork_support", "requires_fork",
43+
"has_subprocess_support", "requires_subprocess",
4344
"anticipate_failure", "load_package_tests", "detect_api_mismatch",
4445
"check__all__", "skip_if_buggy_ucrt_strfptime",
4546
"check_disallow_instantiation",
4647
# sys
47-
"is_jython", "is_android", "is_emscripten",
48+
"is_jython", "is_android", "is_emscripten", "is_wasi",
4849
"check_impl_detail", "unix_shell", "setswitchinterval",
4950
# network
5051
"open_urlresource",
@@ -467,15 +468,23 @@ def requires_debug_ranges(reason='requires co_positions / debug_ranges'):
467468
else:
468469
unix_shell = None
469470

470-
# wasm32-emscripten is POSIX-like but does not provide a
471-
# working fork() or subprocess API.
471+
# wasm32-emscripten and -wasi are POSIX-like but do not
472+
# have subprocess or fork support.
472473
is_emscripten = sys.platform == "emscripten"
474+
is_wasi = sys.platform == "wasi"
473475

474-
has_fork_support = hasattr(os, "fork") and not is_emscripten
476+
has_fork_support = hasattr(os, "fork") and not is_emscripten and not is_wasi
475477

476478
def requires_fork():
477479
return unittest.skipUnless(has_fork_support, "requires working os.fork()")
478480

481+
has_subprocess_support = not is_emscripten and not is_wasi
482+
483+
def requires_subprocess():
484+
"""Used for subprocess, os.spawn calls"""
485+
return unittest.skipUnless(has_subprocess_support, "requires subprocess support")
486+
487+
479488
# Define the URL of a dedicated HTTP server for the network tests.
480489
# The URL must use clear-text HTTP: no redirection to encrypted HTTPS.
481490
TEST_HTTP_URL = "http://www.pythontest.net"

0 commit comments

Comments
 (0)