projects/guix·blob java-team · refs

430 lines · 18.7 KiB

1From f0698133e7d6c353a3e6ae0fc62e57ba558a9bc0 Mon Sep 17 00:00:00 2001
2From: Maxim Cournoyer <[email protected]>
3Date: Wed, 28 Oct 2020 22:55:05 -0400
4Subject: [PATCH] Skip problematic Python 3 tests in Guix.
5
6A subset of the hunks in this patch is tracked upstream at
7https://bugs.python.org/issue38845, which was contributed by Tanguy Le
8Carrour <[email protected]>.
9---
10 Lib/ctypes/test/test_callbacks.py | 3 +++
11 Lib/ctypes/test/test_find.py | 1 +
12 Lib/ctypes/test/test_libc.py | 3 +++
13 Lib/distutils/tests/test_archive_util.py | 2 ++
14 Lib/distutils/tests/test_sdist.py | 1 +
15 Lib/test/_test_multiprocessing.py | 2 ++
16 Lib/test/test_asyncio/test_base_events.py | 2 ++
17 Lib/test/test_generators.py | 1 +
18 Lib/test/test_pathlib.py | 3 +--
19 Lib/test/test_pdb.py | 4 ++--
20 Lib/test/test_regrtest.py | 2 ++
21 Lib/test/test_resource.py | 1 +
22 Lib/test/test_shutil.py | 2 ++
23 Lib/test/test_signal.py | 4 ++++
24 Lib/test/test_socket.py | 8 ++++++++
25 Lib/test/test_spwd.py | 6 ++----
26 Lib/test/test_tarfile.py | 9 ++++++---
27 Lib/test/test_threading.py | 3 +++
28 Lib/test/test_unicodedata.py | 1 +
29 Tools/scripts/run_tests.py | 2 +-
30 20 files changed, 48 insertions(+), 12 deletions(-)
31
32diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
33index d8e9c5a760..94fc5929c9 100644
34--- a/Lib/ctypes/test/test_callbacks.py
35+++ b/Lib/ctypes/test/test_callbacks.py
36@@ -5,6 +5,7 @@ from test import support
37 from ctypes import *
38 from ctypes.test import need_symbol
39 import _ctypes_test
40+import platform
41
42 class Callbacks(unittest.TestCase):
43 functype = CFUNCTYPE
44@@ -178,6 +179,8 @@ class SampleCallbacksTestCase(unittest.TestCase):
45
46 self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)
47
48+ @unittest.skipIf(platform.machine() in ['mips64'],
49+ "This test fails on this platform")
50 def test_issue_8959_a(self):
51 from ctypes.util import find_library
52 libc_path = find_library("c")
53diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
54index 92ac1840ad..c8eb75dedd 100644
55--- a/Lib/ctypes/test/test_find.py
56+++ b/Lib/ctypes/test/test_find.py
57@@ -116,6 +116,7 @@ class FindLibraryLinux(unittest.TestCase):
58 with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
59 self.assertNotEqual(find_library('c'), None)
60
61+ @unittest.skipIf(True, "ldconfig is not used on Guix")
62 def test_find_library_with_ld(self):
63 with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
64 unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
65diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
66index 56285b5ff8..c088ab3db8 100644
67--- a/Lib/ctypes/test/test_libc.py
68+++ b/Lib/ctypes/test/test_libc.py
69@@ -2,6 +2,7 @@ import unittest
70
71 from ctypes import *
72 import _ctypes_test
73+import platform
74
75 lib = CDLL(_ctypes_test.__file__)
76
77@@ -17,6 +18,8 @@ class LibTest(unittest.TestCase):
78 import math
79 self.assertEqual(lib.my_sqrt(2.0), math.sqrt(2.0))
80
81+ @unittest.skipIf(platform.machine() in ['mips64'],
82+ "This test fails on this platform")
83 def test_qsort(self):
84 comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char))
85 lib.my_qsort.argtypes = c_void_p, c_size_t, c_size_t, comparefunc
86diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py
87index e9aad0e40f..8bbaa51ee5 100644
88--- a/Lib/distutils/tests/test_archive_util.py
89+++ b/Lib/distutils/tests/test_archive_util.py
90@@ -333,6 +333,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
91 self.assertEqual(os.path.basename(res), 'archive.tar.xz')
92 self.assertEqual(self._tarinfo(res), self._created_files)
93
94+ @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
95 def test_make_archive_owner_group(self):
96 # testing make_archive with owner and group, with various combinations
97 # this works even if there's not gid/uid support
98@@ -362,6 +363,7 @@ class ArchiveUtilTestCase(support.TempdirManager,
99
100 @unittest.skipUnless(ZLIB_SUPPORT, "Requires zlib")
101 @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
102+ @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
103 def test_tarfile_root_owner(self):
104 tmpdir = self._create_files()
105 base_name = os.path.join(self.mkdtemp(), 'archive')
106diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
107index 23db126959..6e2329df7d 100644
108--- a/Lib/distutils/tests/test_sdist.py
109+++ b/Lib/distutils/tests/test_sdist.py
110@@ -443,6 +443,7 @@ class SDistTestCase(BasePyPIRCCommandTestCase):
111 "The tar command is not found")
112 @unittest.skipIf(find_executable('gzip') is None,
113 "The gzip command is not found")
114+ @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
115 def test_make_distribution_owner_group(self):
116 # now building a sdist
117 dist, cmd = self.get_cmd()
118diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
119index e47905c863..31a5a9c308 100644
120--- a/Lib/test/_test_multiprocessing.py
121+++ b/Lib/test/_test_multiprocessing.py
122@@ -1577,6 +1577,7 @@ class _TestCondition(BaseTestCase):
123 if pid is not None:
124 os.kill(pid, signal.SIGINT)
125
126+ @unittest.skipIf(True, "This fails for unknown reasons on Guix")
127 def test_wait_result(self):
128 if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
129 pid = os.getpid()
130@@ -3905,6 +3906,7 @@ class _TestSharedMemory(BaseTestCase):
131 sms.close()
132
133 @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
134+ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
135 def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
136 # bpo-36368: protect SharedMemoryManager server process from
137 # KeyboardInterrupt signals.
138diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
139index 533d5cc7f5..c4f860cc3b 100644
140--- a/Lib/test/test_asyncio/test_base_events.py
141+++ b/Lib/test/test_asyncio/test_base_events.py
142@@ -1341,6 +1341,8 @@ class BaseEventLoopWithSelectorTests(test_utils.TestCase):
143 self._test_create_connection_ip_addr(m_socket, False)
144
145 @patch_socket
146+ @unittest.skipUnless(support.is_resource_enabled('network'),
147+ 'network is not enabled')
148 def test_create_connection_service_name(self, m_socket):
149 m_socket.getaddrinfo = socket.getaddrinfo
150 sock = m_socket.socket.return_value
151diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
152index 3bf1522808..04bac8a7db 100644
153--- a/Lib/test/test_generators.py
154+++ b/Lib/test/test_generators.py
155@@ -33,6 +33,7 @@ class SignalAndYieldFromTest(unittest.TestCase):
156 else:
157 return "FAILED"
158
159+ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment')
160 def test_raise_and_yield_from(self):
161 gen = self.generator1()
162 gen.send(None)
163diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
164index 3da35710b9..5404f9193d 100644
165--- a/Lib/test/test_pathlib.py
166+++ b/Lib/test/test_pathlib.py
167@@ -2408,10 +2408,7 @@ class PosixPathTest(_BasePathTest, unittest.TestCase):
168 self.assertEqual(given, expect)
169 self.assertEqual(set(p.rglob("FILEd*")), set())
170
171- @unittest.skipUnless(hasattr(pwd, 'getpwall'),
172- 'pwd module does not expose getpwall()')
173- @unittest.skipIf(sys.platform == "vxworks",
174- "no home directory on VxWorks")
175+ @unittest.skipIf(True, "Guix builder home is '/' which causes trouble for these tests")
176 def test_expanduser(self):
177 P = self.cls
178 support.import_module('pwd')
179diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
180index 8016f81e5a..10190486b4 100644
181--- a/Lib/test/test_pdb.py
182+++ b/Lib/test/test_pdb.py
183@@ -1219,11 +1219,11 @@ def test_pdb_issue_20766():
184 > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
185 -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
186 (Pdb) continue
187- pdb 1: <built-in function default_int_handler>
188+ pdb 1: 1
189 > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
190 -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
191 (Pdb) continue
192- pdb 2: <built-in function default_int_handler>
193+ pdb 2: 1
194 """
195
196
197diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
198index a77638b10a..2069b349a8 100644
199--- a/Lib/test/test_regrtest.py
200+++ b/Lib/test/test_regrtest.py
201@@ -811,6 +811,7 @@ class ArgsTestCase(BaseTestCase):
202 output = self.run_tests('--fromfile', filename)
203 self.check_executed_tests(output, tests)
204
205+ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
206 def test_interrupted(self):
207 code = TEST_INTERRUPTED
208 test = self.create_test('sigint', code=code)
209@@ -828,6 +829,7 @@ class ArgsTestCase(BaseTestCase):
210 % (self.TESTNAME_REGEX, len(tests)))
211 self.check_line(output, regex)
212
213+ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
214 def test_slowest_interrupted(self):
215 # Issue #25373: test --slowest with an interrupted test
216 code = TEST_INTERRUPTED
217diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
218index e5ece5284c..5299e54507 100644
219--- a/Lib/test/test_resource.py
220+++ b/Lib/test/test_resource.py
221@@ -148,6 +148,7 @@ class ResourceTest(unittest.TestCase):
222
223 @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
224 @support.requires_linux_version(2, 6, 36)
225+ @unittest.skipIf(True, "Bug: the PermissionError is not raised")
226 def test_prlimit(self):
227 self.assertRaises(TypeError, resource.prlimit)
228 self.assertRaises(ProcessLookupError, resource.prlimit,
229diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
230index e19af64be0..1b893df6fa 100644
231--- a/Lib/test/test_shutil.py
232+++ b/Lib/test/test_shutil.py
233@@ -1427,6 +1427,7 @@ class TestArchives(BaseTest, unittest.TestCase):
234 base_name = os.path.join(tmpdir, 'archive')
235 self.assertRaises(ValueError, make_archive, base_name, 'xxx')
236
237+ @unittest.skipIf(True, "The Guix build container has no root user")
238 @support.requires_zlib()
239 def test_make_archive_owner_group(self):
240 # testing make_archive with owner and group, with various combinations
241@@ -1455,6 +1456,7 @@ class TestArchives(BaseTest, unittest.TestCase):
242 self.assertTrue(os.path.isfile(res))
243
244
245+ @unittest.skipIf(True, "The Guix build container has no root user")
246 @support.requires_zlib()
247 @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
248 def test_tarfile_root_owner(self):
249diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
250index 45553a6a42..55623f01a3 100644
251--- a/Lib/test/test_signal.py
252+++ b/Lib/test/test_signal.py
253@@ -78,7 +78,8 @@ class PosixTests(unittest.TestCase):
254 self.assertLess(len(s), signal.NSIG)
255
256 @unittest.skipUnless(sys.executable, "sys.executable required.")
257 @support.requires_subprocess()
258+ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
259 def test_keyboard_interrupt_exit_code(self):
260 """KeyboardInterrupt triggers exit via SIGINT."""
261 process = subprocess.run(
262@@ -128,7 +129,8 @@ class WindowsSignalTests(unittest.TestCase):
263 signal.signal(7, handler)
264
265 @unittest.skipUnless(sys.executable, "sys.executable required.")
266 @support.requires_subprocess()
267+ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
268 def test_keyboard_interrupt_exit_code(self):
269 """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
270 # We don't test via os.kill(os.getpid(), signal.CTRL_C_EVENT) here
271@@ -1245,6 +1247,7 @@ class StressTest(unittest.TestCase):
272
273 class RaiseSignalTest(unittest.TestCase):
274
275+ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
276 def test_sigint(self):
277 with self.assertRaises(KeyboardInterrupt):
278 signal.raise_signal(signal.SIGINT)
279@@ -1275,6 +1278,7 @@ class RaiseSignalTest(unittest.TestCase):
280
281 class PidfdSignalTest(unittest.TestCase):
282
283+ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
284 @unittest.skipUnless(
285 hasattr(signal, "pidfd_send_signal"),
286 "pidfd support not built in",
287diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
288index aefba4f397..6c89f558d5 100755
289--- a/Lib/test/test_socket.py
290+++ b/Lib/test/test_socket.py
291@@ -1009,6 +1009,8 @@ class GeneralModuleTests(unittest.TestCase):
292 if not fqhn in all_host_names:
293 self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
294
295+ @unittest.skipUnless(support.is_resource_enabled('network'),
296+ 'network is not enabled')
297 def test_host_resolution(self):
298 for addr in [socket_helper.HOSTv4, '10.0.0.1', '255.255.255.255']:
299 self.assertEqual(socket.gethostbyname(addr), addr)
300@@ -1140,6 +1142,8 @@ class GeneralModuleTests(unittest.TestCase):
301 self.assertWarns(DeprecationWarning, socket.ntohs, k)
302 self.assertWarns(DeprecationWarning, socket.htons, k)
303
304+ @unittest.skipUnless(os.path.exists("/etc/services"),
305+ "getservbyname uses /etc/services, which is not in the chroot")
306 def testGetServBy(self):
307 eq = self.assertEqual
308 # Find one service that exists, then check all the related interfaces.
309@@ -1489,6 +1493,8 @@ class GeneralModuleTests(unittest.TestCase):
310 raise
311 self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)
312
313+ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
314+ "getaddrinfo() will fail")
315 def testGetaddrinfo(self):
316 try:
317 socket.getaddrinfo('localhost', 80)
318@@ -1571,6 +1577,8 @@ class GeneralModuleTests(unittest.TestCase):
319 # only IP addresses are allowed
320 self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)
321
322+ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
323+ "getaddrinfo() will fail")
324 @unittest.skipUnless(support.is_resource_enabled('network'),
325 'network is not enabled')
326 def test_idna(self):
327diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
328index 07793c84c8..fec672bcbe 100644
329--- a/Lib/test/test_spwd.py
330+++ b/Lib/test/test_spwd.py
331@@ -5,8 +5,7 @@ from test import support
332 spwd = support.import_module('spwd')
333
334
335-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
336- 'root privileges required')
337+@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
338 class TestSpwdRoot(unittest.TestCase):
339
340 def test_getspall(self):
341@@ -56,8 +55,7 @@ class TestSpwdRoot(unittest.TestCase):
342 self.assertRaises(TypeError, spwd.getspnam, bytes_name)
343
344
345-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
346- 'non-root user required')
347+@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
348 class TestSpwdNonRoot(unittest.TestCase):
349
350 def test_getspnam_exception(self):
351diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
352index 29cde91bf7..8d0f20e8bf 100644
353--- a/Lib/test/test_tarfile.py
354+++ b/Lib/test/test_tarfile.py
355@@ -2607,9 +2607,12 @@ def root_is_uid_gid_0():
356 import pwd, grp
357 except ImportError:
358 return False
359- if pwd.getpwuid(0)[0] != 'root':
360- return False
361- if grp.getgrgid(0)[0] != 'root':
362+ try:
363+ if pwd.getpwuid(0)[0] != 'root':
364+ return False
365+ if grp.getgrgid(0)[0] != 'root':
366+ return False
367+ except KeyError:
368 return False
369 return True
370
371diff --git a/Lib/test/test_tools/test_freeze.py b/Lib/test/test_tools/test_freeze.py
372index 0e7ed67de7..6539a2983b 100644
373--- a/Lib/test/test_tools/test_freeze.py
374+++ b/Lib/test/test_tools/test_freeze.py
375@@ -23,6 +23,7 @@
376 'test is too slow with PGO')
377 class TestFreeze(unittest.TestCase):
378
379+ @unittest.skipIf(True, 'Fails on Guix.')
380 @support.requires_resource('cpu') # Building Python is slow
381 def test_freeze_simple_script(self):
382 script = textwrap.dedent("""
383diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
384index c21cdf8eb7..6c9d575032 100644
385--- a/Lib/test/test_threading.py
386+++ b/Lib/test/test_threading.py
387@@ -1398,5 +1398,6 @@ class MiscTestCase(unittest.TestCase):
388 signal.signal(signum, handler)
389
390+ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
391 def test_interrupt_main_subthread(self):
392 # Calling start_new_thread with a function that executes interrupt_main
393 # should raise KeyboardInterrupt upon completion.
394@@ -1409,6 +1410,8 @@ class InterruptMainTests(unittest.TestCase):
395 t.join()
396 t.join()
397
398+
399+ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
400 def test_interrupt_main_mainthread(self):
401 # Make sure that if interrupt_main is called in main thread that
402 # KeyboardInterrupt is raised instantly.
403diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
404index b552d2bd17..28b1144e15 100644
405--- a/Lib/test/test_unicodedata.py
406+++ b/Lib/test/test_unicodedata.py
407@@ -309,6 +309,7 @@ class UnicodeMiscTest(UnicodeDatabaseTest):
408 self.assertEqual(len(lines), 1,
409 r"\u%.4x should not be a linebreak" % i)
410
411+@requires_resource('network')
412 class NormalizationTest(unittest.TestCase):
413 @staticmethod
414 def check_version(testfile):
415diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
416index bcfa5e943b..1f2484971b 100644
417--- a/Tools/scripts/run_tests.py
418+++ b/Tools/scripts/run_tests.py
419@@ -41,7 +41,7 @@ def main(regrtest_args):
420 else:
421 args.extend(['-j', '0']) # Use all CPU cores
422 if not any(is_resource_use_flag(arg) for arg in regrtest_args):
423- args.extend(['-u', 'all,-largefile,-audio,-gui'])
424+ args.extend(['-u', 'all,-largefile,-audio,-gui,-network'])
425
426 if cross_compile and hostrunner:
427 # If HOSTRUNNER is set and -p/--python option is not given, then
428--
4292.29.2
430