summaryrefslogtreecommitdiff
path: root/t/t4026-color.sh
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2015-03-20 10:12:29 (GMT)
committerJunio C Hamano <gitster@pobox.com>2015-03-20 17:20:16 (GMT)
commit9ddc5ac97ecdd03ceda4b6e3ff20a7524a9f0f8d (patch)
tree534ebb6d622071a3e4f2bd393344e24012011480 /t/t4026-color.sh
parentc21fc9d0ab217d6e3cf01ee895e827b72d8207b6 (diff)
downloadgit-9ddc5ac97ecdd03ceda4b6e3ff20a7524a9f0f8d.zip
git-9ddc5ac97ecdd03ceda4b6e3ff20a7524a9f0f8d.tar.gz
git-9ddc5ac97ecdd03ceda4b6e3ff20a7524a9f0f8d.tar.bz2
t: wrap complicated expect_code users in a block
If we are expecting a command to produce a particular exit code, we can use test_expect_code. However, some cases are more complicated, and want to accept one of a range of exit codes. For these, we end up with something like: cmd; case "$?" in ... That unfortunately breaks the &&-chain and fools --chain-lint. Since these special cases are so few, we can wrap them in a block, like this: { cmd; ret=$?; } && case "$ret" in ... This accomplishes the same thing, and retains the &&-chain (the exit status fed to the && is that of the assignment, which should always be true). It's technically longer, but it is probably a good thing for unusual code like this to stand out. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4026-color.sh')
-rwxr-xr-xt/t4026-color.sh6
1 files changed, 3 insertions, 3 deletions
diff --git a/t/t4026-color.sh b/t/t4026-color.sh
index 4d20fea..2b32c4f 100755
--- a/t/t4026-color.sh
+++ b/t/t4026-color.sh
@@ -111,9 +111,9 @@ test_expect_success 'unknown color slots are ignored (branch)' '
'
test_expect_success 'unknown color slots are ignored (status)' '
- git config color.status.nosuchslotwilleverbedefined white || exit
- git status
- case $? in 0|1) : ok ;; *) false ;; esac
+ git config color.status.nosuchslotwilleverbedefined white &&
+ { git status; ret=$?; } &&
+ case $ret in 0|1) : ok ;; *) false ;; esac
'
test_done