Skip to content

Commit ef1327e

Browse files
authored
bpo-40280: Skip more tests on Emscripten (GH-31947)
- lchmod, lchown are not fully implemented - skip umask tests - cannot fstat unlinked or renamed files yet - ignore musl libc issues that affect Emscripten
1 parent c2e3c06 commit ef1327e

16 files changed

+63
-8
lines changed

Lib/distutils/tests/test_dir_util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from distutils import log
1313
from distutils.tests import support
14-
from test.support import run_unittest
14+
from test.support import run_unittest, is_emscripten
1515

1616

1717
class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
@@ -55,6 +55,7 @@ def test_mkpath_remove_tree_verbosity(self):
5555

5656
@unittest.skipIf(sys.platform.startswith('win'),
5757
"This test is only appropriate for POSIX-like systems.")
58+
@unittest.skipIf(is_emscripten, "Emscripten's umask is a stub.")
5859
def test_mkpath_with_custom_mode(self):
5960
# Get and set the current umask value for testing mode bits.
6061
umask = os.umask(0o002)

Lib/test/test__locale.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import unittest
1010
from platform import uname
1111

12+
from test import support
13+
1214
if uname().system == "Darwin":
1315
maj, min, mic = [int(part) for part in uname().release.split(".")]
1416
if (maj, min, mic) < (8, 0, 0):
@@ -106,6 +108,9 @@ def numeric_tester(self, calc_type, calc_value, data_type, used_locale):
106108
return True
107109

108110
@unittest.skipUnless(nl_langinfo, "nl_langinfo is not available")
111+
@unittest.skipIf(
112+
support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
113+
)
109114
def test_lc_numeric_nl_langinfo(self):
110115
# Test nl_langinfo against known values
111116
tested = False
@@ -122,6 +127,9 @@ def test_lc_numeric_nl_langinfo(self):
122127
if not tested:
123128
self.skipTest('no suitable locales')
124129

130+
@unittest.skipIf(
131+
support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
132+
)
125133
def test_lc_numeric_localeconv(self):
126134
# Test localeconv against known values
127135
tested = False

Lib/test/test__xxsubinterpreters.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -818,7 +818,7 @@ def f():
818818

819819
self.assertEqual(out, 'it worked!')
820820

821-
@unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()")
821+
@support.requires_fork()
822822
def test_fork(self):
823823
import tempfile
824824
with tempfile.NamedTemporaryFile('w+', encoding="utf-8") as file:

Lib/test/test_coroutines.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2208,6 +2208,9 @@ async def f():
22082208
gen.cr_frame.clear()
22092209

22102210

2211+
@unittest.skipIf(
2212+
support.is_emscripten, "asyncio does not work under Emscripten yet."
2213+
)
22112214
class CoroAsyncIOCompatTest(unittest.TestCase):
22122215

22132216
def test_asyncio_1(self):

Lib/test/test_interpreters.py

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

8+
from test import support
89
from test.support import import_helper
910
_interpreters = import_helper.import_module('_xxsubinterpreters')
1011
from test.support import interpreters
@@ -408,7 +409,7 @@ def f():
408409

409410
self.assertEqual(out, 'it worked!')
410411

411-
@unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()")
412+
@support.requires_fork()
412413
def test_fork(self):
413414
interp = interpreters.create()
414415
import tempfile

Lib/test/test_locale.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from decimal import Decimal
2-
from test.support import verbose, is_android
2+
from test.support import verbose, is_android, is_emscripten
33
from test.support.warnings_helper import check_warnings
44
import unittest
55
import locale
@@ -373,11 +373,13 @@ def setUp(self):
373373

374374
@unittest.skipIf(sys.platform.startswith('aix'),
375375
'bpo-29972: broken test on AIX')
376+
@unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
376377
def test_strcoll_with_diacritic(self):
377378
self.assertLess(locale.strcoll('à', 'b'), 0)
378379

379380
@unittest.skipIf(sys.platform.startswith('aix'),
380381
'bpo-29972: broken test on AIX')
382+
@unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
381383
def test_strxfrm_with_diacritic(self):
382384
self.assertLess(locale.strxfrm('à'), locale.strxfrm('b'))
383385

Lib/test/test_logging.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ def remove_loop(fname, tries):
674674
# based on os.fork existing because that is what users and this test use.
675675
# This helps ensure that when fork exists (the important concept) that the
676676
# register_at_fork mechanism is also present and used.
677-
@unittest.skipIf(not hasattr(os, 'fork'), 'Test requires os.fork().')
677+
@support.requires_fork()
678678
def test_post_fork_child_no_deadlock(self):
679679
"""Ensure child logging locks are not held; bpo-6721 & bpo-36533."""
680680
class _OurHandler(logging.Handler):
@@ -4493,6 +4493,7 @@ def _extract_logrecord_process_name(key, logMultiprocessing, conn=None):
44934493
return results
44944494

