]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-108303: Add Lib/test/test_cppext/ sub-directory (#108325)
authorVictor Stinner <vstinner@python.org>
Tue, 22 Aug 2023 18:30:18 +0000 (20:30 +0200)
committerGitHub <noreply@github.com>
Tue, 22 Aug 2023 18:30:18 +0000 (18:30 +0000)
* 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.

Lib/test/test_cppext/__init__.py [moved from Lib/test/test_cppext.py with 91% similarity]
Lib/test/test_cppext/extension.cpp [moved from Lib/test/_testcppext.cpp with 99% similarity]
Lib/test/test_cppext/setup.py [moved from Lib/test/setup_testcppext.py with 93% similarity]
Makefile.pre.in

similarity index 91%
rename from Lib/test/test_cppext.py
rename to Lib/test/test_cppext/__init__.py
index 7a143f446401370e3309b8b522729097b17244be..8adff91c38efcf1956fce66395694eb18f2fec8b 100644 (file)
@@ -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()
similarity index 99%
rename from Lib/test/_testcppext.cpp
rename to Lib/test/test_cppext/extension.cpp
index 82b471312dd2b9f983d53cebc64245b77e9e6ad8..90669b10cb2c6dfaa702328666c75fdc9d4ae298 100644 (file)
@@ -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
similarity index 93%
rename from Lib/test/setup_testcppext.py
rename to Lib/test/test_cppext/setup.py
index 22fe750085fd70244073471f89dbe3de55fb9818..6867094a42043608ba3f279b5c4c7be8c6adc710 100644 (file)
@@ -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 = [
index beccab45a235a556701806c11cf457da436d7c69..d66764e6165409d7641e31a1dd3c0a63bc5164c4 100644 (file)
@@ -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 \