diff options
author | Jeff King <peff@peff.net> | 2015-03-20 11:12:29 +0100 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-03-20 18:20:16 +0100 |
commit | 9ddc5ac97ecdd03ceda4b6e3ff20a7524a9f0f8d (patch) | |
tree | 534ebb6d622071a3e4f2bd393344e24012011480 /t/t5004-archive-corner-cases.sh | |
parent | t: use test_expect_code instead of hand-rolled comparison (diff) | |
download | git-9ddc5ac97ecdd03ceda4b6e3ff20a7524a9f0f8d.tar.xz git-9ddc5ac97ecdd03ceda4b6e3ff20a7524a9f0f8d.zip |
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/t5004-archive-corner-cases.sh')
-rwxr-xr-x | t/t5004-archive-corner-cases.sh | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/t/t5004-archive-corner-cases.sh b/t/t5004-archive-corner-cases.sh index 305bcac6b7..654addaae3 100755 --- a/t/t5004-archive-corner-cases.sh +++ b/t/t5004-archive-corner-cases.sh @@ -66,8 +66,10 @@ test_expect_success UNZIP 'zip archive of empty tree is empty' ' # handle the empty repo at all, making our later check of its exit code # a no-op). But we cannot do anything reasonable except skip the test # on such platforms anyway, and this is the moral equivalent. - "$GIT_UNZIP" "$TEST_DIRECTORY"/t5004/empty.zip - expect_code=$? + { + "$GIT_UNZIP" "$TEST_DIRECTORY"/t5004/empty.zip + expect_code=$? + } && git archive --format=zip HEAD >empty.zip && make_dir extract && |