git/print-failed-test-output
Todd Zullinger 676f6fab11 Improve debug output when 'make test' fails
If 'make test' fails before running any tests, the debug output from
print-failed-test-output is confusing:

    + ./print-failed-test-output
    cat: t/test-results/*.exit: No such file or directory
    ./print-failed-test-output: line 6: [: : integer expression expected

    --------------------------------------------------------------------------------
    t/test-results/*.out
    --------------------------------------------------------------------------------
    cat: t/test-results/*.out: No such file or directory

Use the bash failglob option to imrpve the output:

    + ./print-failed-test-output
    ./print-failed-test-output: line 12: no match: t/test-results/*.exit
2018-05-25 10:20:48 -04:00

14 lines
325 B
Bash

#!/bin/bash
shopt -s failglob
# Print output from failing tests
dashes=$(printf "%80s" '' | tr ' ' '-')
for exit_file in t/test-results/*.exit; do
[ "$(cat "$exit_file")" -eq 0 ] && continue
out_file="${exit_file%exit}out"
printf '\n%s\n%s\n%s\n' "$dashes" "$out_file" "$dashes"
cat "$out_file"
done
exit 1