[Python-checkins] bpo-40280: Skip more tests on Emscripten (GH-31947)

tiran webhook-mailer at python.org
Thu Mar 17 07:10:06 EDT 2022


https://github.com/python/cpython/commit/ef1327e3b622e0cafdf8bfc1f480fed0dd386be6
commit: ef1327e3b622e0cafdf8bfc1f480fed0dd386be6
branch: main
author: Christian Heimes <christian at python.org>
committer: tiran <christian at python.org>
date: 2022-03-17T12:09:57+01:00
summary:

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

files:
M Lib/distutils/tests/test_dir_util.py
M Lib/test/test__locale.py
M Lib/test/test__xxsubinterpreters.py
M Lib/test/test_coroutines.py
M Lib/test/test_interpreters.py
M Lib/test/test_locale.py
M Lib/test/test_logging.py
M Lib/test/test_ntpath.py
M Lib/test/test_os.py
M Lib/test/test_re.py
M Lib/test/test_select.py
M Lib/test/test_strptime.py
M Lib/test/test_support.py
M Lib/test/test_tempfile.py
M Lib/test/test_time.py
M Tools/wasm/config.site-wasm32-emscripten

diff --git a/Lib/distutils/tests/test_dir_util.py b/Lib/distutils/tests/test_dir_util.py
index 1b1f3bbb02e34..f3ba0ee33b4bc 100644
--- a/Lib/distutils/tests/test_dir_util.py
+++ b/Lib/distutils/tests/test_dir_util.py
@@ -11,7 +11,7 @@
 
 from distutils import log
 from distutils.tests import support
-from test.support import run_unittest
+from test.support import run_unittest, is_emscripten
 
 
 class DirUtilTestCase(support.TempdirManager, unittest.TestCase):
@@ -55,6 +55,7 @@ def test_mkpath_remove_tree_verbosity(self):
 
     @unittest.skipIf(sys.platform.startswith('win'),
         "This test is only appropriate for POSIX-like systems.")
+    @unittest.skipIf(is_emscripten, "Emscripten's umask is a stub.")
     def test_mkpath_with_custom_mode(self):
         # Get and set the current umask value for testing mode bits.
         umask = os.umask(0o002)
diff --git a/Lib/test/test__locale.py b/Lib/test/test__locale.py
index 59a00bad7d98a..e25c92c2c82c5 100644
--- a/Lib/test/test__locale.py
+++ b/Lib/test/test__locale.py
@@ -9,6 +9,8 @@
 import unittest
 from platform import uname
 
+from test import support
+
 if uname().system == "Darwin":
     maj, min, mic = [int(part) for part in uname().release.split(".")]
     if (maj, min, mic) < (8, 0, 0):
@@ -106,6 +108,9 @@ def numeric_tester(self, calc_type, calc_value, data_type, used_locale):
             return True
 
     @unittest.skipUnless(nl_langinfo, "nl_langinfo is not available")
+    @unittest.skipIf(
+        support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
+    )
     def test_lc_numeric_nl_langinfo(self):
         # Test nl_langinfo against known values
         tested = False
@@ -122,6 +127,9 @@ def test_lc_numeric_nl_langinfo(self):
         if not tested:
             self.skipTest('no suitable locales')
 
+    @unittest.skipIf(
+        support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
+    )
     def test_lc_numeric_localeconv(self):
         # Test localeconv against known values
         tested = False
diff --git a/Lib/test/test__xxsubinterpreters.py b/Lib/test/test__xxsubinterpreters.py
index 177a8a64a4329..5d0ed9ea14ac7 100644
--- a/Lib/test/test__xxsubinterpreters.py
+++ b/Lib/test/test__xxsubinterpreters.py
@@ -818,7 +818,7 @@ def f():
 
         self.assertEqual(out, 'it worked!')
 
-    @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()")
+    @support.requires_fork()
     def test_fork(self):
         import tempfile
         with tempfile.NamedTemporaryFile('w+', encoding="utf-8") as file:
