]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.11] gh-108303: Add Lib/test/test_cppext/ sub-directory (#108325) (#108336)
authorVictor Stinner <vstinner@python.org>
Wed, 23 Aug 2023 03:11:53 +0000 (05:11 +0200)
committerGitHub <noreply@github.com>
Wed, 23 Aug 2023 03:11:53 +0000 (05:11 +0200)
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 21dda09600848ac280481f7c64f8d9516dc69bb2)

Lib/test/test_cppext/__init__.py [moved from Lib/test/test_cppext.py with 95% 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 95%
rename from Lib/test/test_cppext.py
rename to Lib/test/test_cppext/__init__.py
index 465894d24e7dfc6638cd3674deb1d143d1611a93..4ce29b7ff2c23e10c7ae088d7c95ecd5547fd9c2 100644 (file)
@@ -10,9 +10,7 @@ from test.support import os_helper
 
 
 MS_WINDOWS = (sys.platform == 'win32')
-
-
-SETUP_TESTCPPEXT = support.findfile('setup_testcppext.py')
+SETUP = os.path.join(os.path.dirname(__file__), 'setup.py')
 
 
 @support.requires_subprocess()
@@ -74,14 +72,14 @@ class TestCPPExt(unittest.TestCase):
 
         # Build the C++ extension
         cmd = [python, '-X', 'dev',
-               SETUP_TESTCPPEXT, 'build_ext', '--verbose']
+               SETUP, 'build_ext', '--verbose']
         if std_cpp03:
             cmd.append('-std=c++03')
         run_cmd('Build', cmd)
 
         # Install the C++ extension
         cmd = [python, '-X', 'dev',
-               SETUP_TESTCPPEXT, 'install']
+               SETUP, 'install']
         run_cmd('Install', cmd)
 
         # Do a reference run. Until we test that running python
similarity index 99%
rename from Lib/test/_testcppext.cpp
rename to Lib/test/test_cppext/extension.cpp
index 0e381a78c5ceed72fa26624c05bf1c5c149c76c1..58d18ea67593304cca2b374ac65977b6803c338c 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 c6b68104d1333c442fb8246951df60ef35bb0795..dac3a96609ebcf3113be51cc2e2e258d956913fb 100644 (file)
@@ -1,7 +1,7 @@
 # gh-91321: Build a basic C++ test extension to check that the Python C API is
 # compatible with C++ and does not emit C++ compiler warnings.
+import os.path
 import sys
-from test import support
 
 from setuptools import setup, Extension
 
@@ -9,7 +9,7 @@ from setuptools import setup, Extension
 MS_WINDOWS = (sys.platform == 'win32')
 
 
-SOURCE = support.findfile('_testcppext.cpp')
+SOURCE = os.path.join(os.path.dirname(__file__), 'extension.cpp')
 if not MS_WINDOWS:
     # C++ compiler flags for GCC and clang
     CPPFLAGS = [
index 6405d06afe14e1d93e82c009583e3a5445dbf43f..884bea1841c232d5a79e81263b0f7d923cbfea2e 100644 (file)
@@ -1959,6 +1959,7 @@ TESTSUBDIRS=      ctypes/test \
                test/support \
                test/test_asyncio \
                test/test_capi \
+               test/test_cppext \
                test/test_email \
                test/test_email/data \
                test/test_import \