Skip to content

Commit 7659541

Browse files
committed
Improve new test runner output and detect script errors
1 parent e5f86af commit 7659541

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

dev/do/test-indent

+11-7
Original file line numberDiff line numberDiff line change
@@ -18,22 +18,24 @@ mkdir -p "$tmp_base_dir"
1818
tmp_dir="$(mktemp --directory "$tmp_base_dir/XXXXXX")"
1919
test_case_dir='tests'
2020

21-
test_pass() { PASSED+=("$1"); }
21+
test_pass() { PASSED+=("$1"); echo '::endgroup::'; }
2222
test_fail() {
2323
FAILED+=("$1")
24-
echo "::error file=clj/indent-test/$test_case_dir/$1/out.clj::Failed indent test case."
24+
echo '::endgroup::'
25+
echo "::error file=dev/$test_case_dir/$1/out.clj::Failed indent test case."
2526
}
2627
test_skip() {
2728
SKIPPED+=("$1")
28-
echo "::warning file=clj/indent-test/$test_case_dir/$1/out.clj::Skipped indent test case."
29+
echo '::endgroup::'
30+
echo "::warning file=dev/$test_case_dir/$1/out.clj::Skipped indent test case."
2931
}
3032

3133
run_test_case() {
3234
test_case="$1"
3335
in_file="$test_case_dir/$test_case/in.clj"
3436
expected_file="$test_case_dir/$test_case/out.clj"
3537

36-
echo "::group::$EDITOR -- $test_case"
38+
echo "::group::$EDITOR: $test_case"
3739

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

5658
[ $? -eq 0 ] && test_pass "$test_case" || test_fail "$test_case"
5759
fi
58-
59-
echo '::endgroup::'
6060
}
6161

6262
for tcase in $test_case_dir/*/; do
6363
run_test_case "$(basename "$tcase")"
6464
done
6565

6666
echo "passed: ${#PASSED[@]}, failed: ${#FAILED[@]}, skipped: ${#SKIPPED[@]}"
67-
exit ${#FAILED[@]}
67+
68+
# If none passed, or some failed, exit with error.
69+
if [ ${#PASSED[@]} -eq 0 ] || [ ${#FAILED[@]} -gt 0 ]; then
70+
exit 1
71+
fi

0 commit comments

Comments
 (0)