diff --git a/Lib/test/test_coroutines.py b/Lib/test/test_coroutines.py
index 3081853303b37..77944e678c750 100644
--- a/Lib/test/test_coroutines.py
+++ b/Lib/test/test_coroutines.py
@@ -2208,6 +2208,9 @@ async def f():
             gen.cr_frame.clear()
 
 
+ at unittest.skipIf(
+    support.is_emscripten, "asyncio does not work under Emscripten yet."
+)
 class CoroAsyncIOCompatTest(unittest.TestCase):
 
     def test_asyncio_1(self):
diff --git a/Lib/test/test_interpreters.py b/Lib/test/test_interpreters.py
index 48c7119fff1cf..b969ddf33d81b 100644
--- a/Lib/test/test_interpreters.py
+++ b/Lib/test/test_interpreters.py
@@ -5,6 +5,7 @@
 import unittest
 import time
 
+from test import support
 from test.support import import_helper
 _interpreters = import_helper.import_module('_xxsubinterpreters')
 from test.support import interpreters
@@ -408,7 +409,7 @@ def f():
 
         self.assertEqual(out, 'it worked!')
 
-    @unittest.skipUnless(hasattr(os, 'fork'), "test needs os.fork()")
+    @support.requires_fork()
     def test_fork(self):
         interp = interpreters.create()
         import tempfile
diff --git a/Lib/test/test_locale.py b/Lib/test/test_locale.py
index 2a3b0acc6bd60..774b0fcd33344 100644
--- a/Lib/test/test_locale.py
+++ b/Lib/test/test_locale.py
@@ -1,5 +1,5 @@
 from decimal import Decimal
-from test.support import verbose, is_android
+from test.support import verbose, is_android, is_emscripten
 from test.support.warnings_helper import check_warnings
 import unittest
 import locale
@@ -373,11 +373,13 @@ def setUp(self):
 
     @unittest.skipIf(sys.platform.startswith('aix'),
                      'bpo-29972: broken test on AIX')
+    @unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
     def test_strcoll_with_diacritic(self):
         self.assertLess(locale.strcoll('à', 'b'), 0)
 
     @unittest.skipIf(sys.platform.startswith('aix'),
                      'bpo-29972: broken test on AIX')
+    @unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
     def test_strxfrm_with_diacritic(self):
         self.assertLess(locale.strxfrm('à'), locale.strxfrm('b'))
 
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py
index 4f3315161cf20..be193dcdacf4f 100644
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -674,7 +674,7 @@ def remove_loop(fname, tries):
     # based on os.fork existing because that is what users and this test use.
     # This helps ensure that when fork exists (the important concept) that the
     # register_at_fork mechanism is also present and used.
-    @unittest.skipIf(not hasattr(os, 'fork'), 'Test requires os.fork().')
+    @support.requires_fork()
     def test_post_fork_child_no_deadlock(self):
         """Ensure child logging locks are not held; bpo-6721 & bpo-36533."""
         class _OurHandler(logging.Handler):
@@ -4493,6 +4493,7 @@ def _extract_logrecord_process_name(key, logMultiprocessing, conn=None):
             return results
 
     def test_multiprocessing(self):
+        support.skip_if_broken_multiprocessing_synchronize()
         multiprocessing_imported = 'multiprocessing' in sys.modules
         try:
             # logMultiprocessing is True by default
diff --git a/Lib/test/test_ntpath.py b/Lib/test/test_ntpath.py
index 99a77e3fb43dc..7211ed861762b 100644
--- a/Lib/test/test_ntpath.py
+++ b/Lib/test/test_ntpath.py
@@ -4,7 +4,7 @@
 import unittest
 import warnings
 from test.support import os_helper
-from test.support import TestFailed
+from test.support import TestFailed, is_emscripten
 from test.support.os_helper import FakePath
 from test import test_genericpath
 from tempfile import TemporaryFile
