mtest: Run ninja build.ninja before loading tests

When the build definition has changed since the last ninja invocation meson
test operated on an outdated list of tests and their dependencies. That could
lead to some tests not being run / not all dependencies being built. This was
particularly confusing because the user would see the output of
reconfiguration and rebuilding, and the next mtest invocation would have the
updated configuration.

One issue with this is that that we will now output more useless ninja output
when nothing needs to be done (the "Entering directory" part is not repeated,
as we happen to be in the build directory already). It likely is worth
removing that output, perhaps by testing if anything needs to be done with
ninja -n, but that seems better addressed separately.

Fixes: #9852
pull/10765/head
Andres Freund 2 years ago committed by Eli Schwartz
parent f501e3b187
commit 628effb369
  1. 10
      mesonbuild/mtest.py
  2. 20
      unittests/allplatformstests.py

@ -1560,6 +1560,16 @@ class TestHarness:
startdir = os.getcwd()
try:
os.chdir(self.options.wd)
# Before loading build / test data, make sure that the build
# configuration does not need to be regenerated. This needs to
# 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}')
self.build_data = build.load(os.getcwd())
if not self.options.setup:
self.options.setup = self.build_data.test_setup_default_name

@ -793,6 +793,26 @@ class AllPlatformTests(BasePlatformTests):
self.assertFailedTestCount(2, self.mtest_command + ['--no-suite', 'subprjfail:fail', '--no-suite', 'subprjmix:fail'])
def test_mtest_reconfigure(self):
if self.backend is not Backend.ninja:
raise SkipTest(f'mtest can\'t rebuild with {self.backend.name!r}')
testdir = os.path.join(self.common_test_dir, '206 tap tests')
self.init(testdir)
self.utime(os.path.join(testdir, 'meson.build'))
o = self._run(self.mtest_command + ['--list'])
self.assertIn('Regenerating build files.', o)
self.assertIn('test_features / xfail', o)
o = self._run(self.mtest_command + ['--list'])
self.assertNotIn('Regenerating build files.', o)
# no real targets should have been built
tester = os.path.join(self.builddir, 'tester' + exe_suffix)
self.assertPathDoesNotExist(tester)
# check that we don't reconfigure if --no-rebuild is passed
self.utime(os.path.join(testdir, 'meson.build'))
o = self._run(self.mtest_command + ['--list', '--no-rebuild'])
self.assertNotIn('Regenerating build files.', o)
def test_build_by_default(self):
testdir = os.path.join(self.common_test_dir, '129 build by default')
self.init(testdir)

Loading…
Cancel
Save