cmake-utils.eclass: Support running ctest in parallel
authorMichał Górny <mgorny@gentoo.org>
Tue, 13 Dec 2016 08:29:13 +0000 (09:29 +0100)
committerMichał Górny <mgorny@gentoo.org>
Sat, 7 Jan 2017 10:23:58 +0000 (11:23 +0100)
Pass -j and --test-load options (with values based on MAKEOPTS) to CTest
by default, in order to enable parallel test runs.

eclass/cmake-utils.eclass

index 1b269dd6d134bee7804c6844835860a4f9e6486c..099aaac7b26f31cfaa91cd6d7214b6070d4f4bf8 100644 (file)
@@ -117,7 +117,7 @@ case ${EAPI} in
        *) die "EAPI=${EAPI:-0} is not supported" ;;
 esac
 
-inherit toolchain-funcs multilib flag-o-matic eutils versionator
+inherit toolchain-funcs multilib flag-o-matic eutils multiprocessing versionator
 
 EXPORT_FUNCTIONS src_prepare src_configure src_compile src_test src_install
 
@@ -780,8 +780,9 @@ enable_cmake-utils_src_test() {
 
        [[ -n ${TEST_VERBOSE} ]] && myctestargs+=( --extra-verbose --output-on-failure )
 
-       echo ctest "${myctestargs[@]}" "$@"
-       if ctest "${myctestargs[@]}" "$@" ; then
+       set -- ctest -j "$(makeopts_jobs)" --test-load "$(makeopts_loadavg)" "${myctestargs[@]}" "$@"
+       echo "$@" >&2
+       if "$@" ; then
                einfo "Tests succeeded."
                popd > /dev/null || die
                return 0