Skip to content

Commit 1183e4c

Browse files
authored
gh-127146: Emscripten clean up test suite (#127984)
Removed test skips that are no longer required as a result of Emscripten updates.
1 parent cfeaa99 commit 1183e4c

12 files changed

+19
-82
lines changed

Lib/test/libregrtest/setup.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
from .filter import set_match_tests
1212
from .runtests import RunTests
1313
from .utils import (
14-
setup_unraisable_hook, setup_threading_excepthook, fix_umask,
14+
setup_unraisable_hook, setup_threading_excepthook,
1515
adjust_rlimit_nofile)
1616

1717

@@ -26,8 +26,6 @@ def setup_test_dir(testdir: str | None) -> None:
2626

2727

2828
def setup_process() -> None:
29-
fix_umask()
30-
3129
assert sys.__stderr__ is not None, "sys.__stderr__ is None"
3230
try:
3331
stderr_fd = sys.__stderr__.fileno()

Lib/test/libregrtest/utils.py

-11
Original file line numberDiff line numberDiff line change
@@ -478,17 +478,6 @@ def get_temp_dir(tmp_dir: StrPath | None = None) -> StrPath:
478478
return os.path.abspath(tmp_dir)
479479

480480

481-
def fix_umask() -> None:
482-
if support.is_emscripten:
483-
# Emscripten has default umask 0o777, which breaks some tests.
484-
# see https://github.com/emscripten-core/emscripten/issues/17269
485-
old_mask = os.umask(0)
486-
if old_mask == 0o777:
487-
os.umask(0o027)
488-
else:
489-
os.umask(old_mask)
490-
491-
492481
def get_work_dir(parent_dir: StrPath, worker: bool = False) -> StrPath:
493482
# Define a writable temp dir that will be used as cwd while running
494483
# the tests. The name of the dir includes the pid to allow parallel

Lib/test/test_fileio.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
from functools import wraps
1111

1212
from test.support import (
13-
cpython_only, swap_attr, gc_collect, is_emscripten, is_wasi,
13+
cpython_only, swap_attr, gc_collect, is_wasi,
1414
infinite_recursion, strace_helper
1515
)
1616
from test.support.os_helper import (
@@ -531,7 +531,7 @@ def testAbles(self):
531531
self.assertEqual(f.isatty(), False)
532532
f.close()
533533

534-
if sys.platform != "win32" and not is_emscripten:
534+
if sys.platform != "win32":
535535
try:
536536
f = self.FileIO("/dev/tty", "a")
537537
except OSError:

Lib/test/test_logging.py

-3
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,6 @@ def test_pathlike_objects(self):
680680
os.unlink(fn)
681681

682682
@unittest.skipIf(os.name == 'nt', 'WatchedFileHandler not appropriate for Windows.')
683-
@unittest.skipIf(
684-
support.is_emscripten, "Emscripten cannot fstat unlinked files."
685-
)
686683
@threading_helper.requires_working_threading()
687684
@support.requires_resource('walltime')
688685
def test_race(self):

Lib/test/test_os.py

+13-31
Original file line numberDiff line numberDiff line change
@@ -188,9 +188,6 @@ def test_access(self):
188188
os.close(f)
189189
self.assertTrue(os.access(os_helper.TESTFN, os.W_OK))
190190

191-
@unittest.skipIf(
192-
support.is_emscripten, "Test is unstable under Emscripten."
193-
)
194191
@unittest.skipIf(
195192
support.is_wasi, "WASI does not support dup."
196193
)
@@ -1428,9 +1425,7 @@ def setUp(self):
14281425
else:
14291426
self.sub2_tree = (sub2_path, ["SUB21"], ["tmp3"])
14301427

1431-
if not support.is_emscripten:
1432-
# Emscripten fails with inaccessible directory
1433-
os.chmod(sub21_path, 0)
1428+
os.chmod(sub21_path, 0)
14341429
try:
14351430
os.listdir(sub21_path)
14361431
except PermissionError:
@@ -1726,9 +1721,6 @@ def test_yields_correct_dir_fd(self):
17261721
# check that listdir() returns consistent information
17271722
self.assertEqual(set(os.listdir(rootfd)), set(dirs) | set(files))
17281723

1729-
@unittest.skipIf(
1730-
support.is_emscripten, "Cannot dup stdout on Emscripten"
1731-
)
17321724
@unittest.skipIf(
17331725
support.is_android, "dup return value is unpredictable on Android"
17341726
)
@@ -1745,9 +1737,6 @@ def test_fd_leak(self):
17451737
self.addCleanup(os.close, newfd)
17461738
self.assertEqual(newfd, minfd)
17471739

1748-
@unittest.skipIf(
1749-
support.is_emscripten, "Cannot dup stdout on Emscripten"
1750-
)
17511740
@unittest.skipIf(
17521741
support.is_android, "dup return value is unpredictable on Android"
17531742
)
@@ -1816,8 +1805,8 @@ def test_makedir(self):
18161805
os.makedirs(path)
18171806

18181807
@unittest.skipIf(
1819-
support.is_emscripten or support.is_wasi,
1820-
"Emscripten's/WASI's umask is a stub."
1808+
support.is_wasi,
1809+
"WASI's umask is a stub."
18211810
)
18221811
def test_mode(self):
18231812
with os_helper.temp_umask(0o002):
@@ -1832,8 +1821,8 @@ def test_mode(self):
18321821
self.assertEqual(os.stat(parent).st_mode & 0o777, 0o775)
18331822

18341823
@unittest.skipIf(
1835-
support.is_emscripten or support.is_wasi,
1836-
"Emscripten's/WASI's umask is a stub."
1824+
support.is_wasi,
1825+
"WASI's umask is a stub."
18371826
)
18381827
def test_exist_ok_existing_directory(self):
18391828
path = os.path.join(os_helper.TESTFN, 'dir1')
@@ -1850,8 +1839,8 @@ def test_exist_ok_existing_directory(self):
18501839
os.makedirs(os.path.abspath('/'), exist_ok=True)
18511840

18521841
@unittest.skipIf(
1853-
support.is_emscripten or support.is_wasi,
1854-
"Emscripten's/WASI's umask is a stub."
1842+
support.is_wasi,
1843+
"WASI's umask is a stub."
18551844
)
18561845
def test_exist_ok_s_isgid_directory(self):
18571846
path = os.path.join(os_helper.TESTFN, 'dir1')
@@ -2429,10 +2418,6 @@ def test_dup2(self):
24292418
self.check(os.dup2, 20)
24302419

24312420
@unittest.skipUnless(hasattr(os, 'dup2'), 'test needs os.dup2()')
2432-
@unittest.skipIf(
2433-
support.is_emscripten,
2434-
"dup2() with negative fds is broken on Emscripten (see gh-102179)"
2435-
)
24362421
def test_dup2_negative_fd(self):
24372422
valid_fd = os.open(__file__, os.O_RDONLY)
24382423
self.addCleanup(os.close, valid_fd)
@@ -2457,14 +2442,14 @@ def test_fchown(self):
24572442
self.check(os.fchown, -1, -1)
24582443

24592444
@unittest.skipUnless(hasattr(os, 'fpathconf'), 'test needs os.fpathconf()')
2460-
@unittest.skipIf(
2461-
support.is_emscripten or support.is_wasi,
2462-
"musl libc issue on Emscripten/WASI, bpo-46390"
2463-
)
24642445
def test_fpathconf(self):
24652446
self.assertIn("PC_NAME_MAX", os.pathconf_names)
2466-
self.check(os.pathconf, "PC_NAME_MAX")
2467-
self.check(os.fpathconf, "PC_NAME_MAX")
2447+
if not (support.is_emscripten or support.is_wasi):
2448+
# musl libc pathconf ignores the file descriptor and always returns
2449+
# a constant, so the assertion that it should notice a bad file
2450+
# descriptor and return EBADF fails.
2451+
self.check(os.pathconf, "PC_NAME_MAX")
2452+
self.check(os.fpathconf, "PC_NAME_MAX")
24682453
self.check_bool(os.pathconf, "PC_NAME_MAX")
24692454
self.check_bool(os.fpathconf, "PC_NAME_MAX")
24702455

@@ -3395,9 +3380,6 @@ def test_bad_fd(self):
33953380
@unittest.skipUnless(os.isatty(0) and not win32_is_iot() and (sys.platform.startswith('win') or
33963381
(hasattr(locale, 'nl_langinfo') and hasattr(locale, 'CODESET'))),
33973382
'test requires a tty and either Windows or nl_langinfo(CODESET)')
3398-
@unittest.skipIf(
3399-
support.is_emscripten, "Cannot get encoding of stdin on Emscripten"
3400-
)
34013383
def test_device_encoding(self):
34023384
encoding = os.device_encoding(0)
34033385
self.assertIsNotNone(encoding)

Lib/test/test_pathlib/test_pathlib.py

+1-6
Original file line numberDiff line numberDiff line change
@@ -1673,7 +1673,6 @@ def test_mkdir_exist_ok_with_parent(self):
16731673
self.assertTrue(p.exists())
16741674
self.assertEqual(p.stat().st_ctime, st_ctime_first)
16751675

1676-
@unittest.skipIf(is_emscripten, "FS root cannot be modified on Emscripten.")
16771676
def test_mkdir_exist_ok_root(self):
16781677
# Issue #25803: A drive root could raise PermissionError on Windows.
16791678
self.cls('/').resolve().mkdir(exist_ok=True)
@@ -2039,7 +2038,6 @@ def test_rglob_pathlike(self):
20392038
self.assertEqual(expect, set(p.rglob(FakePath(pattern))))
20402039

20412040
@needs_symlinks
2042-
@unittest.skipIf(is_emscripten, "Hangs")
20432041
def test_glob_recurse_symlinks_common(self):
20442042
def _check(path, glob, expected):
20452043
actual = {path for path in path.glob(glob, recurse_symlinks=True)
@@ -2077,7 +2075,6 @@ def _check(path, glob, expected):
20772075
_check(p, "*/dirD/**/", ["dirC/dirD/"])
20782076

20792077
@needs_symlinks
2080-
@unittest.skipIf(is_emscripten, "Hangs")
20812078
def test_rglob_recurse_symlinks_common(self):
20822079
def _check(path, glob, expected):
20832080
actual = {path for path in path.rglob(glob, recurse_symlinks=True)
@@ -2484,9 +2481,7 @@ def setUp(self):
24842481
os.symlink(tmp5_path, broken_link3_path)
24852482
self.sub2_tree[2].append('broken_link3')
24862483
self.sub2_tree[2].sort()
2487-
if not is_emscripten:
2488-
# Emscripten fails with inaccessible directories.
2489-
os.chmod(sub21_path, 0)
2484+
os.chmod(sub21_path, 0)
24902485
try:
24912486
os.listdir(sub21_path)
24922487
except PermissionError:

Lib/test/test_pydoc/test_pydoc.py

-1
Original file line numberDiff line numberDiff line change
@@ -1224,7 +1224,6 @@ def test_apropos_with_unreadable_dir(self):
12241224
self.assertEqual(err.getvalue(), '')
12251225

12261226
@os_helper.skip_unless_working_chmod
1227-
@unittest.skipIf(is_emscripten, "cannot remove x bit")
12281227
def test_apropos_empty_doc(self):
12291228
pkgdir = os.path.join(TESTFN, 'walkpkg')
12301229
os.mkdir(pkgdir)

Lib/test/test_strptime.py

-6
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,6 @@ def test_am_pm(self):
7979
self.assertEqual(self.LT_ins.am_pm[position], strftime_output,
8080
"AM/PM representation in the wrong position within the tuple")
8181

82-
@unittest.skipIf(
83-
support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
84-
)
8582
def test_timezone(self):
8683
# Make sure timezone is correct
8784
timezone = time.strftime("%Z", self.time_tuple).lower()
@@ -431,9 +428,6 @@ def test_bad_offset(self):
431428
self.assertEqual("Inconsistent use of : in -01:3030", str(err.exception))
432429

433430
@skip_if_buggy_ucrt_strfptime
434-
@unittest.skipIf(
435-
support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
436-
)
437431
def test_timezone(self):
438432
# Test timezone directives.
439433
# When gmtime() is used with %Z, entire result of strftime() is empty.

Lib/test/test_support.py

-1
Original file line numberDiff line numberDiff line change
@@ -549,7 +549,6 @@ def test_optim_args_from_interpreter_flags(self):
549549
self.check_options(opts, 'optim_args_from_interpreter_flags')
550550

551551
@unittest.skipIf(support.is_apple_mobile, "Unstable on Apple Mobile")
552-
@unittest.skipIf(support.is_emscripten, "Unstable in Emscripten")
553552
@unittest.skipIf(support.is_wasi, "Unavailable on WASI")
554553
def test_fd_count(self):
555554
# We cannot test the absolute value of fd_count(): on old Linux kernel

Lib/test/test_tempfile.py

-10
Original file line numberDiff line numberDiff line change
@@ -328,10 +328,6 @@ def _mock_candidate_names(*names):
328328

329329

330330
class TestBadTempdir:
331-
332-
@unittest.skipIf(
333-
support.is_emscripten, "Emscripten cannot remove write bits."
334-
)
335331
def test_read_only_directory(self):
336332
with _inside_empty_temp_dir():
337333
oldmode = mode = os.stat(tempfile.tempdir).st_mode
@@ -1240,9 +1236,6 @@ def test_del_unrolled_file(self):
12401236
with self.assertWarns(ResourceWarning):
12411237
f.__del__()
12421238

1243-
@unittest.skipIf(
1244-
support.is_emscripten, "Emscripten cannot fstat renamed files."
1245-
)
12461239
def test_del_rolled_file(self):
12471240
# The rolled file should be deleted when the SpooledTemporaryFile
12481241
# object is deleted. This should raise a ResourceWarning since the file
@@ -1468,9 +1461,6 @@ def use_closed():
14681461
pass
14691462
self.assertRaises(ValueError, use_closed)
14701463

1471-
@unittest.skipIf(
1472-
support.is_emscripten, "Emscripten cannot fstat renamed files."
1473-
)
14741464
def test_truncate_with_size_parameter(self):
14751465
# A SpooledTemporaryFile can be truncated to zero size
14761466
f = tempfile.SpooledTemporaryFile(max_size=10)

Lib/test/test_time.py

-6
Original file line numberDiff line numberDiff line change
@@ -361,9 +361,6 @@ def test_asctime(self):
361361
def test_asctime_bounding_check(self):
362362
self._bounds_checking(time.asctime)
363363

364-
@unittest.skipIf(
365-
support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
366-
)
367364
def test_ctime(self):
368365
t = time.mktime((1973, 9, 16, 1, 3, 52, 0, 0, -1))
369366
self.assertEqual(time.ctime(t), 'Sun Sep 16 01:03:52 1973')
@@ -746,9 +743,6 @@ class TestStrftime4dyear(_TestStrftimeYear, _Test4dYear, unittest.TestCase):
746743
class TestPytime(unittest.TestCase):
747744
@skip_if_buggy_ucrt_strfptime
748745
@unittest.skipUnless(time._STRUCT_TM_ITEMS == 11, "needs tm_zone support")
749-
@unittest.skipIf(
750-
support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
751-
)
752746
def test_localtime_timezone(self):
753747

754748
# Get the localtime and examine it for the offset and zone.

Lib/test/test_unicode_file_functions.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ def test_open(self):
125125
# open(), os.stat(), etc. don't raise any exception.
126126
@unittest.skipIf(is_apple, 'irrelevant test on Apple platforms')
127127
@unittest.skipIf(
128-
support.is_emscripten or support.is_wasi,
129-
"test fails on Emscripten/WASI when host platform is macOS."
128+
support.is_wasi,
129+
"test fails on WASI when host platform is macOS."
130130
)
131131
def test_normalize(self):
132132
files = set(self.files)

0 commit comments

Comments
 (0)