From 9d446d80db5b11b947521cd4e4a21231ddc5154e Mon Sep 17 00:00:00 2001 From: Eli Schwartz Date: Sun, 9 Jul 2023 03:12:59 -0400 Subject: [PATCH] mtest: try a bit harder to avoid weird non-parseable output at startup In commit 628effb3698e85e403351d2705d576cf4ee8c50c we started verifying the build.ninja file was up to date before even `--list`ing tests, because we could end up with incorrect information. This meant that ninja always runs at startup, and typically returns "no work to do", which ended up listed as "one of" the tests. Instead of unconditionally running ninja attached to the console, first check it in dry-run mode with stdout intercepted, to see if ninja considers itself up to date. If it is, continue. Only if an actual refresh is needed, do we run it while attached to the console. In the garden path, this avoids useless information. In cases where we'd already print a full meson reconfigure log, we continue to do so. --- mesonbuild/mtest.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/mesonbuild/mtest.py b/mesonbuild/mtest.py index 63041bd2c..ed3495aea 100644 --- a/mesonbuild/mtest.py +++ b/mesonbuild/mtest.py @@ -1606,9 +1606,11 @@ class TestHarness: # happen before rebuild_deps(), because we need the correct list of # tests and their dependencies to compute if not self.options.no_rebuild: - ret = subprocess.run(self.ninja + ['build.ninja']).returncode - if ret != 0: - raise TestException(f'Could not configure {self.options.wd!r}') + teststdo = subprocess.run(self.ninja + ['-n', 'build.ninja'], capture_output=True).stdout + if b'ninja: no work to do.' not in teststdo and b'samu: nothing to do' not in teststdo: + ret = subprocess.run(self.ninja + ['build.ninja']) + if ret.returncode != 0: + raise TestException(f'Could not configure {self.options.wd!r}') self.build_data = build.load(os.getcwd()) if not self.options.setup: