From 428a1c7f3e67dd5b190f3077d8f50945a822c7a2 Mon Sep 17 00:00:00 2001 From: Jan Range Date: Thu, 28 Dec 2023 22:29:08 +0100 Subject: [PATCH] pretty printing and logging --- run-tests.sh | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/run-tests.sh b/run-tests.sh index 57697f7..8ea6c23 100644 --- a/run-tests.sh +++ b/run-tests.sh @@ -58,9 +58,20 @@ while [ -n "$(docker ps -f "name=unit-tests" -f "status=running" -q)" ]; do sleep 5 done -# Print logs of "unit-tests" container -docker logs unit-tests +# Check if "unit-test" container has failed +if [ "$(docker inspect -f '{{.State.ExitCode}}' unit-tests)" -ne 0 ]; then + printf "\nāŒ Unit tests failed. Printing logs...\n" + docker logs unit-tests + printf "\n Stopping containers\n" + docker compose -f ./docker-compose-test.yml --env-file local-test.env down + exit 1 +fi + +# Print test results +printf "\n" +cat dv/unit-tests.log +printf "\n\nāœ… Unit tests passed\n\n" # Stop all containers docker compose -f ./docker-compose-test.yml --env-file local-test.env down -printf "\nāœ… Done\n\n" +printf "\nšŸŽ‰ Done\n\n"