From 683f205402a99cfc8cea46c83ce9b46a42616d42 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sat, 16 Dec 2023 12:40:10 +0100 Subject: All kinds of stuff MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- tests/load-functions | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'tests/load-functions') diff --git a/tests/load-functions b/tests/load-functions index 2e9ddda..3436158 100644 --- a/tests/load-functions +++ b/tests/load-functions @@ -1,6 +1,30 @@ # -*- sh -*- # See LICENSE file for copyright and license details. +parallelindex=0 +p () { + ( + set +ev + pid=$$-$parallelindex + a=.a-$pid.tmp + b=.b-$pid.tmp + log=.x-$pid.tmp + ( set -ev ; $t "$@" ) > $log 2>&1 + r=$? + test $r = 0 || cat -- $log >&2 + rm -f -- .?-$pid.tmp + exit $r + ) & + eval parallelpid$(( ++parallelindex ))=$! +} +await () { + while (( parallelindex )); do + parallelvar=parallelpid$(( parallelindex-- )) + eval wait '$'$parallelvar + done +} + + stderr () { ("$@") 2>&1 >/dev/null } -- cgit v1.2.3-70-g09d2