diff options
author | Nirbheek Chauhan <nirbheek@centricular.com> | 2020-01-15 01:42:59 +0530 |
---|---|---|
committer | Nirbheek Chauhan <nirbheek.chauhan@gmail.com> | 2020-01-15 12:14:30 +0530 |
commit | b9d0c7a1698e2ba5fd39c1217eff872707ac9a6b (patch) | |
tree | 52a1fe4797807c0c39e9357152c915175900312e /run_tests.py | |
parent | cfc2b92e92e8dfce22592b8101e0b399d00cb91d (diff) | |
download | meson-b9d0c7a1698e2ba5fd39c1217eff872707ac9a6b.zip meson-b9d0c7a1698e2ba5fd39c1217eff872707ac9a6b.tar.gz meson-b9d0c7a1698e2ba5fd39c1217eff872707ac9a6b.tar.bz2 |
run_tests: Fix detection of ninja 1.9
`get_backend_commands()` doesn't get called when we run tests as
subprocesses, so detect ninja on import. This should speed up CI.
Fixes https://github.com/mesonbuild/meson/issues/5888
Diffstat (limited to 'run_tests.py')
-rwxr-xr-x | run_tests.py | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/run_tests.py b/run_tests.py index c811705..4a1d271 100755 --- a/run_tests.py +++ b/run_tests.py @@ -36,6 +36,26 @@ from mesonbuild.environment import Environment, detect_ninja from mesonbuild.coredata import backendlist NINJA_1_9_OR_NEWER = False +NINJA_CMD = None +# If we're on CI, just assume we have ninja in PATH and it's new enough because +# we provide that. This avoids having to detect ninja for every subprocess unit +# test that we run. +if 'CI' in os.environ: + NINJA_1_9_OR_NEWER = True + NINJA_CMD = 'ninja' +else: + # Look for 1.9 to see if https://github.com/ninja-build/ninja/issues/1219 + # is fixed, else require 1.6 for -w dupbuild=err + for v in ('1.9', '1.6'): + NINJA_CMD = detect_ninja(v) + if NINJA_CMD is not None: + if mesonlib.version_compare(v, '>=1.9'): + NINJA_1_9_OR_NEWER = True + else: + mlog.warning('Found ninja <1.9, tests will run slower', once=True) + break +if NINJA_CMD is None: + raise RuntimeError('Could not find Ninja v1.6 or newer') def guess_backend(backend, msbuild_exe: str): # Auto-detect backend if unspecified @@ -202,22 +222,8 @@ def get_backend_commands(backend, debug=False): clean_cmd = cmd + ['-alltargets', 'clean', '-UseNewBuildSystem=FALSE'] test_cmd = cmd + ['-target', 'RUN_TESTS'] elif backend is Backend.ninja: - global NINJA_1_9_OR_NEWER - # Look for 1.9 to see if https://github.com/ninja-build/ninja/issues/1219 - # is fixed, else require 1.6 for -w dupbuild=err - for v in ('1.9', '1.6'): - ninja_cmd = detect_ninja(v) - if ninja_cmd is not None: - if v == '1.9': - NINJA_1_9_OR_NEWER = True - else: - mlog.warning('Found ninja <1.9, tests will run slower', once=True) - if 'CI' in os.environ: - raise RuntimeError('Require ninja >= 1.9 when running on Meson CI') - break - cmd = [ninja_cmd, '-w', 'dupbuild=err', '-d', 'explain'] - if cmd[0] is None: - raise RuntimeError('Could not find Ninja v1.6 or newer') + global NINJA_CMD + cmd = [NINJA_CMD, '-w', 'dupbuild=err', '-d', 'explain'] if debug: cmd += ['-v'] clean_cmd = cmd + ['clean'] |