Skip to content

Commit 3383b74

Browse files
pks-tgitster
authored andcommitted
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 <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent 87e8fb1 commit 3383b74

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

t/test-lib-functions.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1195,8 +1195,9 @@ test_must_fail () {
11951195
echo >&7 "test_must_fail: only 'git' is allowed: $*"
11961196
return 1
11971197
fi
1198-
"$@" 2>&7
1199-
exit_code=$?
1198+
1199+
exit_code=0; "$@" 2>&7 || exit_code=$?
1200+
12001201
if test $exit_code -eq 0 && ! list_contains "$_test_ok" success
12011202
then
12021203
echo >&4 "test_must_fail: command succeeded: $*"

0 commit comments

Comments
 (0)