Skip to content

Commit 43634fc

Browse files
authored
gh-127146: Emscripten: Skip segfaults in test suite (#127151)
Added skips for tests known to cause problems when running on Emscripten. These mostly relate to the limited stack depth on Emscripten.
1 parent 2f1cee8 commit 43634fc

21 files changed

+46
-8
lines changed

Lib/test/list_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from functools import cmp_to_key
77

88
from test import seq_tests
9-
from test.support import ALWAYS_EQ, NEVER_EQ, get_c_recursion_limit
9+
from test.support import ALWAYS_EQ, NEVER_EQ, get_c_recursion_limit, skip_emscripten_stack_overflow
1010

1111

1212
class CommonTest(seq_tests.CommonTest):
@@ -59,6 +59,7 @@ def test_repr(self):
5959
self.assertEqual(str(a2), "[0, 1, 2, [...], 3]")
6060
self.assertEqual(repr(a2), "[0, 1, 2, [...], 3]")
6161

62+
@skip_emscripten_stack_overflow()
6263
def test_repr_deep(self):
6364
a = self.type2test([])
6465
for i in range(get_c_recursion_limit() + 1):

Lib/test/mapping_tests.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# tests common to dict and UserDict
22
import unittest
33
import collections
4-
from test.support import get_c_recursion_limit
4+
from test.support import get_c_recursion_limit, skip_emscripten_stack_overflow
55

66

77
class BasicTestMappingProtocol(unittest.TestCase):
@@ -622,6 +622,7 @@ def __repr__(self):
622622
d = self._full_mapping({1: BadRepr()})
623623
self.assertRaises(Exc, repr, d)
624624

625+
@skip_emscripten_stack_overflow()
625626
def test_repr_deep(self):
626627
d = self._empty_mapping()
627628
for i in range(get_c_recursion_limit() + 1):

Lib/test/support/__init__.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,9 @@ def skip_android_selinux(name):
535535
is_emscripten = sys.platform == "emscripten"
536536
is_wasi = sys.platform == "wasi"
537537

538+
def skip_emscripten_stack_overflow():
539+
return unittest.skipIf(is_emscripten, "Exhausts limited stack on Emscripten")
540+
538541
is_apple_mobile = sys.platform in {"ios", "tvos", "watchos"}
539542
is_apple = is_apple_mobile or sys.platform == "darwin"
540543

Lib/test/test_ast/test_ast.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
_testinternalcapi = None
1919

2020
from test import support
21-
from test.support import os_helper, script_helper
21+
from test.support import os_helper, script_helper, skip_emscripten_stack_overflow
2222
from test.support.ast_helper import ASTTestMixin
2323
from test.test_ast.utils import to_tuple
2424
from test.test_ast.snippets import (
@@ -745,6 +745,7 @@ def next(self):
745745
enum._test_simple_enum(_Precedence, ast._Precedence)
746746

747747
@support.cpython_only
748+
@skip_emscripten_stack_overflow()
748749
def test_ast_recursion_limit(self):
749750
fail_depth = support.exceeds_recursion_limit()
750751
crash_depth = 100_000
@@ -1661,13 +1662,15 @@ def test_level_as_none(self):
16611662
exec(code, ns)
16621663
self.assertIn('sleep', ns)
16631664

1665+
@skip_emscripten_stack_overflow()
16641666
def test_recursion_direct(self):
16651667
e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0, operand=ast.Constant(1))
16661668
e.operand = e
16671669
with self.assertRaises(RecursionError):
16681670
with support.infinite_recursion():
16691671
compile(ast.Expression(e), "<test>", "eval")
16701672

1673+
@skip_emscripten_stack_overflow()
16711674
def test_recursion_indirect(self):
16721675
e = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0, operand=ast.Constant(1))
16731676
f = ast.UnaryOp(op=ast.Not(), lineno=0, col_offset=0, operand=ast.Constant(1))

Lib/test/test_call.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import unittest
22
from test.support import (cpython_only, is_wasi, requires_limited_api, Py_DEBUG,
3-
set_recursion_limit, skip_on_s390x)
3+
set_recursion_limit, skip_on_s390x, skip_emscripten_stack_overflow)
44
try:
55
import _testcapi
66
except ImportError:
@@ -1038,6 +1038,7 @@ class TestRecursion(unittest.TestCase):
10381038
@skip_on_s390x
10391039
@unittest.skipIf(is_wasi and Py_DEBUG, "requires deep stack")
10401040
@unittest.skipIf(_testcapi is None, "requires _testcapi")
1041+
@skip_emscripten_stack_overflow()
10411042
def test_super_deep(self):
10421043

