Skip to content

Commit 1d82a41

Browse files
authored
gh-116869: Enable test_cext and test_cppext on Free Threading build (#116973)
Remove the "if Py_GIL_DISABLED" skip and move all "skip" decorators to the class. Use support.check_sanitizer()
1 parent dc2d0f4 commit 1d82a41

File tree

2 files changed

+19
-32
lines changed

2 files changed

+19
-32
lines changed

Lib/test/test_cext/__init__.py

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44
import os.path
55
import shutil
66
import subprocess
7-
import sysconfig
87
import unittest
98
from test import support
109

@@ -13,10 +12,15 @@
1312
SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
1413

1514

16-
# gh-110119: pip does not currently support 't' in the ABI flag use by
17-
# --disable-gil builds. Once it does, we can remove this skip.
18-
@unittest.skipIf(support.Py_GIL_DISABLED,
19-
'test does not work with --disable-gil')
15+
# With MSVC, the linker fails with: cannot open file 'python311.lib'
16+
# https://github.com/python/cpython/pull/32175#issuecomment-1111175897
17+
@unittest.skipIf(support.MS_WINDOWS, 'test fails on Windows')
18+
# Building and running an extension in clang sanitizing mode is not
19+
# straightforward
20+
@support.skip_if_sanitizer('test does not work with analyzing builds',
21+
address=True, memory=True, ub=True, thread=True)
22+
# the test uses venv+pip: skip if it's not available
23+
@support.requires_venv_with_pip()
2024
@support.requires_subprocess()
2125
@support.requires_resource('cpu')
2226
class TestExt(unittest.TestCase):
@@ -26,16 +30,6 @@ def test_build_c99(self):
2630
def test_build_c11(self):
2731
self.check_build('c11', '_test_c11_ext')
2832

29-
# With MSVC, the linker fails with: cannot open file 'python311.lib'
30-
# https://github.com/python/cpython/pull/32175#issuecomment-1111175897
31-
@unittest.skipIf(support.MS_WINDOWS, 'test fails on Windows')
32-
# Building and running an extension in clang sanitizing mode is not
33-
# straightforward
34-
@unittest.skipIf(
35-
'-fsanitize' in (sysconfig.get_config_var('PY_CFLAGS') or ''),
36-
'test does not work with analyzing builds')
37-
# the test uses venv+pip: skip if it's not available
38-
@support.requires_venv_with_pip()
3933
def check_build(self, clang_std, extension_name):
4034
venv_dir = 'env'
4135
with support.setup_venv_with_pip_setuptools_wheel(venv_dir) as python_exe:

Lib/test/test_cppext/__init__.py

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -4,38 +4,31 @@
44
import shutil
55
import unittest
66
import subprocess
7-
import sysconfig
87
from test import support
98

109

1110
SOURCE = os.path.join(os.path.dirname(__file__), 'extension.cpp')
1211
SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
1312

1413

15-
# gh-110119: pip does not currently support 't' in the ABI flag use by
16-
# --disable-gil builds. Once it does, we can remove this skip.
17-
@unittest.skipIf(support.Py_GIL_DISABLED,
18-
'test does not work with --disable-gil')
14+
# With MSVC, the linker fails with: cannot open file 'python311.lib'
15+
# https://github.com/python/cpython/pull/32175#issuecomment-1111175897
16+
@unittest.skipIf(support.MS_WINDOWS, 'test fails on Windows')
17+
# Building and running an extension in clang sanitizing mode is not
18+
# straightforward
19+
@support.skip_if_sanitizer('test does not work with analyzing builds',
20+
address=True, memory=True, ub=True, thread=True)
21+
# the test uses venv+pip: skip if it's not available
22+
@support.requires_venv_with_pip()
1923
@support.requires_subprocess()
24+
@support.requires_resource('cpu')
2025
class TestCPPExt(unittest.TestCase):
21-
@support.requires_resource('cpu')
2226
def test_build_cpp11(self):
2327
self.check_build(False, '_testcpp11ext')
2428

25-
@support.requires_resource('cpu')
2629
def test_build_cpp03(self):
2730
self.check_build(True, '_testcpp03ext')
2831

29-
# With MSVC, the linker fails with: cannot open file 'python311.lib'
30-
# https://github.com/python/cpython/pull/32175#issuecomment-1111175897
31-
@unittest.skipIf(support.MS_WINDOWS, 'test fails on Windows')
32-
# Building and running an extension in clang sanitizing mode is not
33-
# straightforward
34-
@unittest.skipIf(
35-
'-fsanitize' in (sysconfig.get_config_var('PY_CFLAGS') or ''),
36-
'test does not work with analyzing builds')
37-
# the test uses venv+pip: skip if it's not available
38-
@support.requires_venv_with_pip()
3932
def check_build(self, std_cpp03, extension_name):
4033
venv_dir = 'env'
4134
with support.setup_venv_with_pip_setuptools_wheel(venv_dir) as python_exe:

0 commit comments

Comments
 (0)