projects/guix·blob java-team · refs

388 lines · 16.6 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
10diff --git a/Lib/ctypes/test/test_callbacks.py b/Lib/ctypes/test/test_callbacks.py
11index d8e9c5a760..94fc5929c9 100644
12--- a/Lib/ctypes/test/test_callbacks.py
13+++ b/Lib/ctypes/test/test_callbacks.py
14@@ -5,6 +5,7 @@
15 from ctypes import *
16 from ctypes.test import need_symbol
17 import _ctypes_test
18+import platform
19
20 class Callbacks(unittest.TestCase):
21 functype = CFUNCTYPE
22@@ -178,6 +179,8 @@ def func(x):
23
24 self.assertLess(diff, 0.01, "%s not less than 0.01" % diff)
25
26+ @unittest.skipIf(platform.machine() in ['mips64'],
27+ "This test fails on this platform")
28 def test_issue_8959_a(self):
29 from ctypes.util import find_library
30 libc_path = find_library("c")
31diff --git a/Lib/ctypes/test/test_find.py b/Lib/ctypes/test/test_find.py
32index 1ff9d019b1..5194954914 100644
33--- a/Lib/ctypes/test/test_find.py
34+++ b/Lib/ctypes/test/test_find.py
35@@ -117,6 +117,7 @@ def test_find_library_with_gcc(self):
36 with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None):
37 self.assertNotEqual(find_library('c'), None)
38
39+ @unittest.skipIf(True, "ldconfig is not used on Guix")
40 def test_find_library_with_ld(self):
41 with unittest.mock.patch("ctypes.util._findSoname_ldconfig", lambda *args: None), \
42 unittest.mock.patch("ctypes.util._findLib_gcc", lambda *args: None):
43diff --git a/Lib/ctypes/test/test_libc.py b/Lib/ctypes/test/test_libc.py
44index 56285b5ff8..c088ab3db8 100644
45--- a/Lib/ctypes/test/test_libc.py
46+++ b/Lib/ctypes/test/test_libc.py
47@@ -2,6 +2,7 @@
48
49 from ctypes import *
50 import _ctypes_test
51+import platform
52
53 lib = CDLL(_ctypes_test.__file__)
54
55@@ -17,6 +18,8 @@ def test_sqrt(self):
56 import math
57 self.assertEqual(lib.my_sqrt(2.0), math.sqrt(2.0))
58
59+ @unittest.skipIf(platform.machine() in ['mips64'],
60+ "This test fails on this platform")
61 def test_qsort(self):
62 comparefunc = CFUNCTYPE(c_int, POINTER(c_char), POINTER(c_char))
63 lib.my_qsort.argtypes = c_void_p, c_size_t, c_size_t, comparefunc
64diff --git a/Lib/distutils/tests/test_archive_util.py b/Lib/distutils/tests/test_archive_util.py
65index edcec2513e..a716150763 100644
66--- a/Lib/distutils/tests/test_archive_util.py
67+++ b/Lib/distutils/tests/test_archive_util.py
68@@ -335,6 +335,7 @@ def test_make_archive_xztar(self):
69 self.assertEqual(os.path.basename(res), 'archive.tar.xz')
70 self.assertEqual(self._tarinfo(res), self._created_files)
71
72+ @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
73 def test_make_archive_owner_group(self):
74 # testing make_archive with owner and group, with various combinations
75 # this works even if there's not gid/uid support
76@@ -364,6 +365,7 @@ def test_make_archive_owner_group(self):
77
78 @unittest.skipUnless(ZLIB_SUPPORT, "Requires zlib")
79 @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
80+ @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
81 def test_tarfile_root_owner(self):
82 tmpdir = self._create_files()
83 base_name = os.path.join(self.mkdtemp(), 'archive')
84diff --git a/Lib/distutils/tests/test_sdist.py b/Lib/distutils/tests/test_sdist.py
85index 752e9db5ba..c66b6323e4 100644
86--- a/Lib/distutils/tests/test_sdist.py
87+++ b/Lib/distutils/tests/test_sdist.py
88@@ -444,6 +444,7 @@ def test_manual_manifest(self):
89 "The tar command is not found")
90 @unittest.skipIf(find_executable('gzip') is None,
91 "The gzip command is not found")
92+ @unittest.skipIf(True, "getgrgid(0)[0] raises a KeyError on Guix")
93 def test_make_distribution_owner_group(self):
94 # now building a sdist
95 dist, cmd = self.get_cmd()
96diff --git a/Lib/test/_test_multiprocessing.py b/Lib/test/_test_multiprocessing.py
97index 8dced90c53..59947e3023 100644
98--- a/Lib/test/_test_multiprocessing.py
99+++ b/Lib/test/_test_multiprocessing.py
100@@ -1589,6 +1589,7 @@ def _test_wait_result(cls, c, pid):
101 if pid is not None:
102 os.kill(pid, signal.SIGINT)
103
104+ @unittest.skipIf(True, "This fails for unknown reasons on Guix")
105 def test_wait_result(self):
106 if isinstance(self, ProcessesMixin) and sys.platform != 'win32':
107 pid = os.getpid()
108@@ -4008,6 +4009,7 @@ def test_shared_memory_across_processes(self):
109 sms.close()
110
111 @unittest.skipIf(os.name != "posix", "not feasible in non-posix platforms")
112+ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
113 def test_shared_memory_SharedMemoryServer_ignores_sigint(self):
114 # bpo-36368: protect SharedMemoryManager server process from
115 # KeyboardInterrupt signals.
116diff --git a/Lib/test/test_asyncio/test_base_events.py b/Lib/test/test_asyncio/test_base_events.py
117index d77bf95a7b..79912c8230 100644
118--- a/Lib/test/test_asyncio/test_base_events.py
119+++ b/Lib/test/test_asyncio/test_base_events.py
120@@ -1359,6 +1359,8 @@ def test_create_connection_no_inet_pton(self, m_socket):
121 self._test_create_connection_ip_addr(m_socket, False)
122
123 @patch_socket
124+ @unittest.skipUnless(support.is_resource_enabled('network'),
125+ 'network is not enabled')
126 def test_create_connection_service_name(self, m_socket):
127 m_socket.getaddrinfo = socket.getaddrinfo
128 sock = m_socket.socket.return_value
129diff --git a/Lib/test/test_generators.py b/Lib/test/test_generators.py
130index 3bf5f3b743..23368c8d8b 100644
131--- a/Lib/test/test_generators.py
132+++ b/Lib/test/test_generators.py
133@@ -33,6 +33,7 @@ def generator2(self):
134 else:
135 return "FAILED"
136
137+ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment')
138 def test_raise_and_yield_from(self):
139 gen = self.generator1()
140 gen.send(None)
141diff --git a/Lib/test/test_pathlib.py b/Lib/test/test_pathlib.py
142index bf3fc5fb24..21015403f3 100644
143--- a/Lib/test/test_pathlib.py
144+++ b/Lib/test/test_pathlib.py
145@@ -2546,6 +2546,7 @@ def test_rglob(self):
146 'pwd module does not expose getpwall()')
147 @unittest.skipIf(sys.platform == "vxworks",
148 "no home directory on VxWorks")
149+ @unittest.skipIf(True, "Guix builder home is '/' which causes trouble for these tests")
150 def test_expanduser(self):
151 P = self.cls
152 import_helper.import_module('pwd')
153diff --git a/Lib/test/test_pdb.py b/Lib/test/test_pdb.py
154index 6ac1a4a3c3..4f58cf9b40 100644
155--- a/Lib/test/test_pdb.py
156+++ b/Lib/test/test_pdb.py
157@@ -1315,11 +1315,11 @@ def test_pdb_issue_20766():
158 > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
159 -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
160 (Pdb) continue
161- pdb 1: <built-in function default_int_handler>
162+ pdb 1: Handlers.SIG_IGN
163 > <doctest test.test_pdb.test_pdb_issue_20766[0]>(6)test_function()
164 -> print('pdb %d: %s' % (i, sess._previous_sigint_handler))
165 (Pdb) continue
166- pdb 2: <built-in function default_int_handler>
167+ pdb 2: Handlers.SIG_IGN
168 """
169
170 def test_pdb_issue_43318():
171diff --git a/Lib/test/test_regrtest.py b/Lib/test/test_regrtest.py
172index 62e6c28280..7ffee56635 100644
173--- a/Lib/test/test_regrtest.py
174+++ b/Lib/test/test_regrtest.py
175@@ -810,6 +810,7 @@ def test_fromfile(self):
176 output = self.run_tests('--fromfile', filename)
177 self.check_executed_tests(output, tests)
178
179+ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
180 def test_interrupted(self):
181 code = TEST_INTERRUPTED
182 test = self.create_test('sigint', code=code)
183@@ -827,6 +828,7 @@ def test_slowest(self):
184 % (self.TESTNAME_REGEX, len(tests)))
185 self.check_line(output, regex)
186
187+ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build environment.')
188 def test_slowest_interrupted(self):
189 # Issue #25373: test --slowest with an interrupted test
190 code = TEST_INTERRUPTED
191diff --git a/Lib/test/test_resource.py b/Lib/test/test_resource.py
192index f2642c6ba1..4358a20dae 100644
193--- a/Lib/test/test_resource.py
194+++ b/Lib/test/test_resource.py
195@@ -150,6 +150,7 @@ def test_freebsd_contants(self):
196
197 @unittest.skipUnless(hasattr(resource, 'prlimit'), 'no prlimit')
198 @support.requires_linux_version(2, 6, 36)
199+ @unittest.skipIf(True, "Bug: the PermissionError is not raised")
200 def test_prlimit(self):
201 self.assertRaises(TypeError, resource.prlimit)
202 self.assertRaises(ProcessLookupError, resource.prlimit,
203diff --git a/Lib/test/test_shutil.py b/Lib/test/test_shutil.py
204index 62e9180375..3eda176fa3 100644
205--- a/Lib/test/test_shutil.py
206+++ b/Lib/test/test_shutil.py
207@@ -1497,6 +1497,7 @@ def test_make_archive(self):
208 base_name = os.path.join(tmpdir, 'archive')
209 self.assertRaises(ValueError, make_archive, base_name, 'xxx')
210
211+ @unittest.skipIf(True, "The Guix build container has no root user")
212 @support.requires_zlib()
213 def test_make_archive_owner_group(self):
214 # testing make_archive with owner and group, with various combinations
215@@ -1525,6 +1526,7 @@ def test_make_archive_owner_group(self):
216 self.assertTrue(os.path.isfile(res))
217
218
219+ @unittest.skipIf(True, "The Guix build container has no root user")
220 @support.requires_zlib()
221 @unittest.skipUnless(UID_GID_SUPPORT, "Requires grp and pwd support")
222 def test_tarfile_root_owner(self):
223diff --git a/Lib/test/test_signal.py b/Lib/test/test_signal.py
224index c2b5861fc3..3c7a9c42cb 100644
225--- a/Lib/test/test_signal.py
226+++ b/Lib/test/test_signal.py
227@@ -89,6 +89,7 @@ def test_valid_signals(self):
228 self.assertLess(len(s), signal.NSIG)
229
230 @unittest.skipUnless(sys.executable, "sys.executable required.")
231+ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
232 def test_keyboard_interrupt_exit_code(self):
233 """KeyboardInterrupt triggers exit via SIGINT."""
234 process = subprocess.run(
235@@ -139,6 +140,7 @@ def test_issue9324(self):
236 signal.signal(7, handler)
237
238 @unittest.skipUnless(sys.executable, "sys.executable required.")
239+ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
240 def test_keyboard_interrupt_exit_code(self):
241 """KeyboardInterrupt triggers an exit using STATUS_CONTROL_C_EXIT."""
242 # We don't test via os.kill(os.getpid(), signal.CTRL_C_EVENT) here
243@@ -1322,6 +1324,7 @@ def cycle_handlers():
244
245 class RaiseSignalTest(unittest.TestCase):
246
247+ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
248 def test_sigint(self):
249 with self.assertRaises(KeyboardInterrupt):
250 signal.raise_signal(signal.SIGINT)
251@@ -1352,6 +1355,7 @@ def handler(a, b):
252
253 class PidfdSignalTest(unittest.TestCase):
254
255+ @unittest.skipUnless(sys.stdin.isatty(), "KeyboardInterrupts require a TTY device")
256 @unittest.skipUnless(
257 hasattr(signal, "pidfd_send_signal"),
258 "pidfd support not built in",
259diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py
260index 9c5f6d3dc9..ef74fc5694 100644
261--- a/Lib/test/test_socket.py
262+++ b/Lib/test/test_socket.py
263@@ -1006,6 +1006,8 @@ def testHostnameRes(self):
264 if not fqhn in all_host_names:
265 self.fail("Error testing host resolution mechanisms. (fqdn: %s, all: %s)" % (fqhn, repr(all_host_names)))
266
267+ @unittest.skipUnless(support.is_resource_enabled('network'),
268+ 'network is not enabled')
269 def test_host_resolution(self):
270 for addr in [socket_helper.HOSTv4, '10.0.0.1', '255.255.255.255']:
271 self.assertEqual(socket.gethostbyname(addr), addr)
272@@ -1136,6 +1138,8 @@ def testNtoHErrors(self):
273 self.assertRaises(OverflowError, socket.ntohl, k)
274 self.assertRaises(OverflowError, socket.htonl, k)
275
276+ @unittest.skipUnless(os.path.exists("/etc/services"),
277+ "getservbyname uses /etc/services, which is not in the chroot")
278 def testGetServBy(self):
279 eq = self.assertEqual
280 # Find one service that exists, then check all the related interfaces.
281@@ -1485,6 +1489,8 @@ def test_sio_loopback_fast_path(self):
282 raise
283 self.assertRaises(TypeError, s.ioctl, socket.SIO_LOOPBACK_FAST_PATH, None)
284
285+ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
286+ "getaddrinfo() will fail")
287 def testGetaddrinfo(self):
288 try:
289 socket.getaddrinfo('localhost', 80)
290@@ -1567,6 +1573,8 @@ def test_getnameinfo(self):
291 # only IP addresses are allowed
292 self.assertRaises(OSError, socket.getnameinfo, ('mail.python.org',0), 0)
293
294+ @unittest.skipUnless(os.path.exists("/etc/gai.conf"),
295+ "getaddrinfo() will fail")
296 @unittest.skipUnless(support.is_resource_enabled('network'),
297 'network is not enabled')
298 def test_idna(self):
299diff --git a/Lib/test/test_spwd.py b/Lib/test/test_spwd.py
300index a143acc659..f7207887c0 100644
301--- a/Lib/test/test_spwd.py
302+++ b/Lib/test/test_spwd.py
303@@ -6,8 +6,7 @@
304 spwd = import_helper.import_module('spwd')
305
306
307-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() == 0,
308- 'root privileges required')
309+@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
310 class TestSpwdRoot(unittest.TestCase):
311
312 def test_getspall(self):
313@@ -57,8 +56,7 @@ def test_getspnam(self):
314 self.assertRaises(TypeError, spwd.getspnam, bytes_name)
315
316
317-@unittest.skipUnless(hasattr(os, 'geteuid') and os.geteuid() != 0,
318- 'non-root user required')
319+@unittest.skipUnless(os.path.exists("/etc/shadow"), 'spwd tests require /etc/shadow')
320 class TestSpwdNonRoot(unittest.TestCase):
321
322 def test_getspnam_exception(self):
323diff --git a/Lib/test/test_tarfile.py b/Lib/test/test_tarfile.py
324index c658cca7a7..b7188e411e 100644
325--- a/Lib/test/test_tarfile.py
326+++ b/Lib/test/test_tarfile.py
327@@ -2737,9 +2737,12 @@ def root_is_uid_gid_0():
328 import pwd, grp
329 except ImportError:
330 return False
331- if pwd.getpwuid(0)[0] != 'root':
332- return False
333- if grp.getgrgid(0)[0] != 'root':
334+ try:
335+ if pwd.getpwuid(0)[0] != 'root':
336+ return False
337+ if grp.getgrgid(0)[0] != 'root':
338+ return False
339+ except KeyError:
340 return False
341 return True
342
343diff --git a/Lib/test/test_threading.py b/Lib/test/test_threading.py
344index c54806e594..d9bbca4e6a 100644
345--- a/Lib/test/test_threading.py
346+++ b/Lib/test/test_threading.py
347@@ -1620,6 +1620,7 @@ def check_interrupt_main_noerror(self, signum):
348 # Restore original handler
349 signal.signal(signum, handler)
350
351+ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
352 def test_interrupt_main_subthread(self):
353 # Calling start_new_thread with a function that executes interrupt_main
354 # should raise KeyboardInterrupt upon completion.
355@@ -1631,6 +1632,8 @@ def call_interrupt():
356 t.join()
357 t.join()
358
359+
360+ @unittest.skipIf(True, 'Keyboard interrupts do not work in the Guix build container.')
361 def test_interrupt_main_mainthread(self):
362 # Make sure that if interrupt_main is called in main thread that
363 # KeyboardInterrupt is raised instantly.
364diff --git a/Lib/test/test_unicodedata.py b/Lib/test/test_unicodedata.py
365index 213b3cf252..a5edd4a119 100644
366--- a/Lib/test/test_unicodedata.py
367+++ b/Lib/test/test_unicodedata.py
368@@ -315,6 +315,7 @@ def test_linebreak_7643(self):
369 self.assertEqual(len(lines), 1,
370 r"\u%.4x should not be a linebreak" % i)
371
372+@requires_resource('network')
373 class NormalizationTest(unittest.TestCase):
374 @staticmethod
375 def check_version(testfile):
376diff --git a/Tools/scripts/run_tests.py b/Tools/scripts/run_tests.py
377index 48feb3f778..e82cafc88a 100644
378--- a/Tools/scripts/run_tests.py
379+++ b/Tools/scripts/run_tests.py
380@@ -40,7 +40,7 @@ def main(regrtest_args):
381 if not any(is_multiprocess_flag(arg) for arg in regrtest_args):
382 args.extend(['-j', '0']) # Use all CPU cores
383 if not any(is_resource_use_flag(arg) for arg in regrtest_args):
384- args.extend(['-u', 'all,-largefile,-audio,-gui'])
385+ args.extend(['-u', 'all,-largefile,-audio,-gui,-network'])
386 args.extend(regrtest_args)
387 print(' '.join(args))
388 if sys.platform == 'win32':