]> git.ipfire.org Git - thirdparty/git.git/blame - ci/print-test-failures.sh
tests: optionally write results as JUnit-style .xml
[thirdparty/git.git] / ci / print-test-failures.sh
CommitLineData
657343a6
LS
1#!/bin/sh
2#
3# Print output of failing tests
4#
5
c2160f2d 6. ${0%/*}/lib.sh
657343a6 7
a8b8b6b8
SG
8# Tracing executed commands would produce too much noise in the loop below.
9set +x
10
aea8879a
SG
11cd t/
12
13if ! ls test-results/*.exit >/dev/null 2>/dev/null
677c7079
SG
14then
15 echo "Build job failed before the tests could have been run"
16 exit
17fi
18
aea8879a
SG
19case "$jobname" in
20osx-clang|osx-gcc)
21 # base64 in OSX doesn't wrap its output at 76 columns by
22 # default, but prints a single, very long line.
23 base64_opts="-b 76"
24 ;;
25esac
26
27combined_trash_size=0
28for TEST_EXIT in test-results/*.exit
f67242c1
JH
29do
30 if [ "$(cat "$TEST_EXIT")" != "0" ]
31 then
32 TEST_OUT="${TEST_EXIT%exit}out"
33 echo "------------------------------------------------------------------------"
34 echo "$(tput setaf 1)${TEST_OUT}...$(tput sgr0)"
35 echo "------------------------------------------------------------------------"
36 cat "${TEST_OUT}"
aea8879a
SG
37
38 test_name="${TEST_EXIT%.exit}"
39 test_name="${test_name##*/}"
40 trash_dir="trash directory.$test_name"
b011fabd
JS
41 case "$CI_TYPE" in
42 travis)
43 ;;
44 *)
45 echo "Unhandled CI type: $CI_TYPE" >&2
46 exit 1
47 ;;
48 esac
aea8879a
SG
49 trash_tgz_b64="trash.$test_name.base64"
50 if [ -d "$trash_dir" ]
51 then
52 tar czp "$trash_dir" |base64 $base64_opts >"$trash_tgz_b64"
53
54 trash_size=$(wc -c <"$trash_tgz_b64")
55 if [ $trash_size -gt 1048576 ]
56 then
57 # larger than 1MB
58 echo "$(tput setaf 1)Didn't include the trash directory of '$test_name' in the trace log, it's too big$(tput sgr0)"
59 continue
60 fi
61
62 new_combined_trash_size=$(($combined_trash_size + $trash_size))
63 if [ $new_combined_trash_size -gt 1048576 ]
64 then
65 echo "$(tput setaf 1)Didn't include the trash directory of '$test_name' in the trace log, there is plenty of trash in there already.$(tput sgr0)"
66 continue
67 fi
68 combined_trash_size=$new_combined_trash_size
69
70 # DO NOT modify these two 'echo'-ed strings below
71 # without updating 'ci/util/extract-trash-dirs.sh'
72 # as well.
73 echo "$(tput setaf 1)Start of trash directory of '$test_name':$(tput sgr0)"
74 cat "$trash_tgz_b64"
75 echo "$(tput setaf 1)End of trash directory of '$test_name'$(tput sgr0)"
76 fi
f67242c1 77 fi
657343a6 78done
aea8879a
SG
79
80if [ $combined_trash_size -gt 0 ]
81then
82 echo "------------------------------------------------------------------------"
83 echo "Trash directories embedded in this log can be extracted by running:"
84 echo
85 echo " curl https://api.travis-ci.org/v3/job/$TRAVIS_JOB_ID/log.txt |./ci/util/extract-trash-dirs.sh"
86fi