From: Patrick Steinhardt Date: Tue, 21 Apr 2026 07:34:15 +0000 (+0200) Subject: t: prepare `test_must_fail ()` for `set -e` X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=990fd368ac7fcb56f69a27ba341cac10f04e285b;p=thirdparty%2Fgit.git t: prepare `test_must_fail ()` for `set -e` The helper function `test_must_fail ()` executes a specific Git command that may or may not fail in a specific way. This is done by executing the command in question and then comparing its exit code against a set of conditions. This works, but once we run our test suite with `set -e` we may bail out of `test_must_fail ()` early in case the command actually fails, even though we expect it to fail. Prepare for this change by handling the failed case with `||`. Signed-off-by: Patrick Steinhardt Signed-off-by: Junio C Hamano --- diff --git a/t/test-lib-functions.sh b/t/test-lib-functions.sh index f3af10fb7e..5fd5494ef1 100644 --- a/t/test-lib-functions.sh +++ b/t/test-lib-functions.sh @@ -1195,8 +1195,9 @@ test_must_fail () { echo >&7 "test_must_fail: only 'git' is allowed: $*" return 1 fi - "$@" 2>&7 - exit_code=$? + + exit_code=0; "$@" 2>&7 || exit_code=$? + if test $exit_code -eq 0 && ! list_contains "$_test_ok" success then echo >&4 "test_must_fail: command succeeded: $*"