From 18ce6a97291d282be67fcf356323d97c4d37d1e8 Mon Sep 17 00:00:00 2001 From: Bartosz Majsak Date: Fri, 17 Sep 2021 13:21:01 +0200 Subject: [PATCH] fix: propagates test script error code correctly --- upstream/test/test.sh | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/upstream/test/test.sh b/upstream/test/test.sh index 2b2e1249e..58dbfafa9 100755 --- a/upstream/test/test.sh +++ b/upstream/test/test.sh @@ -138,17 +138,20 @@ function run() { echo "#${v#*--}" set -o pipefail "$@" | tee -a $OP_TEST_LOG_DIR/log.out - [[ $? -eq 0 ]] || { echo -e "\nFailed with rc=$? !!!\nLogs are in '$OP_TEST_LOG_DIR/log.out'."; exit $?; } + exit_code=$? + if [ $exit_code -ne 0 ]; then echo -e "\nFailed with rc=$exit_code !!!\nLogs are in '$OP_TEST_LOG_DIR/log.out'."; exit $exit_code; fi set +o pipefail elif [[ $OP_TEST_DEBUG -ge 1 ]] ; then set -o pipefail "$@" | tee -a $OP_TEST_LOG_DIR/log.out - [[ $? -eq 0 ]] || { echo -e "\nFailed with rc=$? !!!\nLogs are in '$OP_TEST_LOG_DIR/log.out'."; exit $?; } + exit_code=$? + if [ $exit_code -ne 0 ]; then echo -e "\nFailed with rc=$exit_code !!!\nLogs are in '$OP_TEST_LOG_DIR/log.out'."; exit $exit_code; fi set +o pipefail else set -o pipefail "$@" | tee -a $OP_TEST_LOG_DIR/log.out >/dev/null 2>&1 - [[ $? -eq 0 ]] || { echo -e "\nFailed with rc=$? !!!\nLogs are in '$OP_TEST_LOG_DIR/log.out'."; exit $?; } + exit_code=$? + if [ $exit_code -ne 0 ]; then echo -e "\nFailed with rc=$exit_code !!!\nLogs are in '$OP_TEST_LOG_DIR/log.out'."; exit $exit_code; fi set +o pipefail fi }