From 23377654c21533781cd4e602cbd45746e0cd5cf6 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Mon, 14 Sep 2020 17:02:51 +0200 Subject: [PATCH] :wrench: Improve test.sh --- scripts/test.sh | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/scripts/test.sh b/scripts/test.sh index b3e3e48e..ecbbc5b0 100644 --- a/scripts/test.sh +++ b/scripts/test.sh @@ -183,12 +183,10 @@ dir_contains() { } test_dir() { - local n offset l base - l=0 + local n offset l n=$2 - # [ -z "$n" ] && n=1 + l=$n offset=$n - base=$((n-1)) [ "$async" -lt 0 ] && set -m found=0 grep '\.gw' <<< "$(ls "$1")" &> /dev/null && found=1 @@ -201,25 +199,28 @@ test_dir() { else test_gw "$file" "$n" fi [ "$async" -ne 0 ] && { - if [ $(( $((n-base)) % async)) -eq 0 ] + if [ $((n % async)) -eq 0 ] then wait for i in $(seq "$offset" "$n") do read_test "${GWION_TEST_DIR}${separator}${GWION_TEST_PREFIX}$(printf "%04i" "$i").log" + l=$((l+1)) done offset=$((offset + async)); fi } n=$((n+1)) - l=$((l+1)) done - [ "$async" -ne 0 ] && { + [ $l != $n ] && [ "$async" -ne 0 ] && { wait - local rest=$(( $((n-base-1)) %async)) - for i in $(seq $((n-rest)) $((n-1))) - do read_test "${GWION_TEST_DIR}${separator}${GWION_TEST_PREFIX}$(printf "%04i" "$i").log" - done + local rest=$((n-l)) + if [ $rest -gt 0 ] + then + for i in $(seq $((l)) $((n-1))) + do read_test "${GWION_TEST_DIR}${separator}${GWION_TEST_PREFIX}$(printf "%04i" "$i").log" + done + fi } fi @@ -309,7 +310,7 @@ do_test() { elif [ -d "$arg" ] then # [ -f ${GWION_TEST_DIR}/${GWION_TEST_PREFIX}bailout ] && exit 1 - [ "${arg: -1}" = "/" ] && arg=${arg:0: -1} + [ "${arg: -1}" = "/" ] && arg=${arg%?} # make header for i in $(seq 1 $((${#arg}+4))); do printf "#"; done echo -e '\n'"# $arg #"'\t'"${ANSI_RESET}severity: ${ANSI_BOLD}$severity${ANSI_RESET}" -- 2.43.0