@@ -747,6 +747,7 @@ def check_error(exc, paths):
         self.assertRaises(TypeError, ntpath.commonpath,
                           ['Program Files', b'C:\\Program Files\\Foo'])
 
+    @unittest.skipIf(is_emscripten, "Emscripten cannot fstat unnamed files.")
     def test_sameopenfile(self):
         with TemporaryFile() as tf1, TemporaryFile() as tf2:
             # Make sure the same file is really the same
diff --git a/Lib/test/test_os.py b/Lib/test/test_os.py
index ae8d930a95253..426d2ae9373bc 100644
--- a/Lib/test/test_os.py
+++ b/Lib/test/test_os.py
@@ -181,6 +181,9 @@ def test_access(self):
         os.close(f)
         self.assertTrue(os.access(os_helper.TESTFN, os.W_OK))
 
+    @unittest.skipIf(
+        support.is_emscripten, "Test is unstable under Emscripten."
+    )
     def test_closerange(self):
         first = os.open(os_helper.TESTFN, os.O_CREAT|os.O_RDWR)
         # We must allocate two consecutive file descriptors, otherwise
@@ -1578,6 +1581,7 @@ def test_makedir(self):
                             'dir5', 'dir6')
         os.makedirs(path)
 
+    @unittest.skipIf(support.is_emscripten, "Emscripten's umask is a stub.")
     def test_mode(self):
         with os_helper.temp_umask(0o002):
             base = os_helper.TESTFN
@@ -2158,6 +2162,9 @@ def test_fchown(self):
         self.check(os.fchown, -1, -1)
 
     @unittest.skipUnless(hasattr(os, 'fpathconf'), 'test needs os.fpathconf()')
+    @unittest.skipIf(
+        support.is_emscripten, "musl libc issue on Emscripten, bpo-46390"
+    )
     def test_fpathconf(self):
         self.check(os.pathconf, "PC_NAME_MAX")
         self.check(os.fpathconf, "PC_NAME_MAX")
@@ -4058,6 +4065,7 @@ def test_path_t_converter_and_custom_class(self):
 
 @unittest.skipUnless(hasattr(os, 'get_blocking'),
                      'needs os.get_blocking() and os.set_blocking()')
+ at unittest.skipIf(support.is_emscripten, "Cannot unset blocking flag")
 class BlockingTests(unittest.TestCase):
     def test_blocking(self):
         fd = os.open(__file__, os.O_RDONLY)
@@ -4513,7 +4521,7 @@ def test_times(self):
             self.assertEqual(times.elapsed, 0)
 
 
- at requires_os_func('fork')
+ at support.requires_fork()
 class ForkTests(unittest.TestCase):
     def test_fork(self):
         # bpo-42540: ensure os.fork() with non-default memory allocator does
diff --git a/Lib/test/test_re.py b/Lib/test/test_re.py
index 18fa24a99ce03..59575962eb4f3 100644
--- a/Lib/test/test_re.py
+++ b/Lib/test/test_re.py
@@ -1,6 +1,6 @@
 from test.support import (gc_collect, bigmemtest, _2G,
                           cpython_only, captured_stdout,
-                          check_disallow_instantiation)
+                          check_disallow_instantiation, is_emscripten)
 import locale
 import re
 import sre_compile
@@ -1892,6 +1892,7 @@ def test_bug_20998(self):
         # with ignore case.
         self.assertEqual(re.fullmatch('[a-c]+', 'ABC', re.I).span(), (0, 3))
 
+    @unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
     def test_locale_caching(self):
         # Issue #22410
         oldlocale = locale.setlocale(locale.LC_CTYPE)
@@ -1928,6 +1929,7 @@ def check_en_US_utf8(self):
         self.assertIsNone(re.match(b'(?Li)\xc5', b'\xe5'))
         self.assertIsNone(re.match(b'(?Li)\xe5', b'\xc5'))
 
