diff mbox series

[1/8] ci/lib: support custom output directories when creating test artifacts

Message ID 20241211-pks-meson-ci-v1-1-28d18b494374@pks.im (mailing list archive)
State Superseded
Headers show
Series ci: wire up support for Meson | expand

Commit Message

Patrick Steinhardt Dec. 11, 2024, 10:52 a.m. UTC
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>
---
 ci/lib.sh | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

Comments

Karthik Nayak Dec. 12, 2024, 10:16 a.m. UTC | #1
Patrick Steinhardt <ps@pks.im> writes:

> 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.
>

So currently in the config: `TEST_OUTPUT_DIRECTORY: "/Volumes/RAMDisk"`.
So this is broken as is?

>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>
> ---
>  ci/lib.sh | 12 ++++++------
>  1 file changed, 6 insertions(+), 6 deletions(-)
>
> diff --git a/ci/lib.sh b/ci/lib.sh
> index 930f98d7228166c37c236beb062b14675fb68ef3..2e7a5f0540b66f24bd0f5744311c2c48b472d63d 100755
> --- a/ci/lib.sh
> +++ b/ci/lib.sh
> @@ -180,9 +180,9 @@ handle_failed_tests () {
>  }
>
>  create_failed_test_artifacts () {
> -	mkdir -p t/failed-test-artifacts
> +	mkdir -p "${TEST_OUTPUT_DIRECTORY:-t}"/failed-test-artifacts
>
> -	for test_exit in t/test-results/*.exit
> +	for test_exit in "${TEST_OUTPUT_DIRECTORY:-t}"/test-results/*.exit
>  	do
>  		test 0 != "$(cat "$test_exit")" || continue
>
> @@ -191,11 +191,11 @@ create_failed_test_artifacts () {
>  		printf "\\e[33m\\e[1m=== Failed test: ${test_name} ===\\e[m\\n"
>  		echo "The full logs are in the 'print test failures' step below."
>  		echo "See also the 'failed-tests-*' artifacts attached to this run."
> -		cat "t/test-results/$test_name.markup"
> +		cat "${TEST_OUTPUT_DIRECTORY:-t}/test-results/$test_name.markup"
>
> -		trash_dir="t/trash directory.$test_name"
> -		cp "t/test-results/$test_name.out" t/failed-test-artifacts/
> -		tar czf t/failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
> +		trash_dir="${TEST_OUTPUT_DIRECTORY:-t}/trash directory.$test_name"
> +		cp "${TEST_OUTPUT_DIRECTORY:-t}/test-results/$test_name.out" "${TEST_OUTPUT_DIRECTORY:-t}"/failed-test-artifacts/
> +		tar czf "${TEST_OUTPUT_DIRECTORY:-t}/failed-test-artifacts/$test_name.trash.tar.gz" "$trash_dir"
>  	done
>  }

The changes look good, if the TEST_OUTPUT_DIRECTORY isn't set we default
to `t` which was the previous directory.
Patrick Steinhardt Dec. 13, 2024, 5:24 a.m. UTC | #2
On Thu, Dec 12, 2024 at 02:16:30AM -0800, karthik nayak wrote:
> Patrick Steinhardt <ps@pks.im> writes:
> 
> > 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.
> >
> 
> So currently in the config: `TEST_OUTPUT_DIRECTORY: "/Volumes/RAMDisk"`.
> So this is broken as is?

Yeah. I've noticed multiple times that the test output directory is not
uploaded on failing macOS jobs.

Patrick
diff mbox series

Patch

diff --git a/ci/lib.sh b/ci/lib.sh
index 930f98d7228166c37c236beb062b14675fb68ef3..2e7a5f0540b66f24bd0f5744311c2c48b472d63d 100755
--- a/ci/lib.sh
+++ b/ci/lib.sh
@@ -180,9 +180,9 @@  handle_failed_tests () {
 }
 
 create_failed_test_artifacts () {
-	mkdir -p t/failed-test-artifacts
+	mkdir -p "${TEST_OUTPUT_DIRECTORY:-t}"/failed-test-artifacts
 
-	for test_exit in t/test-results/*.exit
+	for test_exit in "${TEST_OUTPUT_DIRECTORY:-t}"/test-results/*.exit
 	do
 		test 0 != "$(cat "$test_exit")" || continue
 
@@ -191,11 +191,11 @@  create_failed_test_artifacts () {
 		printf "\\e[33m\\e[1m=== Failed test: ${test_name} ===\\e[m\\n"
 		echo "The full logs are in the 'print test failures' step below."
 		echo "See also the 'failed-tests-*' artifacts attached to this run."
-		cat "t/test-results/$test_name.markup"
+		cat "${TEST_OUTPUT_DIRECTORY:-t}/test-results/$test_name.markup"
 
-		trash_dir="t/trash directory.$test_name"
-		cp "t/test-results/$test_name.out" t/failed-test-artifacts/
-		tar czf t/failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
+		trash_dir="${TEST_OUTPUT_DIRECTORY:-t}/trash directory.$test_name"
+		cp "${TEST_OUTPUT_DIRECTORY:-t}/test-results/$test_name.out" "${TEST_OUTPUT_DIRECTORY:-t}"/failed-test-artifacts/
+		tar czf "${TEST_OUTPUT_DIRECTORY:-t}/failed-test-artifacts/$test_name.trash.tar.gz" "$trash_dir"
 	done
 }