1#!/bin/sh 2# 3# Print output of failing tests 4# 5 6. ${0%/*}/lib.sh 7 8# Tracing executed commands would produce too much noise in the loop below. 9set+x 10 11cd t/ 12 13if!lstest-results/*.exit>/dev/null 2>/dev/null 14then 15echo"Build job failed before the tests could have been run" 16exit 17fi 18 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 intest-results/*.exit 29do 30if["$(cat "$TEST_EXIT")"!="0"] 31then 32 TEST_OUT="${TEST_EXIT%exit}out" 33echo"------------------------------------------------------------------------" 34echo"$(tput setaf 1)${TEST_OUT}...$(tput sgr0)" 35echo"------------------------------------------------------------------------" 36cat"${TEST_OUT}" 37 38 test_name="${TEST_EXIT%.exit}" 39 test_name="${test_name##*/}" 40 trash_dir="trash directory.$test_name" 41 trash_tgz_b64="trash.$test_name.base64" 42if[-d"$trash_dir"] 43then 44tar czp "$trash_dir"|base64 $base64_opts>"$trash_tgz_b64" 45 46 trash_size=$(wc -c <"$trash_tgz_b64") 47if[$trash_size-gt1048576] 48then 49# larger than 1MB 50echo"$(tput setaf 1)Didn't include the trash directory of '$test_name' in the trace log, it's too big$(tput sgr0)" 51continue 52fi 53 54 new_combined_trash_size=$(($combined_trash_size + $trash_size)) 55if[$new_combined_trash_size-gt1048576] 56then 57echo"$(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)" 58continue 59fi 60 combined_trash_size=$new_combined_trash_size 61 62# DO NOT modify these two 'echo'-ed strings below 63# 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)" 68fi 69fi 70done 71 72if[$combined_trash_size-gt0] 73then 74echo"------------------------------------------------------------------------" 75echo"Trash directories embedded in this log can be extracted by running:" 76echo 77echo" curl https://api.travis-ci.org/v3/job/$TRAVIS_JOB_ID/log.txt |./ci/util/extract-trash-dirs.sh" 78fi