summaryrefslogtreecommitdiff
path: root/run_project_tests.py
diff options
context:
space:
mode:
authorAndrew McNulty <amcn102@gmail.com>2024-02-14 00:57:56 +0000
committerEli Schwartz <eschwartz93@gmail.com>2024-02-14 22:58:40 -0500
commitc0bf597715f7077a0897fd1ebecbe829452be972 (patch)
tree996826912c3dbd955c32e1ca3a18f82fd619287f /run_project_tests.py
parentefad4ba9c52479150a23a094a89e821e937b1cbd (diff)
downloadmeson-c0bf597715f7077a0897fd1ebecbe829452be972.tar.gz
run_project_tests: Fix Cython compiler detection
On Debian systems the cython compiler binary is installed as `cython3`. The current logic for detecting whether to run the Cython unit tests instead checks for `cython` or the value of the `CYTHON` environment variable, which leads to cases where the underlying Meson can correctly compile Cython code but the test harness excludes these tests from execution because it cannot find `cython3`. This commit makes the test harness use the same detection method as Meson itself. It also takes the opportunity to refactor some existing code which does the same job for Objective C and Objective C++ tests to avoid repetition.
Diffstat (limited to 'run_project_tests.py')
-rwxr-xr-xrun_project_tests.py33
1 files changed, 13 insertions, 20 deletions
diff --git a/run_project_tests.py b/run_project_tests.py
index 4458fce76..60ff56f70 100755
--- a/run_project_tests.py
+++ b/run_project_tests.py
@@ -37,7 +37,7 @@ from mesonbuild import compilers
from mesonbuild import mesonlib
from mesonbuild import mlog
from mesonbuild import mtest
-from mesonbuild.compilers import compiler_from_language, detect_objc_compiler, detect_objcpp_compiler
+from mesonbuild.compilers import compiler_from_language
from mesonbuild.build import ConfigurationData
from mesonbuild.mesonlib import MachineChoice, Popen_safe, TemporaryDirectoryWinProof, setup_vsenv
from mesonbuild.mlog import blue, bold, cyan, green, red, yellow, normal_green
@@ -964,33 +964,26 @@ def have_d_compiler() -> bool:
return False
def have_objc_compiler(use_tmp: bool) -> bool:
- with TemporaryDirectoryWinProof(prefix='b ', dir=None if use_tmp else '.') as build_dir:
- env = environment.Environment('', build_dir, get_fake_options('/'))
- try:
- objc_comp = detect_objc_compiler(env, MachineChoice.HOST)
- except mesonlib.MesonException:
- return False
- if not objc_comp:
- return False
- env.coredata.process_new_compiler('objc', objc_comp, env)
- try:
- objc_comp.sanity_check(env.get_scratch_dir(), env)
- except mesonlib.MesonException:
- return False
- return True
+ return have_working_compiler('objc', use_tmp)
def have_objcpp_compiler(use_tmp: bool) -> bool:
+ return have_working_compiler('objcpp', use_tmp)
+
+def have_cython_compiler(use_tmp: bool) -> bool:
+ return have_working_compiler('cython', use_tmp)
+
+def have_working_compiler(lang: str, use_tmp: bool) -> bool:
with TemporaryDirectoryWinProof(prefix='b ', dir=None if use_tmp else '.') as build_dir:
env = environment.Environment('', build_dir, get_fake_options('/'))
try:
- objcpp_comp = detect_objcpp_compiler(env, MachineChoice.HOST)
+ compiler = compiler_from_language(env, lang, MachineChoice.HOST)
except mesonlib.MesonException:
return False
- if not objcpp_comp:
+ if not compiler:
return False
- env.coredata.process_new_compiler('objcpp', objcpp_comp, env)
+ env.coredata.process_new_compiler(lang, compiler, env)
try:
- objcpp_comp.sanity_check(env.get_scratch_dir(), env)
+ compiler.sanity_check(env.get_scratch_dir(), env)
except mesonlib.MesonException:
return False
return True
@@ -1116,7 +1109,7 @@ def detect_tests_to_run(only: T.Dict[str, T.List[str]], use_tmp: bool) -> T.List
TestCategory('java', 'java', backend is not Backend.ninja or not have_java()),
TestCategory('C#', 'csharp', skip_csharp(backend)),
TestCategory('vala', 'vala', backend is not Backend.ninja or not shutil.which(os.environ.get('VALAC', 'valac'))),
- TestCategory('cython', 'cython', backend is not Backend.ninja or not shutil.which(os.environ.get('CYTHON', 'cython'))),
+ TestCategory('cython', 'cython', backend is not Backend.ninja or not have_cython_compiler(options.use_tmpdir)),
TestCategory('rust', 'rust', should_skip_rust(backend)),
TestCategory('d', 'd', backend is not Backend.ninja or not have_d_compiler()),
TestCategory('objective c', 'objc', backend not in (Backend.ninja, Backend.xcode) or not have_objc_compiler(options.use_tmpdir)),