3 # Print output of failing tests
8 # Tracing executed commands would produce too much noise in the loop below.
13 if ! ls test-results/*.exit >/dev/null 2>/dev/null
15 echo "Build job failed before the tests could have been run"
21 # base64 in OSX doesn't wrap its output at 76 columns by
22 # default, but prints a single, very long line.
28 for TEST_EXIT in test-results/*.exit
30 if [ "$(cat "$TEST_EXIT")" != "0" ]
32 TEST_OUT="${TEST_EXIT%exit}out"
33 echo "------------------------------------------------------------------------"
34 echo "$(tput setaf 1)${TEST_OUT}...$(tput sgr0)"
35 echo "------------------------------------------------------------------------"
38 test_name="${TEST_EXIT%.exit}"
39 test_name="${test_name##*/}"
40 trash_dir="trash directory.$test_name"
45 mkdir -p failed-test-artifacts
46 mv "$trash_dir" failed-test-artifacts
50 mkdir -p failed-test-artifacts
51 echo "::set-env name=FAILED_TEST_ARTIFACTS::t/failed-test-artifacts"
52 cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/
53 tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
57 echo "Unhandled CI type: $CI_TYPE" >&2
61 trash_tgz_b64="trash.$test_name.base64"
62 if [ -d "$trash_dir" ]
64 tar czp "$trash_dir" |base64 $base64_opts >"$trash_tgz_b64"
66 trash_size=$(wc -c <"$trash_tgz_b64")
67 if [ $trash_size -gt 1048576 ]
70 echo "$(tput setaf 1)Didn't include the trash directory of '$test_name' in the trace log, it's too big$(tput sgr0)"
74 new_combined_trash_size=$(($combined_trash_size + $trash_size))
75 if [ $new_combined_trash_size -gt 1048576 ]
77 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)"
80 combined_trash_size=$new_combined_trash_size
82 # DO NOT modify these two 'echo'-ed strings below
83 # without updating 'ci/util/extract-trash-dirs.sh'
85 echo "$(tput setaf 1)Start of trash directory of '$test_name':$(tput sgr0)"
87 echo "$(tput setaf 1)End of trash directory of '$test_name'$(tput sgr0)"
92 if [ $combined_trash_size -gt 0 ]
94 echo "------------------------------------------------------------------------"
95 echo "Trash directories embedded in this log can be extracted by running:"
97 echo " curl https://api.travis-ci.org/v3/job/$TRAVIS_JOB_ID/log.txt |./ci/util/extract-trash-dirs.sh"