+    @unittest.skipIf(is_emscripten, "musl libc issue on Emscripten, bpo-46390")
     def test_locale_compiled(self):
         oldlocale = locale.setlocale(locale.LC_CTYPE)
         self.addCleanup(locale.setlocale, locale.LC_CTYPE, oldlocale)
diff --git a/Lib/test/test_select.py b/Lib/test/test_select.py
index 69421fd77558d..8b59321121e49 100644
--- a/Lib/test/test_select.py
+++ b/Lib/test/test_select.py
@@ -78,6 +78,9 @@ def test_select(self):
                           rfd, wfd, xfd)
 
     # Issue 16230: Crash on select resized list
+    @unittest.skipIf(
+        support.is_emscripten, "Emscripten cannot select a fd multiple times."
+    )
     def test_select_mutated(self):
         a = []
         class F:
diff --git a/Lib/test/test_strptime.py b/Lib/test/test_strptime.py
index e5f75b7aab9aa..e3fcabef94611 100644
--- a/Lib/test/test_strptime.py
+++ b/Lib/test/test_strptime.py
@@ -70,6 +70,9 @@ def test_am_pm(self):
         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()
@@ -368,6 +371,9 @@ def test_bad_offset(self):
         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.
diff --git a/Lib/test/test_support.py b/Lib/test/test_support.py
index 59e9f3a6c1c8d..2cff377cf629e 100644
--- a/Lib/test/test_support.py
+++ b/Lib/test/test_support.py
@@ -658,10 +658,13 @@ def id(self):
             self.assertFalse(support.match_test(test_access))
             self.assertTrue(support.match_test(test_chdir))
 
+    @unittest.skipIf(support.is_emscripten, "Unstable in Emscripten")
     def test_fd_count(self):
         # We cannot test the absolute value of fd_count(): on old Linux
         # kernel or glibc versions, os.urandom() keeps a FD open on
         # /dev/urandom device and Python has 4 FD opens instead of 3.
+        # Test is unstable on Emscripten. The platform starts and stops
+        # background threads that use pipes and epoll fds.
         start = os_helper.fd_count()
         fd = os.open(__file__, os.O_RDONLY)
         try:
diff --git a/Lib/test/test_tempfile.py b/Lib/test/test_tempfile.py
index 25fddaec6d317..a6847189dca46 100644
--- a/Lib/test/test_tempfile.py
+++ b/Lib/test/test_tempfile.py
@@ -341,6 +341,9 @@ 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
@@ -465,6 +468,7 @@ def test_file_mode(self):
         self.assertEqual(mode, expected)
 
     @unittest.skipUnless(has_spawnl, 'os.spawnl not available')
+    @support.requires_subprocess()
     def test_noinherit(self):
         # _mkstemp_inner file handles are not inherited by child processes
 
@@ -1282,6 +1286,9 @@ def use_closed():
                 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)
diff --git a/Lib/test/test_time.py b/Lib/test/test_time.py
index faac639613a5c..dc0bbb0ee2931 100644
--- a/Lib/test/test_time.py
+++ b/Lib/test/test_time.py
@@ -313,6 +313,9 @@ def test_asctime(self):
     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')
@@ -699,6 +702,9 @@ 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.
diff --git a/Tools/wasm/config.site-wasm32-emscripten b/Tools/wasm/config.site-wasm32-emscripten
index 2a601987ccedf..7f2df3a47723f 100644
--- a/Tools/wasm/config.site-wasm32-emscripten
+++ b/Tools/wasm/config.site-wasm32-emscripten
@@ -53,6 +53,9 @@ ac_cv_func_symlinkat=no
 ac_cv_func_readlinkat=no
 ac_cv_func_fchmodat=no
 ac_cv_func_dup3=no
+# lchmod/lchown are implemented, but fail with ENOTSUP.
+ac_cv_func_lchmod=no
+ac_cv_func_lchown=no
 
 # Syscalls not implemented in emscripten
 # [Errno 52] Function not implemented



More information about the Python-checkins mailing list