From: Alfred Wingate <paro…@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 <paro…@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