meson.eclass: fix tests
authorWilliam Hubbs <williamh@gentoo.org>
Sun, 2 Jun 2019 16:29:07 +0000 (11:29 -0500)
committerWilliam Hubbs <williamh@gentoo.org>
Sun, 2 Jun 2019 16:47:11 +0000 (11:47 -0500)
- use "meson test" to run tests instead of "eninja test"
- calculate --num-processes based on ninjaopts or makeopts in the "meson test"
  call.
- allow meson_src_test to accept arguments with the emesontestargs array
  or passed in the call like meson_src_configure

Closes: https://bugs.gentoo.org/680010
Signed-off-by: William Hubbs <williamh@gentoo.org>
eclass/meson.eclass

index 65b09932a7ac0bd3c8c179b9e390ba70f4c66c8c..b9562376b8687d3abe185a2ab6fb3c68bf34e21a 100644 (file)
@@ -41,7 +41,7 @@ esac
 
 if [[ -z ${_MESON_ECLASS} ]]; then
 
-inherit ninja-utils python-utils-r1 toolchain-funcs
+inherit multiprocessing ninja-utils python-utils-r1 toolchain-funcs
 
 fi
 
@@ -78,6 +78,12 @@ fi
 # Optional meson arguments as Bash array; this should be defined before
 # calling meson_src_configure.
 
+# @VARIABLE: emesontestargs
+# @DEFAULT_UNSET
+# @DESCRIPTION:
+# Optional meson test arguments as Bash array; this should be defined before
+# calling meson_src_test.
+
 
 read -d '' __MESON_ARRAY_PARSER <<"EOF"
 import shlex
@@ -246,12 +252,27 @@ meson_src_compile() {
 }
 
 # @FUNCTION: meson_src_test
+# @USAGE: [extra meson test arguments]
 # @DESCRIPTION:
 # This is the meson_src_test function.
 meson_src_test() {
        debug-print-function ${FUNCNAME} "$@"
 
-       eninja -C "${BUILD_DIR}" test
+       local mesontestargs=(
+               --verbose
+               -C "${BUILD_DIR}"
+               )
+       [[ -n ${NINJAOPTS} || -n ${MAKEOPTS} ]] &&
+               mesontestargs+=(
+                       --num-processes "$(makeopts_jobs ${NINJAOPTS:-${MAKEOPTS}})"
+                       )
+
+       # Append additional arguments from ebuild
+       mesontestargs+=("${emesontestargs[@]}")
+
+       set -- meson test "${mesontestargs[@]}" "$@"
+       echo "$@" >&2
+       "$@" || die "tests failed"
 }
 
 # @FUNCTION: meson_src_install