44954495
def test_multiprocessing(self):
4496+
support.skip_if_broken_multiprocessing_synchronize()
44964497
multiprocessing_imported = 'multiprocessing' in sys.modules
44974498
try:
44984499
# logMultiprocessing is True by default

Lib/test/test_ntpath.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import unittest
55
import warnings
66
from test.support import os_helper
7-
from test.support import TestFailed
7+
from test.support import TestFailed, is_emscripten
88
from test.support.os_helper import FakePath
99
from test import test_genericpath
1010
from tempfile import TemporaryFile
@@ -747,6 +747,7 @@ def check_error(exc, paths):
747747
self.assertRaises(TypeError, ntpath.commonpath,
748748
['Program Files', b'C:\\Program Files\\Foo'])
749749

750+
@unittest.skipIf(is_emscripten, "Emscripten cannot fstat unnamed files.")
750751
def test_sameopenfile(self):
751752
with TemporaryFile() as tf1, TemporaryFile() as tf2:
752753
# Make sure the same file is really the same

Lib/test/test_os.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,9 @@ def test_access(self):
181181
os.close(f)
182182
self.assertTrue(os.access(os_helper.TESTFN, os.W_OK))
183183

184+
@unittest.skipIf(
185+
support.is_emscripten, "Test is unstable under Emscripten."
186+
)
184187
def test_closerange(self):
185188
first = os.open(os_helper.TESTFN, os.O_CREAT|os.O_RDWR)
186189
# We must allocate two consecutive file descriptors, otherwise
@@ -1578,6 +1581,7 @@ def test_makedir(self):
15781581
'dir5', 'dir6')
15791582
os.makedirs(path)
15801583

1584+
@unittest.skipIf(support.is_emscripten, "Emscripten's umask is a stub.")
15811585
def test_mode(self):
15821586
with os_helper.temp_umask(0o002):
15831587
base = os_helper.TESTFN
@@ -2158,6 +2162,9 @@ def test_fchown(self):
21582162
self.check(os.fchown, -1, -1)
21592163

21602164
@unittest.skipUnless(hasattr(os, 'fpathconf'), 'test needs os.fpathconf()')
2165+
@unittest.skipIf(
2166+
support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
2167+
)
21612168
def test_fpathconf(self):
21622169
self.check(os.pathconf, "PC_NAME_MAX")
21632170
self.check(os.fpathconf, "PC_NAME_MAX")
@@ -4058,6 +4065,7 @@ def test_path_t_converter_and_custom_class(self):
40584065

40594066
@unittest.skipUnless(hasattr(os, 'get_blocking'),
40604067
'needs os.get_blocking() and os.set_blocking()')
4068+
@unittest.skipIf(support.is_emscripten, "Cannot unset blocking flag")
40614069
class BlockingTests(unittest.TestCase):
40624070
def test_blocking(self):
40634071
fd = os.open(__file__, os.O_RDONLY)
@@ -4513,7 +4521,7 @@ def test_times(self):
45134521
self.assertEqual(times.elapsed, 0)
45144522

45154523

4516-
@requires_os_func('fork')
4524+
@support.requires_fork()
45174525
class ForkTests(unittest.TestCase):
45184526
def test_fork(self):
45194527
# bpo-42540: ensure os.fork() with non-default memory allocator does

Lib/test/test_re.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from test.support import (gc_collect, bigmemtest, _2G,
22
cpython_only, captured_stdout,
3-
check_disallow_instantiation)
3+
check_disallow_instantiation, is_emscripten)
44
import locale
55
import re
66
import sre_compile
@@ -1892,6 +1892,7 @@ def test_bug_20998(self):
18921892
# with ignore case.
18931893
self.assertEqual(re.fullmatch('[a-c]+', 'ABC', re.I).span(), (0, 3))
18941894

1895+
@unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
18951896
def test_locale_caching(self):
18961897
# Issue #22410
18971898
oldlocale = locale.setlocale(locale.LC_CTYPE)
@@ -1928,6 +1929,7 @@ def check_en_US_utf8(self):
19281929
self.assertIsNone(re.match(b'(?Li)\xc5', b'\xe5'))
19291930
self.assertIsNone(re.match(b'(?Li)\xe5', b'\xc5'))
19301931

1932+
@unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
19311933
def test_locale_compiled(self):
19321934
oldlocale = locale.setlocale(locale.LC_CTYPE)
19331935
self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)

0 commit comments

Comments
 (0)