From aa84c55bef6393b00b3c86eed77bfc00756c7ce9 Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sat, 5 Nov 2022 21:12:25 -0400 Subject: [PATCH] tests: fix edge case where non-default python is used, by skipping it In a couple of python module tests, we try to test things that rely on the default python being the same one we look up in the python module. This is unsolvable for the deprecated python3 module, as it actually uses the in-process version of python for everything. For the python module, we could actually look up the default system python instead of the one we are running with, but then we wouldn't be testing the functionality of that alternative python... and also the install manifest tests would see files installed for the wrong version of python, and report a combination of missing+extra files... Solve both tests by just skipping the parts we cannot check. --- test cases/python/2 extmodule/meson.build | 17 ++++++++++++----- test cases/python3/3 cython/meson.build | 6 ++++++ 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/test cases/python/2 extmodule/meson.build b/test cases/python/2 extmodule/meson.build index c3f4eec6a..239492c44 100644 --- a/test cases/python/2 extmodule/meson.build +++ b/test cases/python/2 extmodule/meson.build @@ -34,10 +34,17 @@ py.install_sources(blaster, subdir: 'pure') py3_pkg_dep = dependency('python3', method: 'pkg-config', required : false) if py3_pkg_dep.found() - python_lib_dir = py3_pkg_dep.get_pkgconfig_variable('libdir') - - # Check we can apply a version constraint - dependency('python3', version: '>=@0@'.format(py_dep.version())) + py3_dep_majver = py3_pkg_dep.version().split('.') + py3_dep_majver = py3_dep_majver[0] + '.' + py3_dep_majver[1] + message(f'got two pythons: pkg-config is @py3_dep_majver@, and module is', py.language_version()) + if py3_dep_majver != py.language_version() + message('skipped python3 pkg-config test because the default python3 is different from Meson\'s') + else + python_lib_dir = py3_pkg_dep.get_pkgconfig_variable('libdir') + + # Check we can apply a version constraint + dependency('python3', version: '>=@0@'.format(py_dep.version())) + endif else - message('Skipped python3 pkg-config test') + message('Skipped python3 pkg-config test because it was not found') endif diff --git a/test cases/python3/3 cython/meson.build b/test cases/python3/3 cython/meson.build index 753b906cf..d41fc93c4 100644 --- a/test cases/python3/3 cython/meson.build +++ b/test cases/python3/3 cython/meson.build @@ -6,8 +6,14 @@ py3_dep = dependency('python3', required : false) if cython.found() and py3_dep.found() py3_dep = dependency('python3') + py3_dep_majver = py3_dep.version().split('.') + py3_dep_majver = py3_dep_majver[0] + '.' + py3_dep_majver[1] py3_mod = import('python3') py3 = py3_mod.find_python() + if py3_dep_majver != py3_mod.language_version() + v = py3_mod.language_version() + error('MESON_SKIP_TEST: deprecated python3 module is non-functional when default python3 is different from Meson\'s', v) + endif subdir('libdir') test('cython tester',