From 0af3adfcb1998701eaa7c8e695a745ede98056a0 Mon Sep 17 00:00:00 2001 From: Todd Zullinger Date: Fri, 2 Dec 2022 23:12:17 -0500 Subject: [PATCH] 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. ;) --- git.spec | 3 ++- print-failed-test-output | 13 +++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/git.spec b/git.spec index cc7f53c..4c7d9bf 100644 --- a/git.spec +++ b/git.spec @@ -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 diff --git a/print-failed-test-output b/print-failed-test-output index d0d63aa..4e65662 100644 --- a/print-failed-test-output +++ b/print-failed-test-output @@ -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