gh-116303: Skip tests if C recursion limit is unavailable (GH-117368)

The test suite fetches the C recursion limit from the _testcapi
extension module. Test extension modules can be disabled using the
--disable-test-modules configure option.
This commit is contained in:
Erlend E. Aasland 2024-04-08 14:45:25 +02:00 committed by GitHub
parent 9a12f5d1c1
commit ca62ffd1a5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
14 changed files with 32 additions and 35 deletions

View file

@ -13,7 +13,7 @@ import textwrap
import warnings
from test import support
from test.support import (script_helper, requires_debug_ranges,
requires_specialization, Py_C_RECURSION_LIMIT)
requires_specialization, get_c_recursion_limit)
from test.support.bytecode_helper import instructions_with_positions
from test.support.os_helper import FakePath
@ -114,7 +114,7 @@ class TestSpecifics(unittest.TestCase):
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
def test_extended_arg(self):
repeat = int(Py_C_RECURSION_LIMIT * 0.9)
repeat = int(get_c_recursion_limit() * 0.9)
longexpr = 'x = x or ' + '-x' * repeat
g = {}
code = textwrap.dedent('''
@ -634,9 +634,10 @@ class TestSpecifics(unittest.TestCase):
@unittest.skipIf(support.is_wasi, "exhausts limited stack on WASI")
def test_compiler_recursion_limit(self):
# Expected limit is Py_C_RECURSION_LIMIT
fail_depth = Py_C_RECURSION_LIMIT + 1
crash_depth = Py_C_RECURSION_LIMIT * 100
success_depth = int(Py_C_RECURSION_LIMIT * 0.8)
limit = get_c_recursion_limit()
fail_depth = limit + 1
crash_depth = limit * 100
success_depth = int(limit * 0.8)
def check_limit(prefix, repeated, mode="single"):
expect_ok = prefix + repeated * success_depth