]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-127146: Emscripten clean up test suite (#127984)
authorHood Chatham <roberthoodchatham@gmail.com>
Tue, 17 Dec 2024 07:48:23 +0000 (08:48 +0100)
committerGitHub <noreply@github.com>
Tue, 17 Dec 2024 07:48:23 +0000 (07:48 +0000)
Removed test skips that are no longer required as a result of Emscripten updates.

12 files changed:
Lib/test/libregrtest/setup.py
Lib/test/libregrtest/utils.py
Lib/test/test_fileio.py
Lib/test/test_logging.py
Lib/test/test_os.py
Lib/test/test_pathlib/test_pathlib.py
Lib/test/test_pydoc/test_pydoc.py
Lib/test/test_strptime.py
Lib/test/test_support.py
Lib/test/test_tempfile.py
Lib/test/test_time.py
Lib/test/test_unicode_file_functions.py

index ba57f06b4841d4db16fdb7cde1d4397decf424be..c0346aa934d3947488dcc8da2bb9698c6c7159f7 100644 (file)
@@ -11,7 +11,7 @@ from test.support.os_helper import TESTFN_UNDECODABLE, FS_NONASCII
 from .filter import set_match_tests
 from .runtests import RunTests
 from .utils import (
-    setup_unraisable_hook, setup_threading_excepthook, fix_umask,
+    setup_unraisable_hook, setup_threading_excepthook,
     adjust_rlimit_nofile)
 
 
@@ -26,8 +26,6 @@ def setup_test_dir(testdir: str | None) -> None:
 
 
 def setup_process() -> None:
-    fix_umask()
-
     assert sys.__stderr__ is not None, "sys.__stderr__ is None"
     try:
         stderr_fd = sys.__stderr__.fileno()
index 1ecfc61af9e39d5d864537636ca7de0e2381a13d..3eff9e753b6d8480816a949d19506f766e16f1b6 100644 (file)
@@ -478,17 +478,6 @@ def get_temp_dir(tmp_dir: StrPath | None = None) -> StrPath:
     return os.path.abspath(tmp_dir)
 
 
-def fix_umask() -> None:
-    if support.is_emscripten:
-        # Emscripten has default umask 0o777, which breaks some tests.
-        # see https://github.com/emscripten-core/emscripten/issues/17269
-        old_mask = os.umask(0)
-        if old_mask == 0o777:
-            os.umask(0o027)
-        else:
-            os.umask(old_mask)
-
-
 def get_work_dir(parent_dir: StrPath, worker: bool = False) -> StrPath:
     # 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
index e681417e15d34ba2be0074f6e7bcc3aceb7d2853..5a0f033ebb82d2f9553f8dceaba44b8213bdf3f7 100644 (file)
@@ -10,7 +10,7 @@ from weakref import proxy
 from functools import wraps
 
 from test.support import (
-    cpython_only, swap_attr, gc_collect, is_emscripten, is_wasi,
+    cpython_only, swap_attr, gc_collect, is_wasi,
     infinite_recursion, strace_helper
 )
 from test.support.os_helper import (
@@ -531,7 +531,7 @@ class OtherFileTests:
             self.assertEqual(f.isatty(), False)
             f.close()
 
-            if sys.platform != "win32" and not is_emscripten:
+            if sys.platform != "win32":
                 try:
                     f = self.FileIO("/dev/tty", "a")
                 except OSError:
index e72f222e1c7eeb79516f09054885c92aba9d9cab..671b4c57a809aa12579e4fde90b85d5e49a5ea57 100644 (file)
@@ -680,9 +680,6 @@ class HandlerTest(BaseTest):
             os.unlink(fn)
 
     @unittest.skipIf(os.name == 'nt', 'WatchedFileHandler not appropriate for Windows.')
-    @unittest.skipIf(
-        support.is_emscripten, "Emscripten cannot fstat unlinked files."
-    )
     @threading_helper.requires_working_threading()
     @support.requires_resource('walltime')
     def test_race(self):
index 8aac92934f6ac04d79f81f66bdcd7a46053bf3e6..b0e686cb754b932e39114f6b8c8f74895516e5ca 100644 (file)
@@ -188,9 +188,6 @@ class FileTests(unittest.TestCase):
         os.close(f)
         self.assertTrue(os.access(os_helper.TESTFN, os.W_OK))
 
-    @unittest.skipIf(
-        support.is_emscripten, "Test is unstable under Emscripten."
-    )
     @unittest.skipIf(
         support.is_wasi, "WASI does not support dup."
     )
@@ -1428,9 +1425,7 @@ class WalkTests(unittest.TestCase):
         else:
             self.sub2_tree = (sub2_path, ["SUB21"], ["tmp3"])
 
-        if not support.is_emscripten:
-            # Emscripten fails with inaccessible directory
-            os.chmod(sub21_path, 0)
+        os.chmod(sub21_path, 0)
         try:
             os.listdir(sub21_path)
         except PermissionError:
@@ -1726,9 +1721,6 @@ class FwalkTests(WalkTests):
                 # check that listdir() returns consistent information
                 self.assertEqual(set(os.listdir(rootfd)), set(dirs) | set(files))
 
-    @unittest.skipIf(
-        support.is_emscripten, "Cannot dup stdout on Emscripten"
-    )
     @unittest.skipIf(
         support.is_android, "dup return value is unpredictable on Android"
     )
@@ -1745,9 +1737,6 @@ class FwalkTests(WalkTests):
         self.addCleanup(os.close, newfd)
         self.assertEqual(newfd, minfd)
 
-    @unittest.skipIf(
-        support.is_emscripten, "Cannot dup stdout on Emscripten"
-    )
     @unittest.skipIf(
         support.is_android, "dup return value is unpredictable on Android"
     )
@@ -1816,8 +1805,8 @@ class MakedirTests(unittest.TestCase):
         os.makedirs(path)
 
     @unittest.skipIf(
-        support.is_emscripten or support.is_wasi,
-        "Emscripten's/WASI's umask is a stub."
+        support.is_wasi,
+        "WASI's umask is a stub."
     )
     def test_mode(self):
         with os_helper.temp_umask(0o002):
@@ -1832,8 +1821,8 @@ class MakedirTests(unittest.TestCase):
                 self.assertEqual(os.stat(parent).st_mode & 0o777, 0o775)
 
     @unittest.skipIf(
-        support.is_emscripten or support.is_wasi,
-        "Emscripten's/WASI's umask is a stub."
+        support.is_wasi,
+        "WASI's umask is a stub."
     )
     def test_exist_ok_existing_directory(self):
         path = os.path.join(os_helper.TESTFN, 'dir1')
@@ -1850,8 +1839,8 @@ class MakedirTests(unittest.TestCase):
         os.makedirs(os.path.abspath('/'), exist_ok=True)
 
     @unittest.skipIf(
-        support.is_emscripten or support.is_wasi,
-        "Emscripten's/WASI's umask is a stub."
+        support.is_wasi,
+        "WASI's umask is a stub."
     )
     def test_exist_ok_s_isgid_directory(self):
         path = os.path.join(os_helper.TESTFN, 'dir1')
@@ -2429,10 +2418,6 @@ class TestInvalidFD(unittest.TestCase):
         self.check(os.dup2, 20)
 
     @unittest.skipUnless(hasattr(os, 'dup2'), 'test needs os.dup2()')
-    @unittest.skipIf(
-        support.is_emscripten,
-        "dup2() with negative fds is broken on Emscripten (see gh-102179)"
-    )
     def test_dup2_negative_fd(self):
         valid_fd = os.open(__file__, os.O_RDONLY)
         self.addCleanup(os.close, valid_fd)
@@ -2457,14 +2442,14 @@ class TestInvalidFD(unittest.TestCase):
         self.check(os.fchown, -1, -1)
 
     @unittest.skipUnless(hasattr(os, 'fpathconf'), 'test needs os.fpathconf()')
-    @unittest.skipIf(
-        support.is_emscripten or support.is_wasi,
-        "musl libc issue on Emscripten/WASI, bpo-46390"
-    )
     def test_fpathconf(self):
         self.assertIn("PC_NAME_MAX", os.pathconf_names)
-        self.check(os.pathconf, "PC_NAME_MAX")
-        self.check(os.fpathconf, "PC_NAME_MAX")
+        if not (support.is_emscripten or support.is_wasi):
+            # musl libc pathconf ignores the file descriptor and always returns
+            # a constant, so the assertion that it should notice a bad file
+            # descriptor and return EBADF fails.
+            self.check(os.pathconf, "PC_NAME_MAX")
+            self.check(os.fpathconf, "PC_NAME_MAX")
         self.check_bool(os.pathconf, "PC_NAME_MAX")
         self.check_bool(os.fpathconf, "PC_NAME_MAX")
 
@@ -3395,9 +3380,6 @@ class DeviceEncodingTests(unittest.TestCase):
     @unittest.skipUnless(os.isatty(0) and not win32_is_iot() and (sys.platform.startswith('win') or
             (hasattr(locale, 'nl_langinfo') and hasattr(locale, 'CODESET'))),
             'test requires a tty and either Windows or nl_langinfo(CODESET)')
-    @unittest.skipIf(
-        support.is_emscripten, "Cannot get encoding of stdin on Emscripten"
-    )
     def test_device_encoding(self):
         encoding = os.device_encoding(0)
         self.assertIsNotNone(encoding)
index 68bff2cf0d511e294a640d7a8269500cb0d3d375..ac3a3b4f15c10e1ad38481fd03c9fe8d97aee391 100644 (file)
@@ -1673,7 +1673,6 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest):
         self.assertTrue(p.exists())
         self.assertEqual(p.stat().st_ctime, st_ctime_first)
 
-    @unittest.skipIf(is_emscripten, "FS root cannot be modified on Emscripten.")
     def test_mkdir_exist_ok_root(self):
         # Issue #25803: A drive root could raise PermissionError on Windows.
         self.cls('/').resolve().mkdir(exist_ok=True)
@@ -2039,7 +2038,6 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest):
         self.assertEqual(expect, set(p.rglob(FakePath(pattern))))
 
     @needs_symlinks
