Skip to content

Commit e029f68

Browse files
committed
Refactor reporting of failures
To make the code more symmetric between passed, skipped, and failed tests, this moves the line printing the result for failed tests out of report_failure, which is now only concerned with reporting the output of the failed test.
1 parent 841d025 commit e029f68

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

test/testlib.sh

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,7 @@ begin_test () {
146146
before_time=$(date '+%s')
147147
}
148148

149-
report_failure () {
150-
msg=$1
151-
desc=$2
152-
failures=$(( failures + 1 ))
153-
printf "test: %-73s $msg\\n" "$desc ..."
149+
report_failure_output () {
154150
(
155151
sed 's/^/ /' <"$TRASHDIR/out" |
156152
grep -a -v -e '^\+ end_test' -e '^+ set +x' |
@@ -172,7 +168,9 @@ end_test () {
172168
elif [ "$test_status" -eq 254 ]; then
173169
printf "test: %-65s SKIPPED\\n" "$test_description ..."
174170
else
175-
report_failure "FAILED (${elapsed_time}s)" "$test_description ..."
171+
failures=$(( failures + 1 ))
172+
printf "test: %-65s FAILED (${elapsed_time}s)\\n" "$test_description ..."
173+
report_failure_output
176174
fi
177175

178176
unset test_description

0 commit comments

Comments
 (0)