2-test.sh (1142B)
1 #!/bin/bash 2 set -exuo pipefail 3 4 check_command() 5 { 6 make -j"$(nproc)" check 7 } 8 9 print_logs() 10 { 11 set +e 12 echo "###############################################################" 13 echo "## make check FAILED - dumping the logs of every failing test" 14 echo "###############################################################" 15 # Automake writes one .log per test plus a per-directory 16 # test-suite.log; the per-test logs carry the actual diagnostics. 17 find . -name 'test-suite.log' -print -exec cat {} \; 18 find . -name '*.log' -path '*/src/*' -newer config.status -print0 | 19 while IFS= read -r -d '' logfile; do 20 case "${logfile}" in 21 */config.log) continue ;; 22 esac 23 # Only the logs of tests that did not pass: automake writes a 24 # matching .trs with ":test-result: PASS" for successful ones. 25 trs="${logfile%.log}.trs" 26 if [ -f "${trs}" ] && grep -q ':test-result: PASS' "${trs}"; then 27 continue 28 fi 29 echo "--------------------------------------------------------" 30 echo "## ${logfile}" 31 echo "--------------------------------------------------------" 32 cat "${logfile}" 33 done 34 set -e 35 } 36 37 if ! check_command ; then 38 print_logs 39 exit 1 40 fi