1#!/bin/sh2#3# Print output of failing tests4#56. ${0%/*}/lib-travisci.sh78# Tracing executed commands would produce too much noise in the loop below.9set +x1011cd t/1213if ! ls test-results/*.exit >/dev/null 2>/dev/null14then15echo "Build job failed before the tests could have been run"16exit17fi1819case "$jobname" in20osx-clang|osx-gcc)21# base64 in OSX doesn't wrap its output at 76 columns by22# default, but prints a single, very long line.23base64_opts="-b 76"24;;25esac2627combined_trash_size=028for TEST_EXIT in test-results/*.exit29do30if [ "$(cat "$TEST_EXIT")" != "0" ]31then32TEST_OUT="${TEST_EXIT%exit}out"33echo "------------------------------------------------------------------------"34echo "$(tput setaf 1)${TEST_OUT}...$(tput sgr0)"35echo "------------------------------------------------------------------------"36cat "${TEST_OUT}"3738test_name="${TEST_EXIT%.exit}"39test_name="${test_name##*/}"40trash_dir="trash directory.$test_name"41trash_tgz_b64="trash.$test_name.base64"42if [ -d "$trash_dir" ]43then44tar czp "$trash_dir" |base64 $base64_opts >"$trash_tgz_b64"4546trash_size=$(wc -c <"$trash_tgz_b64")47if [ $trash_size -gt 1048576 ]48then49# larger than 1MB50echo "$(tput setaf 1)Didn't include the trash directory of '$test_name' in the trace log, it's too big$(tput sgr0)"51continue52fi5354new_combined_trash_size=$(($combined_trash_size + $trash_size))55if [ $new_combined_trash_size -gt 1048576 ]56then57echo "$(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)"58continue59fi60combined_trash_size=$new_combined_trash_size6162# DO NOT modify these two 'echo'-ed strings below63# without updating 'ci/util/extract-trash-dirs.sh'64# as well.65echo "$(tput setaf 1)Start of trash directory of '$test_name':$(tput sgr0)"66cat "$trash_tgz_b64"67echo "$(tput setaf 1)End of trash directory of '$test_name'$(tput sgr0)"68fi69fi70done7172if [ $combined_trash_size -gt 0 ]73then74echo "------------------------------------------------------------------------"75echo "Trash directories embedded in this log can be extracted by running:"76echo77echo " curl https://api.travis-ci.org/v3/job/$TRAVIS_JOB_ID/log.txt |./ci/util/extract-trash-dirs.sh"78fi