Skip to content

Commit

Permalink
Improve new test runner output and detect script errors
Browse files Browse the repository at this point in the history
  • Loading branch information
axvr committed Jan 26, 2025
1 parent e5f86af commit 80ec263
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions dev/do/test-indent
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@ mkdir -p "$tmp_base_dir"
tmp_dir="$(mktemp --directory "$tmp_base_dir/XXXXXX")"
test_case_dir='tests'

test_pass() { PASSED+=("$1"); }
test_pass() { PASSED+=("$1"); echo '::endgroup::'; }
test_fail() {
FAILED+=("$1")
echo '::endgroup::'
echo "::error file=clj/indent-test/$test_case_dir/$1/out.clj::Failed indent test case."
}
test_skip() {
SKIPPED+=("$1")
echo '::endgroup::'
echo "::warning file=clj/indent-test/$test_case_dir/$1/out.clj::Skipped indent test case."
}

Expand All @@ -33,7 +35,7 @@ run_test_case() {
in_file="$test_case_dir/$test_case/in.clj"
expected_file="$test_case_dir/$test_case/out.clj"

echo "::group::$EDITOR -- $test_case"
echo "::group::$EDITOR: $test_case"

if [ -f "$test_case_dir/$test_case/SKIP" ]; then
test_skip "$test_case"
Expand All @@ -55,13 +57,15 @@ run_test_case() {

[ $? -eq 0 ] && test_pass "$test_case" || test_fail "$test_case"
fi

echo '::endgroup::'
}

for tcase in $test_case_dir/*/; do
run_test_case "$(basename "$tcase")"
done

echo "passed: ${#PASSED[@]}, failed: ${#FAILED[@]}, skipped: ${#SKIPPED[@]}"
exit ${#FAILED[@]}

# If none passed, or some failed, exit with error.
if [ ${#PASSED[@]} -eq 0 ] || [ ${#FAILED[@]} -gt 0 ]; then
exit 1
fi

0 comments on commit 80ec263

Please sign in to comment.