Skip to content

Commit

Permalink
mtest: fix rebuilding correct target list before running tests
Browse files Browse the repository at this point in the history
When manually specifying a target on the CLI, which does not have any
test deps, we  calculate that there are no deps to rebuild, we run ninja
without any targets, and this invokes the default "all" rule and maybe
builds a few thousand targets that this specific test does not need.

In such a case we simply should not run ninja at all, since we don't
want to rebuild anything.
  • Loading branch information
eli-schwartz committed May 20, 2022
1 parent ed6b33e commit 8a32168
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
5 changes: 5 additions & 0 deletions mesonbuild/mtest.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}')
Expand Down
4 changes: 4 additions & 0 deletions unittests/platformagnostictests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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'])

0 comments on commit 8a32168

Please sign in to comment.