Skip to content

Commit a153961

Browse files
authored
[3.11] gh-108303: Add Lib/test/test_cppext/ sub-directory (#108325) (#108336)
gh-108303: Add Lib/test/test_cppext/ sub-directory (#108325) * Move test_cppext to its own directory * Rename setup_testcppext.py to setup.py * Rename _testcppext.cpp to extension.cpp * The source (extension.cpp) is now also copied by the test. (cherry picked from commit 21dda09)
1 parent 12cad61 commit a153961

File tree

4 files changed

+8
-7
lines changed

4 files changed

+8
-7
lines changed

Lib/test/test_cppext.py renamed to Lib/test/test_cppext/__init__.py

+3-5
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,7 @@
1010

1111

1212
MS_WINDOWS = (sys.platform == 'win32')
13-
14-
15-
SETUP_TESTCPPEXT = support.findfile('setup_testcppext.py')
13+
SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
1614

1715

1816
@support.requires_subprocess()
@@ -74,14 +72,14 @@ def run_cmd(operation, cmd):
7472

7573
# Build the C++ extension
7674
cmd = [python, '-X', 'dev',
77-
SETUP_TESTCPPEXT, 'build_ext', '--verbose']
75+
SETUP, 'build_ext', '--verbose']
7876
if std_cpp03:
7977
cmd.append('-std=c++03')
8078
run_cmd('Build', cmd)
8179

8280
# Install the C++ extension
8381
cmd = [python, '-X', 'dev',
84-
SETUP_TESTCPPEXT, 'install']
82+
SETUP, 'install']
8583
run_cmd('Install', cmd)
8684

8785
# Do a reference run. Until we test that running python

Lib/test/_testcppext.cpp renamed to Lib/test/test_cppext/extension.cpp

+2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
// gh-91321: Very basic C++ test extension to check that the Python C API is
22
// compatible with C++ and does not emit C++ compiler warnings.
3+
//
4+
// The code is only built, not executed.
35

46
// Always enable assertions
57
#undef NDEBUG

Lib/test/setup_testcppext.py renamed to Lib/test/test_cppext/setup.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
11
# gh-91321: Build a basic C++ test extension to check that the Python C API is
22
# compatible with C++ and does not emit C++ compiler warnings.
3+
import os.path
34
import sys
4-
from test import support
55

66
from setuptools import setup, Extension
77

88

99
MS_WINDOWS = (sys.platform == 'win32')
1010

1111

12-
SOURCE = support.findfile('_testcppext.cpp')
12+
SOURCE = os.path.join(os.path.dirname(__file__), 'extension.cpp')
1313
if not MS_WINDOWS:
1414
# C++ compiler flags for GCC and clang
1515
CPPFLAGS = [

Makefile.pre.in

+1
Original file line numberDiff line numberDiff line change
@@ -1959,6 +1959,7 @@ TESTSUBDIRS= ctypes/test \
19591959
test/support \
19601960
test/test_asyncio \
19611961
test/test_capi \
1962+
test/test_cppext \
19621963
test/test_email \
19631964
test/test_email/data \
19641965
test/test_import \

0 commit comments

Comments
 (0)