summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2023-08-22 18:30:18 (GMT)
committerGitHub <noreply@github.com>2023-08-22 18:30:18 (GMT)
commit21dda09600848ac280481f7c64f8d9516dc69bb2 (patch)
tree7f07e637dfad29e825fc4f10c1aa313b39ba3d0f
parentc1c9cd61da1c5b6318da9f7055d45ec82a9949ba (diff)
downloadcpython-21dda09600848ac280481f7c64f8d9516dc69bb2.zip
cpython-21dda09600848ac280481f7c64f8d9516dc69bb2.tar.gz
cpython-21dda09600848ac280481f7c64f8d9516dc69bb2.tar.bz2
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.
-rw-r--r--Lib/test/test_cppext/__init__.py (renamed from Lib/test/test_cppext.py)8
-rw-r--r--Lib/test/test_cppext/extension.cpp (renamed from Lib/test/_testcppext.cpp)2
-rw-r--r--Lib/test/test_cppext/setup.py (renamed from Lib/test/setup_testcppext.py)3
-rw-r--r--Makefile.pre.in1
4 files changed, 8 insertions, 6 deletions
diff --git a/Lib/test/test_cppext.py b/Lib/test/test_cppext/__init__.py
index 7a143f4..8adff91 100644
--- a/Lib/test/test_cppext.py
+++ b/Lib/test/test_cppext/__init__.py
@@ -10,9 +10,8 @@ from test import support
MS_WINDOWS = (sys.platform == 'win32')
-
-
-SETUP_TESTCPPEXT = support.findfile('setup_testcppext.py')
+SOURCE = os.path.join(os.path.dirname(__file__), 'extension.cpp')
+SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
@support.requires_subprocess()
@@ -41,7 +40,8 @@ class TestCPPExt(unittest.TestCase):
def _check_build(self, std_cpp03, extension_name, python_exe):
pkg_dir = 'pkg'
os.mkdir(pkg_dir)
- shutil.copy(SETUP_TESTCPPEXT, os.path.join(pkg_dir, "setup.py"))
+ shutil.copy(SETUP, os.path.join(pkg_dir, os.path.basename(SETUP)))
+ shutil.copy(SOURCE, os.path.join(pkg_dir, os.path.basename(SOURCE)))
def run_cmd(operation, cmd):
env = os.environ.copy()
diff --git a/Lib/test/_testcppext.cpp b/Lib/test/test_cppext/extension.cpp
index 82b4713..90669b1 100644
--- a/Lib/test/_testcppext.cpp
+++ b/Lib/test/test_cppext/extension.cpp
@@ -1,5 +1,7 @@
// gh-91321: Very basic C++ test extension to check that the Python C API is
// compatible with C++ and does not emit C++ compiler warnings.
+//
+// The code is only built, not executed.
// Always enable assertions
#undef NDEBUG
diff --git a/Lib/test/setup_testcppext.py b/Lib/test/test_cppext/setup.py
index 22fe750..6867094 100644
--- a/Lib/test/setup_testcppext.py
+++ b/Lib/test/test_cppext/setup.py
@@ -2,7 +2,6 @@
# compatible with C++ and does not emit C++ compiler warnings.
import os
import sys
-from test import support
from setuptools import setup, Extension
@@ -10,7 +9,7 @@ from setuptools import setup, Extension
MS_WINDOWS = (sys.platform == 'win32')
-SOURCE = support.findfile('_testcppext.cpp')
+SOURCE = 'extension.cpp'
if not MS_WINDOWS:
# C++ compiler flags for GCC and clang
CPPFLAGS = [
diff --git a/Makefile.pre.in b/Makefile.pre.in
index beccab4..d66764e 100644
--- a/Makefile.pre.in
+++ b/Makefile.pre.in
@@ -2156,6 +2156,7 @@ TESTSUBDIRS= idlelib/idle_test \
test/support/_hypothesis_stubs \
test/test_asyncio \
test/test_capi \
+ test/test_cppext \
test/test_ctypes \
test/test_email \
test/test_email/data \