Lars Schneider | 657343a | 2017-09-10 16:44:28 +0200 | [diff] [blame] | 1 | #!/bin/sh |
| 2 | # |
| 3 | # Print output of failing tests |
| 4 | # |
| 5 | |
Johannes Schindelin | c2160f2 | 2019-01-27 15:26:50 -0800 | [diff] [blame] | 6 | . ${0%/*}/lib.sh |
Lars Schneider | 657343a | 2017-09-10 16:44:28 +0200 | [diff] [blame] | 7 | |
SZEDER Gábor | a8b8b6b | 2017-12-27 17:36:00 +0100 | [diff] [blame] | 8 | # Tracing executed commands would produce too much noise in the loop below. |
| 9 | set +x |
| 10 | |
SZEDER Gábor | aea8879 | 2018-08-01 00:56:12 +0200 | [diff] [blame] | 11 | cd t/ |
| 12 | |
| 13 | if ! ls test-results/*.exit >/dev/null 2>/dev/null |
SZEDER Gábor | 677c707 | 2017-12-27 17:36:03 +0100 | [diff] [blame] | 14 | then |
| 15 | echo "Build job failed before the tests could have been run" |
| 16 | exit |
| 17 | fi |
| 18 | |
SZEDER Gábor | aea8879 | 2018-08-01 00:56:12 +0200 | [diff] [blame] | 19 | case "$jobname" in |
| 20 | osx-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 | ;; |
| 25 | esac |
| 26 | |
| 27 | combined_trash_size=0 |
| 28 | for TEST_EXIT in test-results/*.exit |
Junio C Hamano | f67242c | 2017-09-11 10:18:29 +0900 | [diff] [blame] | 29 | do |
| 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}" |
SZEDER Gábor | aea8879 | 2018-08-01 00:56:12 +0200 | [diff] [blame] | 37 | |
| 38 | test_name="${TEST_EXIT%.exit}" |
| 39 | test_name="${test_name##*/}" |
| 40 | trash_dir="trash directory.$test_name" |
Johannes Schindelin | b011fab | 2019-01-27 15:26:51 -0800 | [diff] [blame] | 41 | case "$CI_TYPE" in |
Johannes Schindelin | 6141a2e | 2019-01-29 06:19:28 -0800 | [diff] [blame] | 42 | azure-pipelines) |
| 43 | mkdir -p failed-test-artifacts |
| 44 | mv "$trash_dir" failed-test-artifacts |
| 45 | continue |
| 46 | ;; |
Johannes Schindelin | f72f328 | 2020-04-11 00:18:14 +0700 | [diff] [blame] | 47 | github-actions) |
| 48 | mkdir -p failed-test-artifacts |
Junio C Hamano | 92bf1b6 | 2020-11-17 12:10:35 -0800 | [diff] [blame] | 49 | echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV |
Johannes Schindelin | f72f328 | 2020-04-11 00:18:14 +0700 | [diff] [blame] | 50 | cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/ |
| 51 | tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir" |
| 52 | continue |
| 53 | ;; |
Patrick Steinhardt | 0e3b67e | 2023-11-09 09:05:54 +0100 | [diff] [blame] | 54 | gitlab-ci) |
| 55 | mkdir -p failed-test-artifacts |
| 56 | cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/ |
| 57 | tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir" |
| 58 | continue |
| 59 | ;; |
Johannes Schindelin | b011fab | 2019-01-27 15:26:51 -0800 | [diff] [blame] | 60 | *) |
| 61 | echo "Unhandled CI type: $CI_TYPE" >&2 |
| 62 | exit 1 |
| 63 | ;; |
| 64 | esac |
SZEDER Gábor | aea8879 | 2018-08-01 00:56:12 +0200 | [diff] [blame] | 65 | trash_tgz_b64="trash.$test_name.base64" |
| 66 | if [ -d "$trash_dir" ] |
| 67 | then |
| 68 | tar czp "$trash_dir" |base64 $base64_opts >"$trash_tgz_b64" |
| 69 | |
| 70 | trash_size=$(wc -c <"$trash_tgz_b64") |
| 71 | if [ $trash_size -gt 1048576 ] |
| 72 | then |
| 73 | # larger than 1MB |
| 74 | echo "$(tput setaf 1)Didn't include the trash directory of '$test_name' in the trace log, it's too big$(tput sgr0)" |
| 75 | continue |
| 76 | fi |
| 77 | |
| 78 | new_combined_trash_size=$(($combined_trash_size + $trash_size)) |
| 79 | if [ $new_combined_trash_size -gt 1048576 ] |
| 80 | then |
| 81 | 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)" |
| 82 | continue |
| 83 | fi |
| 84 | combined_trash_size=$new_combined_trash_size |
| 85 | |
| 86 | # DO NOT modify these two 'echo'-ed strings below |
| 87 | # without updating 'ci/util/extract-trash-dirs.sh' |
| 88 | # as well. |
| 89 | echo "$(tput setaf 1)Start of trash directory of '$test_name':$(tput sgr0)" |
| 90 | cat "$trash_tgz_b64" |
| 91 | echo "$(tput setaf 1)End of trash directory of '$test_name'$(tput sgr0)" |
| 92 | fi |
Junio C Hamano | f67242c | 2017-09-11 10:18:29 +0900 | [diff] [blame] | 93 | fi |
Lars Schneider | 657343a | 2017-09-10 16:44:28 +0200 | [diff] [blame] | 94 | done |