diff options
author | Andrew McNulty <amcn102@gmail.com> | 2024-05-08 16:05:51 +0200 |
---|---|---|
committer | Andrew McNulty <amcn102@gmail.com> | 2024-06-11 19:47:31 +0200 |
commit | 4023bbfc3655cd9eba80021854ade9a0fcc97d11 (patch) | |
tree | 3580210717b71efd7431761f7cca58dee56f0d3c | |
parent | d1abdce88fa263b6e532901564e44ca510df1065 (diff) | |
download | meson-4023bbfc3655cd9eba80021854ade9a0fcc97d11.zip meson-4023bbfc3655cd9eba80021854ade9a0fcc97d11.tar.gz meson-4023bbfc3655cd9eba80021854ade9a0fcc97d11.tar.bz2 |
unittests: Add Python unittest for limited API
This new unittest runs the existing Python limited API
test case, and checks that the resulting library was linked to
the correct library.
-rw-r--r-- | unittests/pythontests.py | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/unittests/pythontests.py b/unittests/pythontests.py index 6079bd5..aaea906 100644 --- a/unittests/pythontests.py +++ b/unittests/pythontests.py @@ -11,7 +11,7 @@ from .allplatformstests import git_init from .baseplatformtests import BasePlatformTests from .helpers import * -from mesonbuild.mesonlib import MachineChoice, TemporaryDirectoryWinProof +from mesonbuild.mesonlib import MachineChoice, TemporaryDirectoryWinProof, is_windows from mesonbuild.modules.python import PythonModule class PythonTests(BasePlatformTests): @@ -86,3 +86,32 @@ python = pymod.find_installation('python3', required: true) if shutil.which('python2') or PythonModule._get_win_pythonpath('python2'): raise self.skipTest('python2 installed, already tested') self._test_bytecompile() + + def test_limited_api_linked_correct_lib(self): + if not is_windows(): + return self.skipTest('Test only run on Windows.') + + testdir = os.path.join(self.src_root, 'test cases', 'python', '9 extmodule limited api') + + self.init(testdir) + self.build() + + from importlib.machinery import EXTENSION_SUFFIXES + limited_suffix = EXTENSION_SUFFIXES[1] + + limited_library_path = os.path.join(self.builddir, f'limited{limited_suffix}') + self.assertPathExists(limited_library_path) + + limited_dep_name = 'python3.dll' + if shutil.which('dumpbin'): + # MSVC + output = subprocess.check_output(['dumpbin', '/DEPENDENTS', limited_library_path], + stderr=subprocess.STDOUT) + self.assertIn(limited_dep_name, output.decode()) + elif shutil.which('objdump'): + # mingw + output = subprocess.check_output(['objdump', '-p', limited_library_path], + stderr=subprocess.STDOUT) + self.assertIn(limited_dep_name, output.decode()) + else: + raise self.skipTest('Test needs either dumpbin(MSVC) or objdump(mingw).') |