[RFC PATCH v5 02/10] CI: add --exit-code to ci/print-test-failures.sh
- From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
- Date
- Apr 21, 2022, 18:36 UTC
- Message-ID
- <RFC-patch-v5-02.10-caec0b1089a-20220421T183001Z-avarab@gmail.com>
- In-Reply-To
- <RFC-cover-v5-00.10-00000000000-20220421T183001Z-avarab@gmail.com>
The ci/print-test-failures.sh scripts will exit 0 when there's failed tests, let's teach it --exit-code to have it exit non-zero in those cases.
Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com> --- ci/print-test-failures.sh | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+)
diff --git a/ci/print-test-failures.sh b/ci/print-test-failures.sh index f6736f424e0..d00cd0e4944 100755 --- a/ci/print-test-failures.sh +++ b/ci/print-test-failures.sh @@ -8,16 +8,33 @@ set -e . ${0%/*}/lib-ci-type.sh . ${0%/*}/lib-tput.sh +exit_code= +while test $# != 0 +do + case "$1" in + --exit-code) + exit_code=t + ;; + *) + echo "BUG: invalid $0 argument: $1" >&2 + exit 1 + ;; + esac + shift +done + if ! ls t/test-results/*.exit >/dev/null 2>/dev/null then echo "Build job failed before the tests could have been run" exit fi +failed= for TEST_EXIT in t/test-results/*.exit do if [ "$(cat "$TEST_EXIT")" != "0" ] then + failed=t TEST_NAME="${TEST_EXIT%.exit}" TEST_NAME="${TEST_NAME##*/}" TEST_OUT="${TEST_NAME}.out" @@ -42,3 +59,11 @@ do esac fi done + +if test -n "$failed" +then + if test -n "$exit_code" + then + exit 1 + fi +fi
-- 2.36.0.879.g3659959fcca