tests: apply modern idiom for signaling test failure

Simplify the way these tests signal failure by employing the modern
idiom of making the `if` or `case` statement resolve to false when an
error is detected.

Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
Reviewed-by: Elijah Newren <newren@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Eric Sunshine 2021-12-09 00:11:09 -05:00 committed by Junio C Hamano
parent 7abcbcb7ea
commit 77b1d9f355
3 changed files with 6 additions and 6 deletions

View file

@ -25,7 +25,7 @@ test_expect_success \
'the index entry must still be a symbolic link' ' 'the index entry must still be a symbolic link' '
case "$(git ls-files --stage --cached symlink)" in case "$(git ls-files --stage --cached symlink)" in
120000" "*symlink) echo pass;; 120000" "*symlink) echo pass;;
*) echo fail; git ls-files --stage --cached symlink; (exit 1);; *) echo fail; git ls-files --stage --cached symlink; false;;
esac' esac'
test_done test_done

View file

@ -68,7 +68,7 @@ test_expect_success 'merge and rebase should match' '
if test -s difference if test -s difference
then then
cat difference cat difference
(exit 1) false
else else
echo happy echo happy
fi fi
@ -102,7 +102,7 @@ test_expect_success 'merge and rebase should match' '
if test -s difference if test -s difference
then then
cat difference cat difference
(exit 1) false
else else
echo happy echo happy
fi fi
@ -117,7 +117,7 @@ test_expect_success 'picking rebase' '
echo happy echo happy
else else
git show-branch git show-branch
(exit 1) false
fi && fi &&
f=$(git diff-tree --name-only HEAD^ HEAD) && f=$(git diff-tree --name-only HEAD^ HEAD) &&
g=$(git diff-tree --name-only HEAD^^ HEAD^) && g=$(git diff-tree --name-only HEAD^^ HEAD^) &&
@ -127,7 +127,7 @@ test_expect_success 'picking rebase' '
*) *)
echo "$f" echo "$f"
echo "$g" echo "$g"
(exit 1) false
esac esac
' '

View file

@ -177,7 +177,7 @@ test_expect_success 'git add --refresh' '
git read-tree HEAD && git read-tree HEAD &&
case "$(git diff-index HEAD -- foo)" in case "$(git diff-index HEAD -- foo)" in
:100644" "*"M foo") echo pass;; :100644" "*"M foo") echo pass;;
*) echo fail; (exit 1);; *) echo fail; false;;
esac && esac &&
git add --refresh -- foo && git add --refresh -- foo &&
test -z "$(git diff-index HEAD -- foo)" test -z "$(git diff-index HEAD -- foo)"