ci/lib: support custom output directories when creating test artifacts

Update `create_failed_test_artifacts ()` so that it can handle arbitrary test output directories. This fixes creation of these artifacts for macOS on GitLab CI, which uses a separate output directory already. This will also be used by our out-of-tree builds with Meson. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Patrick Steinhardt committed Dec 13, 2024 at 11:41 UTC 714c134dd6f29d23b46cb85cd8bd82a2ce894c65
1 file changed +6 -6
ci/lib.sh
+6 -6
@@ -180,9 +180,9 @@ handle_failed_tests () {
180 }
181
182 create_failed_test_artifacts () {
183 - mkdir -p t/failed-test-artifacts
183 + mkdir -p "${TEST_OUTPUT_DIRECTORY:-t}"/failed-test-artifacts
184
185 - for test_exit in t/test-results/*.exit
185 + for test_exit in "${TEST_OUTPUT_DIRECTORY:-t}"/test-results/*.exit
186 do
187 test 0 != "$(cat "$test_exit")" || continue
188
@@ -191,11 +191,11 @@ create_failed_test_artifacts () {
191 printf "\\e[33m\\e[1m=== Failed test: ${test_name} ===\\e[m\\n"
192 echo "The full logs are in the 'print test failures' step below."
193 echo "See also the 'failed-tests-*' artifacts attached to this run."
194 - cat "t/test-results/$test_name.markup"
194 + cat "${TEST_OUTPUT_DIRECTORY:-t}/test-results/$test_name.markup"
195
196 - trash_dir="t/trash directory.$test_name"
197 - cp "t/test-results/$test_name.out" t/failed-test-artifacts/
198 - tar czf t/failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
196 + trash_dir="${TEST_OUTPUT_DIRECTORY:-t}/trash directory.$test_name"
197 + cp "${TEST_OUTPUT_DIRECTORY:-t}/test-results/$test_name.out" "${TEST_OUTPUT_DIRECTORY:-t}"/failed-test-artifacts/
198 + tar czf "${TEST_OUTPUT_DIRECTORY:-t}/failed-test-artifacts/$test_name.trash.tar.gz" "$trash_dir"
199 done
200 }
201