Debian Codegraph @

etc/actions/failed_tests_logs.sh

raw
1 #!/usr/bin/env bash
2
3 # This script checks if tests have failed. If yes, it prints the content of the
4 # failed tests log, and returns 1.
5 #
6 # It allows keeping the '-i' option for 'make check', print the failed
7 # tests, and only then, return exit 1 to interrupt the CI pipeline.
8
9 FAILED_TESTS=$(grep ":test-result: FAIL" examples/*/*.trs)
10
11 if [ -z "$FAILED_TESTS" ]; then
12 exit 0;
13 fi
14
15 NB_FAILED_TESTS=$(echo "$FAILED_TESTS" | wc -l)
16 echo "$NB_FAILED_TESTS tests failed:"
17
18 echo "$FAILED_TESTS" | while IFS= read -r line; do
19 path="${line%::test-result: FAIL}"
20 printf "\n******** ${path%.*}.log ********\n\n"
21 tail -n 100 ${path%.*}.log
22 done
23
24 exit 1