10431044
def recurse(n):

Lib/test/test_capi/test_misc.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2137,6 +2137,7 @@ def test_py_config_isoloated_per_interpreter(self):
21372137
# test fails, assume that the environment in this process may
21382138
# be altered and suspect.
21392139

2140+
@requires_subinterpreters
21402141
@unittest.skipUnless(hasattr(os, "pipe"), "requires os.pipe()")
21412142
def test_configured_settings(self):
21422143
"""

Lib/test/test_class.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
"Test the functionality of Python classes implementing operators."
22

33
import unittest
4-
from test.support import cpython_only, import_helper, script_helper
4+
from test.support import cpython_only, import_helper, script_helper, skip_emscripten_stack_overflow
55

66
testmeths = [
77

@@ -554,6 +554,7 @@ class Custom:
554554
self.assertFalse(hasattr(o, "__call__"))
555555
self.assertFalse(hasattr(c, "__call__"))
556556

557+
@skip_emscripten_stack_overflow()
557558
def testSFBug532646(self):
558559
# Test for SF bug 532646
559560

Lib/test/test_compile.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,7 @@ def __getitem__(self, key):
121121
self.assertEqual(d['z'], 12)
122122

123123
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
124+
@support.skip_emscripten_stack_overflow()
124125
def test_extended_arg(self):
125126
repeat = int(get_c_recursion_limit() * 0.9)
126127
longexpr = 'x = x or ' + '-x' * repeat
@@ -709,6 +710,7 @@ def test_yet_more_evil_still_undecodable(self):
709710

710711
@support.cpython_only
711712
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
713+
@support.skip_emscripten_stack_overflow()
712714
def test_compiler_recursion_limit(self):
713715
# Expected limit is Py_C_RECURSION_LIMIT
714716
limit = get_c_recursion_limit()

Lib/test/test_copy.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,7 @@ def test_deepcopy_list(self):
371371
self.assertIsNot(x, y)
372372
self.assertIsNot(x[0], y[0])
373373

374+
@support.skip_emscripten_stack_overflow()
374375
def test_deepcopy_reflexive_list(self):
375376
x = []
376377
x.append(x)
@@ -398,6 +399,7 @@ def test_deepcopy_tuple_of_immutables(self):
398399
y = copy.deepcopy(x)
399400
self.assertIs(x, y)
400401

402+
@support.skip_emscripten_stack_overflow()
401403
def test_deepcopy_reflexive_tuple(self):
402404
x = ([],)
403405
x[0].append(x)
@@ -415,6 +417,7 @@ def test_deepcopy_dict(self):
415417
self.assertIsNot(x, y)
416418
self.assertIsNot(x["foo"], y["foo"])
417419

420+
@support.skip_emscripten_stack_overflow()
418421
def test_deepcopy_reflexive_dict(self):
419422
x = {}
420423
x['foo'] = x

Lib/test/test_descr.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3663,6 +3663,7 @@ def f(a): return a
36633663
encoding='latin1', errors='replace')
36643664
self.assertEqual(ba, b'abc\xbd?')
36653665

3666+
@support.skip_emscripten_stack_overflow()
36663667
def test_recursive_call(self):
36673668
# Testing recursive __call__() by setting to instance of class...
36683669
class A(object):
@@ -3942,6 +3943,7 @@ def __del__(self):
39423943
# it as a leak.
39433944
del C.__del__
39443945

3946+
@unittest.skipIf(support.is_emscripten, "Seems to works in Pyodide?")
39453947
def test_slots_trash(self):
39463948
# Testing slot trash...
39473949
# Deallocating deeply nested slotted trash caused stack overflows
@@ -4864,6 +4866,7 @@ class Thing:
48644866
# CALL_METHOD_DESCRIPTOR_O
48654867
deque.append(thing, thing)
48664868

4869+
@support.skip_emscripten_stack_overflow()
48674870
def test_repr_as_str(self):
48684871
# Issue #11603: crash or infinite loop when rebinding __str__ as
48694872
# __repr__.

0 commit comments

Comments
 (0)