]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: use test_might_fail() instead of manipulating exit code manually
authorEric Sunshine <sunshine@sunshineco.com>
Mon, 2 Jul 2018 00:23:41 +0000 (20:23 -0400)
committerJunio C Hamano <gitster@pobox.com>
Tue, 3 Jul 2018 19:38:04 +0000 (12:38 -0700)
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>
t/t1507-rev-parse-upstream.sh
t/t1700-split-index.sh
t/t4012-diff-binary.sh
t/t5400-send-pack.sh

index 93c77eac45321cb24823431c4d89dc393049edbf..349f6e10af9ea64a0e874b863f784feab4d12386 100755 (executable)
@@ -123,9 +123,9 @@ test_expect_success 'checkout -b new my-side@{u} forks from the same' '
 
 test_expect_success 'merge my-side@{u} records the correct name' '
 (
-       cd clone || exit
-       git checkout master || exit
-       git branch -D new ;# can fail but is ok
+       cd clone &&
+       git checkout master &&
+       test_might_fail git branch -D new &&
        git branch -t new my-side@{u} &&
        git merge -s ours new@{u} &&
        git show -s --pretty=tformat:%s >actual &&
index 1e81b33b2e3a23a135c9b9440787a6e0c0deaa22..39133bcbc85239183c3d73596f76f0486aeefcfe 100755 (executable)
@@ -435,7 +435,7 @@ test_expect_success 'writing split index with null sha1 does not write cache tre
        commit=$(git commit-tree $tree -p HEAD <msg) &&
        git update-ref HEAD "$commit" &&
        GIT_ALLOW_NULL_SHA1=1 git reset --hard &&
-       (test-tool dump-cache-tree >cache-tree.out || true) &&
+       test_might_fail test-tool dump-cache-tree >cache-tree.out &&
        test_line_count = 0 cache-tree.out
 '
 
index 0a8af76aabf5ad79193341d1ffd4be4c9d4cb7a6..6579c81216a9b2e7dc6f2457cc46003dd905aa30 100755 (executable)
@@ -102,10 +102,8 @@ test_expect_success 'apply binary patch' '
 
 test_expect_success 'diff --no-index with binary creation' '
        echo Q | q_to_nul >binary &&
-       (: hide error code from diff, which just indicates differences
-        git diff --binary --no-index /dev/null binary >current ||
-        true
-       ) &&
+       # hide error code from diff, which just indicates differences
+       test_might_fail git diff --binary --no-index /dev/null binary >current &&
        rm binary &&
        git apply --binary <current &&
        echo Q >expected &&
index 911eae1bf7518485ace0fbd417e3ea0bbb18a9cf..f1932ea431dca6d5aa2ad71575b7767413eeac18 100755 (executable)
@@ -86,7 +86,7 @@ test_expect_success 'push can be used to delete a ref' '
 test_expect_success 'refuse deleting push with denyDeletes' '
        (
            cd victim &&
-           ( git branch -D extra || : ) &&
+           test_might_fail git branch -D extra &&
            git config receive.denyDeletes true &&
            git branch extra master
        ) &&
@@ -119,7 +119,7 @@ test_expect_success 'override denyDeletes with git -c receive-pack' '
 test_expect_success 'denyNonFastforwards trumps --force' '
        (
            cd victim &&
-           ( git branch -D extra || : ) &&
+           test_might_fail git branch -D extra &&
            git config receive.denyNonFastforwards true
        ) &&
        victim_orig=$(cd victim && git rev-parse --verify master) &&