-    @unittest.skipIf(is_emscripten, "Hangs")
     def test_glob_recurse_symlinks_common(self):
         def _check(path, glob, expected):
             actual = {path for path in path.glob(glob, recurse_symlinks=True)
@@ -2077,7 +2075,6 @@ class PathTest(test_pathlib_abc.DummyPathTest, PurePathTest):
         _check(p, "*/dirD/**/", ["dirC/dirD/"])
 
     @needs_symlinks
-    @unittest.skipIf(is_emscripten, "Hangs")
     def test_rglob_recurse_symlinks_common(self):
         def _check(path, glob, expected):
             actual = {path for path in path.rglob(glob, recurse_symlinks=True)
@@ -2484,9 +2481,7 @@ class PathWalkTest(test_pathlib_abc.DummyPathWalkTest):
             os.symlink(tmp5_path, broken_link3_path)
             self.sub2_tree[2].append('broken_link3')
             self.sub2_tree[2].sort()
-        if not is_emscripten:
-            # Emscripten fails with inaccessible directories.
-            os.chmod(sub21_path, 0)
+        os.chmod(sub21_path, 0)
         try:
             os.listdir(sub21_path)
         except PermissionError:
index 2a4d3ab73db608e4fc69f49c83458e33e7bf7b1b..3283fde9e12a8a33ffd15b7a53e7d5a3287d0121 100644 (file)
@@ -1224,7 +1224,6 @@ class PydocImportTest(PydocBaseTest):
         self.assertEqual(err.getvalue(), '')
 
     @os_helper.skip_unless_working_chmod
-    @unittest.skipIf(is_emscripten, "cannot remove x bit")
     def test_apropos_empty_doc(self):
         pkgdir = os.path.join(TESTFN, 'walkpkg')
         os.mkdir(pkgdir)
index 9f5cfca9c7f1249ddf4706c04e05b48618f25001..0d30a63ab0c140cc87b009312286a0da35167e36 100644 (file)
@@ -79,9 +79,6 @@ class LocaleTime_Tests(unittest.TestCase):
         self.assertEqual(self.LT_ins.am_pm[position], strftime_output,
                          "AM/PM representation in the wrong position within the tuple")
 
-    @unittest.skipIf(
-        support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
-    )
     def test_timezone(self):
         # Make sure timezone is correct
         timezone = time.strftime("%Z", self.time_tuple).lower()
@@ -431,9 +428,6 @@ class StrptimeTests(unittest.TestCase):
         self.assertEqual("Inconsistent use of : in -01:3030", str(err.exception))
 
     @skip_if_buggy_ucrt_strfptime
-    @unittest.skipIf(
-        support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
-    )
     def test_timezone(self):
         # Test timezone directives.
         # When gmtime() is used with %Z, entire result of strftime() is empty.
index 635ae03a404988e3204efeab5a33d39a1be80d6f..d900db546ada8d92e0e80b14bf48a1fc26a51e13 100644 (file)
@@ -549,7 +549,6 @@ class TestSupport(unittest.TestCase):
                 self.check_options(opts, 'optim_args_from_interpreter_flags')
 
     @unittest.skipIf(support.is_apple_mobile, "Unstable on Apple Mobile")
-    @unittest.skipIf(support.is_emscripten, "Unstable in Emscripten")
     @unittest.skipIf(support.is_wasi, "Unavailable on WASI")
     def test_fd_count(self):
         # We cannot test the absolute value of fd_count(): on old Linux kernel
index a5e182cef23dc54f534fe04dcc2aafcf0e35fe6a..57e9bd20c77ee1a5aaace40d613a0d69a3c922b3 100644 (file)
@@ -328,10 +328,6 @@ def _mock_candidate_names(*names):
 
 
 class TestBadTempdir:
-
-    @unittest.skipIf(
-        support.is_emscripten, "Emscripten cannot remove write bits."
-    )
     def test_read_only_directory(self):
         with _inside_empty_temp_dir():
             oldmode = mode = os.stat(tempfile.tempdir).st_mode
@@ -1240,9 +1236,6 @@ class TestSpooledTemporaryFile(BaseTestCase):
         with self.assertWarns(ResourceWarning):
             f.__del__()
 
-    @unittest.skipIf(
-        support.is_emscripten, "Emscripten cannot fstat renamed files."
-    )
     def test_del_rolled_file(self):
         # The rolled file should be deleted when the SpooledTemporaryFile
         # object is deleted. This should raise a ResourceWarning since the file
@@ -1468,9 +1461,6 @@ class TestSpooledTemporaryFile(BaseTestCase):
                 pass
         self.assertRaises(ValueError, use_closed)
 
-    @unittest.skipIf(
-        support.is_emscripten, "Emscripten cannot fstat renamed files."
-    )
     def test_truncate_with_size_parameter(self):
         # A SpooledTemporaryFile can be truncated to zero size
         f = tempfile.SpooledTemporaryFile(max_size=10)
index 92398300f2657795eaa56b3ae67926fab9280a65..1c540bed33c71ea28552f505464709dc9f7c64ab 100644 (file)
@@ -361,9 +361,6 @@ class TimeTestCase(unittest.TestCase):
     def test_asctime_bounding_check(self):
         self._bounds_checking(time.asctime)
 
-    @unittest.skipIf(
-        support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
-    )
     def test_ctime(self):
         t = time.mktime((1973, 9, 16, 1, 3, 52, 0, 0, -1))
         self.assertEqual(time.ctime(t), 'Sun Sep 16 01:03:52 1973')
@@ -746,9 +743,6 @@ class TestStrftime4dyear(_TestStrftimeYear, _Test4dYear, unittest.TestCase):
 class TestPytime(unittest.TestCase):
     @skip_if_buggy_ucrt_strfptime
     @unittest.skipUnless(time._STRUCT_TM_ITEMS == 11, "needs tm_zone support")
-    @unittest.skipIf(
-        support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
-    )
     def test_localtime_timezone(self):
 
         # Get the localtime and examine it for the offset and zone.
index 25c16e3a0b7e430c8f0721fd186287615789a27b..4a067d714e12e3a888f648f569d520c67d86b167 100644 (file)
@@ -125,8 +125,8 @@ class UnicodeFileTests(unittest.TestCase):
     # open(), os.stat(), etc. don't raise any exception.
     @unittest.skipIf(is_apple, 'irrelevant test on Apple platforms')
     @unittest.skipIf(
-        support.is_emscripten or support.is_wasi,
-        "test fails on Emscripten/WASI when host platform is macOS."
+        support.is_wasi,
+        "test fails on WASI when host platform is macOS."
     )
     def test_normalize(self):
         files = set(self.files)