include test-results & "trash" directory contents in build output

When a build fails, the contents of t/test-results and the trash
directories can be quite useful for debugging.  This is particularly
true when the failures occur only in Koji, where we can't get a shell
and poke around.

Create a compressed tarball and encode it with base64 to allow it to be
output along with the normal build output.  Include instruction on how
to extract the base64-encoded content from the build log inline.

The tar archive is compressed with zstd which provides a good balance of
speed and size.  The compression level of 17 was chosen after a number
of tests against real test failures, as opposed to entirely random
selection. ;)
This commit is contained in:
Todd Zullinger 2022-12-02 23:12:17 -05:00
parent 13887794b7
commit 0af3adfcb1
2 changed files with 15 additions and 1 deletions

View File

@ -257,6 +257,7 @@ BuildRequires: subversion-perl
BuildRequires: tar
BuildRequires: time
BuildRequires: zip
BuildRequires: zstd
%endif
# endif with tests
@ -864,7 +865,7 @@ export GIT_TEST_SVN_HTTPD=true
# Create tmpdir for test output and update GIT_TEST_OPTS
# Also update GIT-BUILD-OPTIONS to keep make from any needless rebuilding
testdir=$(mktemp -d -p /tmp git-t.XXXX)
export testdir=$(mktemp -d -p /tmp git-t.XXXX)
sed -i "s@^GIT_TEST_OPTS = .*@& --root=$testdir@" config.mak
touch -r GIT-BUILD-OPTIONS ts
sed -i "s@\(GIT_TEST_OPTS='.*\)'@\1 --root=$testdir'@" GIT-BUILD-OPTIONS

View File

@ -10,4 +10,17 @@ for exit_file in t/test-results/*.exit; do
printf '\n%s\n%s\n%s\n' "$sep" "$out_file" "$sep"
cat "$out_file"
done
# tar up test-results & $testdir, then print base64 encoded output
#
# copy $testdir contents to test-results to avoid absolute paths with tar
cp -a $testdir/* t/test-results/
begin='-----BEGIN BASE64 MESSAGE-----'
end='-----END BASE64 MESSAGE-----'
printf '\n%s\n' 'test-results and trash directory output follows; decode via:'
printf '%s\n' "sed -n '/^${begin}$/,/^${end}$/{/^${begin}$/!{/^${end}$/!p}}' build.log | base64 -d >output.tar.zst"
printf '%s\n' "$begin"
tar -C t -cf - test-results/ | zstdmt -17 | base64
printf '%s\n' "$end"
exit 1