From ed2b88c31a9cd3efe0485cf4b7a2f3b8f251b61e Mon Sep 17 00:00:00 2001 From: Egor Tensin Date: Tue, 22 Sep 2026 16:18:39 +0500 Subject: test/local: tests summary & output tweaks --- test/local/main.sh | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) (limited to 'test') diff --git a/test/local/main.sh b/test/local/main.sh index cba7ab7..64a8b7b 100755 --- a/test/local/main.sh +++ b/test/local/main.sh @@ -13,6 +13,8 @@ script_dir="$( dirname -- "${BASH_SOURCE[0]}" )" script_dir="$( cd -- "$script_dir" && pwd )" readonly script_dir +numof_ok_tests=0 +numof_failed_tests=0 declare -a failed_tests=() run_test_file() { @@ -20,7 +22,7 @@ run_test_file() { for test_file; do echo echo ====================================================================== - echo "Running test: $test_file" + echo "TEST: $test_file" echo ====================================================================== source "$script_dir/lib/common.sh" @@ -49,10 +51,12 @@ run_test_file() { echo ---------------------------------------------------------------------- echo "OK: $test_file" echo ---------------------------------------------------------------------- + numof_ok_tests=$((numof_ok_tests + 1)) else echo ---------------------------------------------------------------------- echo "FAIL: $test_file" echo ---------------------------------------------------------------------- + numof_failed_tests=$((numof_failed_tests + 1)) failed_tests+=("$test_file") fi done @@ -60,6 +64,7 @@ run_test_file() { main() { local -a test_files=() + local test_file find "$script_dir" \ -mindepth 1 \ @@ -75,13 +80,22 @@ main() { run_test_file ${test_files[@]+"${test_files[@]}"} + local ret=0 + [ "$numof_failed_tests" -gt 0 ] && ret=1 + + echo + echo ====================================================================== + echo SUMMARY + echo ====================================================================== + echo "OK: $numof_ok_tests" + echo "FAIL: $numof_failed_tests" if [ "${#failed_tests[@]}" -gt 0 ]; then - echo - echo ====================================================================== - echo "FAILED TESTS:" ${failed_tests[@]+"${failed_tests[@]}"} - echo ====================================================================== - return 1 + for test_file in ${failed_tests[@]+"${failed_tests[@]}"}; do + echo "FAIL: $test_file" + done fi + echo ---------------------------------------------------------------------- + return "$ret" } main -- cgit v1.3