diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 4cbaedba88eb..32c70b2835f9 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -1972,6 +1972,11 @@ def convert_path_to_target(path: str) -> str: depends.update(d) targets.update(intro_targets[d]) + if tests and not targets: + # We want to build minimal deps, but if the subset of targets have no + # deps then ninja falls back to 'all'. + return True + ret = subprocess.run(ninja + ['-C', wd] + sorted(targets)).returncode if ret != 0: print(f'Could not rebuild {wd}') diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py index bb6a14f6cb46..dd360663e49d 100644 --- a/unittests/platformagnostictests.py +++ b/unittests/platformagnostictests.py @@ -92,4 +92,8 @@ def test_mtest_rebuild_deps(self): self._run(self.mtest_command) self.clean() + with self.assertRaises(subprocess.CalledProcessError): + self._run(self.mtest_command + ['runner-without-dep']) + self.clean() + self._run(self.mtest_command + ['runner-with-exedep'])