Skip to content

Commit a6a4a88

Browse files
peffgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0a5e3c5 commit a6a4a88

5 files changed

+11
-8
lines changed

t/t5503-tagfollow.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,8 @@ EOF
139139
'
140140

141141
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 &&
144144
(
145145
mkdir clone2 &&
146146
cd clone2 &&

t/t6032-merge-large-rename.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ make_text() {
2828

2929
test_rename() {
3030
test_expect_success "rename ($1, $2)" '
31-
n='$1'
32-
expect='$2'
31+
n='$1' &&
32+
expect='$2' &&
3333
git checkout -f master &&
34-
git branch -D test$n || true &&
34+
test_might_fail git branch -D test$n &&
3535
git reset --hard initial &&
3636
for i in $(count $n); do
3737
make_text $i initial initial >$i

t/t7201-co.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -591,7 +591,7 @@ test_expect_success 'checkout --conflict=merge, overriding config' '
591591
'
592592

593593
test_expect_success 'checkout --conflict=diff3' '
594-
git config --unset merge.conflictstyle
594+
test_unconfig merge.conflictstyle &&
595595
setup_conflicting_index &&
596596
echo "none of the above" >sample &&
597597
echo ourside >expect &&

t/t7508-status.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -538,7 +538,7 @@ A dir2/added
538538
?? untracked
539539
EOF
540540
test_expect_success 'status -s -uall' '
541-
git config --unset status.showuntrackedfiles
541+
test_unconfig status.showuntrackedfiles &&
542542
git status -s -uall >output &&
543543
test_cmp expect output
544544
'

t/t9500-gitweb-standalone-no-errors.sh

+4-1
Original file line numberDiff line numberDiff line change
@@ -779,7 +779,10 @@ test_expect_success \
779779

780780
test_expect_success \
781781
'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+
} &&
783786
test_when_finished "git checkout master" &&
784787
gitweb_run "p=.git;a=summary"'
785788

0 commit comments

Comments
 (0)