t: fix &&-chaining issues around setup which might fail

Many tests have an initial setup step that might fail based on whether earlier tests in the script have succeeded or not. Using a trick like "|| true" breaks the &&-chain, missing earlier failures (and fooling --chain-lint). We can use test_might_fail in some cases, which is correct and makes the intent more obvious. We can also use test_unconfig for unsetting config (and which is more robust, as well). The case in t9500 is an oddball. It wants to run cmd1 _or_ cmd2, and does it like: cmd1 || cmd2 && other_stuff It's not wrong in this case, but it's a bad habit to get into, because it breaks the &&-chain if used anywhere except at the beginning of the test (and we use the correct solution here, putting it inside a block for precedence). Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Mar 20, 2015 at 06:10 UTC a6a4a88af0b99fec688f66256a2c23a15e110c1f
5 files changed +11 -8
t/t5503-tagfollow.sh
+2 -2
@@ -139,8 +139,8 @@ EOF
139 '
140
141 test_expect_success 'new clone fetch master and tags' '
142 - git branch -D cat
143 - rm -f $U
142 + test_might_fail git branch -D cat &&
143 + rm -f $U &&
144 (
145 mkdir clone2 &&
146 cd clone2 &&
t/t6032-merge-large-rename.sh
+3 -3
@@ -28,10 +28,10 @@ make_text() {
28
29 test_rename() {
30 test_expect_success "rename ($1, $2)" '
31 - n='$1'
32 - expect='$2'
31 + n='$1' &&
32 + expect='$2' &&
33 git checkout -f master &&
34 - git branch -D test$n || true &&
34 + test_might_fail git branch -D test$n &&
35 git reset --hard initial &&
36 for i in $(count $n); do
37 make_text $i initial initial >$i
t/t7201-co.sh
+1 -1
@@ -591,7 +591,7 @@ test_expect_success 'checkout --conflict=merge, overriding config' '
591 '
592
593 test_expect_success 'checkout --conflict=diff3' '
594 - git config --unset merge.conflictstyle
594 + test_unconfig merge.conflictstyle &&
595 setup_conflicting_index &&
596 echo "none of the above" >sample &&
597 echo ourside >expect &&
t/t7508-status.sh
+1 -1
@@ -538,7 +538,7 @@ A dir2/added
538 ?? untracked
539 EOF
540 test_expect_success 'status -s -uall' '
541 - git config --unset status.showuntrackedfiles
541 + test_unconfig status.showuntrackedfiles &&
542 git status -s -uall >output &&
543 test_cmp expect output
544 '
t/t9500-gitweb-standalone-no-errors.sh
+4 -1
@@ -779,7 +779,10 @@ test_expect_success \
779
780 test_expect_success \
781 'unborn HEAD: "summary" page (with "heads" subview)' \
782 - 'git checkout orphan_branch || git checkout --orphan orphan_branch &&
782 + '{
783 + git checkout orphan_branch ||
784 + git checkout --orphan orphan_branch
785 + } &&
786 test_when_finished "git checkout master" &&
787 gitweb_run "p=.git;a=summary"'
788