Article View: linux.gentoo.dev
Article #94[gentoo-dev] [PATCH 01/10] meson.eclass: support skipping tests
From: Alfred Wingate
Date: Thu, 05 Nov 2026 04:00
Date: Thu, 05 Nov 2026 04:00
99 lines
4897 bytes
4897 bytes
From: Alfred Wingate <parona@protonmail.com>
Meson 1.12.0 added support for skipping individual tests with --exclude.
Hook that up and homebrew a solution that works for older meson.
In practise the homebrewed solution lists all the tests in the test
suite, filters them out and explicitly runs the leftovers.
--no-suite is used early to filter out tests from the list, as meson
doesn't like explicitly running tests that match --no-suite in the same
command.
Signed-off-by: Alfred Wingate <parona@protonmail.com>
---
eclass/meson.eclass | 54 +++++++++++++++++++++++++++++++++++++++++----
1 file changed, 50 insertions(+), 4 deletions(-)
diff --git a/eclass/meson.eclass b/eclass/meson.eclass
index e0d7a01783861..9164a5b9ec4ec 100644
--- a/eclass/meson.eclass
+++ b/eclass/meson.eclass
@@ -85,6 +85,16 @@ BDEPEND=">=dev-build/meson-1.2.3
# User-controlled environment variable containing arguments to be passed to
# meson in meson_src_configure.
+# @VARIABLE: EMESON_SKIP_TEST_SUITES
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Array of test suites that should be skipped.
+
+# @VARIABLE: EMESON_SKIP_TESTS
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Array of tests that should be skipped.
+
# @FUNCTION: _meson_env_array
# @INTERNAL
# @DESCRIPTION:
@@ -546,12 +556,48 @@ meson_src_test() {
local mesontestargs=(
--print-errorlogs
--num-processes "$(makeopts_jobs "${MAKEOPTS}")"
- "$@"
)
- set -- meson test "${mesontestargs[@]}"
- echo "$@" >&2
- "$@"
+ if [[ -n ${EMESON_SKIP_TEST_SUITES} || -n ${EMESON_SKIP_TESTS} ]]; then
+ if has_version -b ">=dev-build/meson-1.12.0"; then
+ mesontestargs+=( "${EMESON_SKIP_TEST_SUITES[@]/#/--no-suite=}" "${EMESON_SKIP_TESTS[@]/#/--exclude=}" )
+ else
+ local -a tests=()
+ readarray -t tests < <(meson test --list -C "${BUILD_DIR}" "${EMESON_SKIP_TEST_SUITES[@]/#/--no-suite=}" 2>/dev/null )
+
+ local test_index
+ for test_index in "${!tests[@]}"; do
+ local test_name="${tests[${test_index}]}"
+
+ # Strip test suites while keeping subproject name to match --exclude behavior later on
+ test_name="${test_name##* - }"
+ # Override test name, cannot call test with pretty printed suites included
+ tests[${test_index}]="${test_name}"
+
+ # --exclude matches subproject:testname or testname
+ if [[ ${EMESON_SKIP_TESTS[@]} =~ ${test_name} ]] || \
+ [[ ${EMESON_SKIP_TESTS[@]} =~ ${test_name##*:} ]]; then
+ unset tests[${test_index}]
+ fi
+ done
+
+ # Handle case where you skip everything. Otherwise every test would run instead
+ if [[ ${#tests[@]} -eq 0 ]]; then
+ ewarn "Skipped all tests or no tests defined."
+ return 0
+ fi
+ fi
+ fi
+
+ set -- meson test "${mesontestargs[@]}" "$@"
+ if [[ -z ${tests[@]} ]]; then
+ echo "$@" >&2
+ "$@"
+ else
+ # Address ARGS_MAX for older meson test skipping
+ # Note: meson doesn't append to testlog.txt on new invocations, so logs may be lost.
+ printf '%s\0' "${tests[@]}" | xargs -0 -t "$@"
+ fi
local rv=$?
[[ ${rv} -eq 0 ]] || die -n "tests failed"
--
2.56.0
Technical Details
Message-ID:
<NVWNP-9V7G-17@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!bofh.it!news.nic.it!robomodReferences:
<NVWE9-9V4a-1@gated-at.bofh.it>Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!news.corradoroberto.it!bofh.it!news.nic.it!robomod From: Alfred Wingate <parona@protonmail.com> Newsgroups: linux.gentoo.dev Subject: [gentoo-dev] [PATCH 01/10] meson.eclass: support skipping tests Date: Thu, 05 Nov 2026 05:00:01 +0100 Message-ID: <NVWNP-9V7G-17@gated-at.bofh.it> References: <NVWE9-9V4a-1@gated-at.bofh.it> Feedback-ID: 25092314:user:proton X-Pm-Message-ID: c80b85b5704445cd8fe4088cb025b188db3a464b List-ID: Gentoo Linux mail <gentoo-dev.gentoo.org> Reply-To: gentoo-dev@lists.gentoo.org X-Auto-Response-Suppress: DR, RN, NRN, OOF, AutoReply MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable Approved: robomod@news.nic.it Lines: 99 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Cc: "base-system@gentoo.org" <base-system@gentoo.org>, "sam@gentoo.org" <sam@gentoo.org>, "eschwartz@gentoo.org" <eschwartz@gentoo.org>, "inbox@peterleese.org" <inbox@peterleese.org>, "gstreamer@gentoo.org" <gstreamer@gentoo.org>, "chewi@gentoo.org" <chewi@gentoo.org>, Alfred Wingate <parona@protonmail.com> X-Original-Date: Thu, 05 Nov 2026 03:48:47 +0000 X-Original-Message-ID: <20261105034814.1035529-2-parona@protonmail.com> X-Original-References: <20261105034814.1035529-1-parona@protonmail.com>