Skip to content

Commit ddfe5b5

Browse files
committed
Include name of test suite in test logs
If a test fails, it’s not immediately clear which file it belongs to. To address this, this change adds the name of the test suite to the test logs, which corresponds to the name of the test file, omitting the file extension for better legibility.
1 parent 4d458bc commit ddfe5b5

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

test/testlib.sh

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,9 @@ PATH="$ROOTDIR/test/bin:$ROOTDIR/bin:$ROOTDIR/share/github-backup-utils:$PATH"
3030
TMPDIR="$ROOTDIR/test/tmp"
3131
TRASHDIR="$TMPDIR/$(basename "$0")-$$"
3232

33+
test_suite_file_name="$(basename "${BASH_SOURCE[1]}")"
34+
test_suite_name="${test_suite_file_name%.*}"
35+
3336
# Set GIT_{AUTHOR,COMMITTER}_{NAME,EMAIL}
3437
# This removes the assumption that a git config that specifies these is present.
3538
export GIT_AUTHOR_NAME=make GIT_AUTHOR_EMAIL=make GIT_COMMITTER_NAME=make GIT_COMMITTER_EMAIL=make
@@ -63,6 +66,8 @@ color_reset=$(printf '\e[0m')
6366
color_command=$(printf '\e[0;35m')
6467
# Display exit code line in red
6568
color_error_message=$(printf '\e[0;31m')
69+
# Display test suite name in blue
70+
color_test_suite=$(printf '\e[0;34m')
6671
# Display successful tests in bold green
6772
color_pass=$(printf '\e[1;32m')
6873
# Display skipped tests in bold gray
@@ -200,7 +205,8 @@ end_test () {
200205
printf "${color_fail}FAIL${color_reset}" 1>&2
201206
fi
202207

203-
printf " [%8.3f s] $test_description\\n" "$elapsed_time" 1>&2
208+
printf " [%8.3f s] ${color_test_suite}$test_suite_name${color_reset} $test_description\\n" \
209+
"$elapsed_time" 1>&2
204210

205211
if [ "$test_status" -ne 0 ] && [ "$test_status" -ne 254 ]; then
206212
report_failure_output

0 commit comments

Comments
 (0)