Skip to content

Commit 6be44b5

Browse files
committed
Merge branch 'sg/travis-retrieve-trash-upon-failure'
The Travis CI scripts were taught to ship back the test data from failed tests. * sg/travis-retrieve-trash-upon-failure: travis-ci: include the trash directories of failed tests in the trace log
2 parents 11ea82a + aea8879 commit 6be44b5

File tree

3 files changed

+104
-3
lines changed

3 files changed

+104
-3
lines changed

ci/lib-travisci.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ fi
9797
export DEVELOPER=1
9898
export DEFAULT_TEST_TARGET=prove
9999
export GIT_PROVE_OPTS="--timer --jobs 3 --state=failed,slow,save"
100-
export GIT_TEST_OPTS="--verbose-log -x"
100+
export GIT_TEST_OPTS="--verbose-log -x --immediate"
101101
export GIT_TEST_CLONE_2GB=YesPlease
102102
if [ "$jobname" = linux-gcc ]; then
103103
export CC=gcc-8

ci/print-test-failures.sh

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,24 @@
88
# Tracing executed commands would produce too much noise in the loop below.
99
set +x
1010

11-
if ! ls t/test-results/*.exit >/dev/null 2>/dev/null
11+
cd t/
12+
13+
if ! ls test-results/*.exit >/dev/null 2>/dev/null
1214
then
1315
echo "Build job failed before the tests could have been run"
1416
exit
1517
fi
1618

17-
for TEST_EXIT in t/test-results/*.exit
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
1829
do
1930
if [ "$(cat "$TEST_EXIT")" != "0" ]
2031
then
@@ -23,5 +34,45 @@ do
2334
echo "$(tput setaf 1)${TEST_OUT}...$(tput sgr0)"
2435
echo "------------------------------------------------------------------------"
2536
cat "${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"
42+
if [ -d "$trash_dir" ]
43+
then
44+
tar czp "$trash_dir" |base64 $base64_opts >"$trash_tgz_b64"
45+
46+
trash_size=$(wc -c <"$trash_tgz_b64")
47+
if [ $trash_size -gt 1048576 ]
48+
then
49+
# larger than 1MB
50+
echo "$(tput setaf 1)Didn't include the trash directory of '$test_name' in the trace log, it's too big$(tput sgr0)"
51+
continue
52+
fi
53+
54+
new_combined_trash_size=$(($combined_trash_size + $trash_size))
55+
if [ $new_combined_trash_size -gt 1048576 ]
56+
then
57+
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)"
58+
continue
59+
fi
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.
65+
echo "$(tput setaf 1)Start of trash directory of '$test_name':$(tput sgr0)"
66+
cat "$trash_tgz_b64"
67+
echo "$(tput setaf 1)End of trash directory of '$test_name'$(tput sgr0)"
68+
fi
2669
fi
2770
done
71+
72+
if [ $combined_trash_size -gt 0 ]
73+
then
74+
echo "------------------------------------------------------------------------"
75+
echo "Trash directories embedded in this log can be extracted by running:"
76+
echo
77+
echo " curl https://api.travis-ci.org/v3/job/$TRAVIS_JOB_ID/log.txt |./ci/util/extract-trash-dirs.sh"
78+
fi

ci/util/extract-trash-dirs.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/sh
2+
3+
error () {
4+
echo >&2 "error: $@"
5+
exit 1
6+
}
7+
8+
find_embedded_trash () {
9+
while read -r line
10+
do
11+
case "$line" in
12+
*Start\ of\ trash\ directory\ of\ \'t[0-9][0-9][0-9][0-9]-*\':*)
13+
test_name="${line#*\'}"
14+
test_name="${test_name%\'*}"
15+
16+
return 0
17+
esac
18+
done
19+
20+
return 1
21+
}
22+
23+
extract_embedded_trash () {
24+
while read -r line
25+
do
26+
case "$line" in
27+
*End\ of\ trash\ directory\ of\ \'$test_name\'*)
28+
return
29+
;;
30+
*)
31+
printf '%s\n' "$line"
32+
;;
33+
esac
34+
done
35+
36+
error "unexpected end of input"
37+
}
38+
39+
# Raw logs from Linux build jobs have CRLF line endings, while OSX
40+
# build jobs mostly have CRCRLF, except an odd line every now and
41+
# then that has CRCRCRLF. 'base64 -d' from 'coreutils' doesn't like
42+
# CRs and complains about "invalid input", so remove all CRs at the
43+
# end of lines.
44+
sed -e 's/\r*$//' | \
45+
while find_embedded_trash
46+
do
47+
echo "Extracting trash directory of '$test_name'"
48+
49+
extract_embedded_trash |base64 -d |tar xzp
50+
done

0 commit comments

Comments
 (0)