diff options
Diffstat (limited to 'test/local/main.sh')
| -rwxr-xr-x | test/local/main.sh | 51 |
1 files changed, 9 insertions, 42 deletions
diff --git a/test/local/main.sh b/test/local/main.sh index 64a8b7b..5713366 100755 --- a/test/local/main.sh +++ b/test/local/main.sh @@ -13,22 +13,15 @@ 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=() +source "$script_dir/lib/log.sh" run_test_file() { local test_file for test_file; do - echo - echo ====================================================================== - echo "TEST: $test_file" - echo ====================================================================== - - source "$script_dir/lib/common.sh" + source "$script_dir/lib/test.sh" source "$script_dir/$test_file" - echo "Should fail? ${test_should_fail:-No}" + log_test_start "$test_file" set +e ( @@ -44,21 +37,10 @@ run_test_file() { test_run ) - local ec="$?" + local ret="$?" set -e - if [ "$ec" -eq 0 ] || [ -n "${test_should_fail:+Yes}" ]; then - 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 + log_test_finish "$test_file" "$ret" done } @@ -72,30 +54,15 @@ main() { -type f \ -regex '.*/tst-.*\.sh$' \ -regextype posix-basic \ - -printf '%P\0' | - sort -z | + -printf '%P\0' \ + | sort -z \ + | \ while IFS= read -d '' -r test_file; do test_files+=("$test_file") done 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 - for test_file in ${failed_tests[@]+"${failed_tests[@]}"}; do - echo "FAIL: $test_file" - done - fi - echo ---------------------------------------------------------------------- - return "$ret" + log_tests_summary } main |
