t: use test_might_fail() instead of manipulating exit code manually
These tests manually coerce the exit code of invoked commands to "success" when they don't care if the command succeeds or fails since failure of those commands should not cause the test to fail overall. In doing so, they intentionally break the &&-chain. Modernize by replacing manual exit code management with test_might_fail() and a normal &&-chain. Signed-off-by: Eric Sunshine <sunshine@sunshineco.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Sunshine committed
Jul 1, 2018 at 20:23 UTC
83279748594cf1c7a38ebf518cd6b63cd3d8de37
4 files changed
+8
-10
t/t1507-rev-parse-upstream.sh
+3
-3
@@ -123,9 +123,9 @@ test_expect_success 'checkout -b new my-side@{u} forks from the same' '
123
124
test_expect_success 'merge my-side@{u} records the correct name' '
125
(
126
- cd clone || exit
127
- git checkout master || exit
128
- git branch -D new ;# can fail but is ok
126
+ cd clone &&
127
+ git checkout master &&
128
+ test_might_fail git branch -D new &&
129
git branch -t new my-side@{u} &&
130
git merge -s ours new@{u} &&
131
git show -s --pretty=tformat:%s >actual &&
t/t1700-split-index.sh
+1
-1
@@ -435,7 +435,7 @@ test_expect_success 'writing split index with null sha1 does not write cache tre
435
commit=$(git commit-tree $tree -p HEAD <msg) &&
436
git update-ref HEAD "$commit" &&
437
GIT_ALLOW_NULL_SHA1=1 git reset --hard &&
438
- (test-tool dump-cache-tree >cache-tree.out || true) &&
438
+ test_might_fail test-tool dump-cache-tree >cache-tree.out &&
439
test_line_count = 0 cache-tree.out
440
'
441
t/t4012-diff-binary.sh
+2
-4
@@ -102,10 +102,8 @@ test_expect_success 'apply binary patch' '
102
103
test_expect_success 'diff --no-index with binary creation' '
104
echo Q | q_to_nul >binary &&
105
- (: hide error code from diff, which just indicates differences
106
- git diff --binary --no-index /dev/null binary >current ||
107
- true
108
- ) &&
105
+ # hide error code from diff, which just indicates differences
106
+ test_might_fail git diff --binary --no-index /dev/null binary >current &&
107
rm binary &&
108
git apply --binary <current &&
109
echo Q >expected &&
t/t5400-send-pack.sh
+2
-2
@@ -86,7 +86,7 @@ test_expect_success 'push can be used to delete a ref' '
86
test_expect_success 'refuse deleting push with denyDeletes' '
87
(
88
cd victim &&
89
- ( git branch -D extra || : ) &&
89
+ test_might_fail git branch -D extra &&
90
git config receive.denyDeletes true &&
91
git branch extra master
92
) &&
@@ -119,7 +119,7 @@ test_expect_success 'override denyDeletes with git -c receive-pack' '
119
test_expect_success 'denyNonFastforwards trumps --force' '
120
(
121
cd victim &&
122
- ( git branch -D extra || : ) &&
122
+ test_might_fail git branch -D extra &&
123
git config receive.denyNonFastforwards true
124
) &&
125
victim_orig=$(cd victim && git rev-parse --verify master) &&