summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorEli Schwartz <eschwartz@archlinux.org>2022-05-19 19:17:01 -0400
committerEli Schwartz <eschwartz93@gmail.com>2025-01-07 20:16:05 -0500
commiteb1e52afa142fc0f38260a9cb3413f2bd63b1675 (patch)
tree26c54730d3d586c6305da7127ed5716da78407da /unittests
parentdfe5cbb3e432bb632731f853df05e2023ab233d6 (diff)
downloadmeson-eb1e52afa142fc0f38260a9cb3413f2bd63b1675.tar.gz
mtest: fix rebuilding all before running tests
Inconsistency in the original implementation of commit 79e2c52a15e896e46ff3cfa3ec16fbf3f132ee01. If an explicit list of targets is passed on the CLI, then that is passed to rebuild_deps. If not, we pass every loaded test to rebuild_deps instead. This means we cannot distinguish between "trying to run all tests" and "trying to run specific tests". We then load all the deps for all tests, and try to build them all as explicit arguments to the underlying ninja. There are two situations where this falls flat: - given underspecified deps - given all (selected?) tests legitimately happen to have no dependencies In both cases, 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 run does not need. Additionally, in large projects which define many tests with many dependencies, we could end up overflowing ARG_MAX when processing *all* tests. Instead, pass no tests to rebuild_deps. We then specially handle this by directly running the relevant ninja target for "all test deps", which is overall more elegant than specifying many many dependencies by name. Given a subset of tests to guarantee the freshness of, we instead skip running ninja at all if there are indeed no test dependencies.
Diffstat (limited to 'unittests')
-rw-r--r--unittests/platformagnostictests.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/unittests/platformagnostictests.py b/unittests/platformagnostictests.py
index 2fb75f284..ef277dee2 100644
--- a/unittests/platformagnostictests.py
+++ b/unittests/platformagnostictests.py
@@ -6,6 +6,7 @@ from __future__ import annotations
import json
import os
import pickle
+import subprocess
import tempfile
import subprocess
import textwrap
@@ -508,3 +509,17 @@ class PlatformAgnosticTests(BasePlatformTests):
f.write("option('new_option', type : 'boolean', value : false)")
self.setconf('-Dsubproject:new_option=true')
self.assertEqual(self.getconf('subproject:new_option'), True)
+
+ def test_mtest_rebuild_deps(self):
+ testdir = os.path.join(self.unit_test_dir, '106 underspecified mtest')
+ self.init(testdir)
+
+ with self.assertRaises(subprocess.CalledProcessError):
+ 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'])