Skip to content

Commit

Permalink
t4117: use modern test_* helpers
Browse files Browse the repository at this point in the history
We can use test_must_fail and test_path_* to avoid some
hand-rolled if statements. This makes the code shorter, and
makes it more obvious when we are breaking the &&-chain.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Mar 20, 2015
1 parent 2f69de5 commit e7d053d
Showing 1 changed file with 10 additions and 56 deletions.
66 changes: 10 additions & 56 deletions t/t4117-apply-reject.sh
Original file line number Diff line number Diff line change
Expand Up @@ -56,23 +56,13 @@ test_expect_success 'apply --reject is incompatible with --3way' '

test_expect_success 'apply without --reject should fail' '
if git apply patch.1
then
echo "Eh? Why?"
exit 1
fi
test_must_fail git apply patch.1 &&
test_cmp file1 saved.file1
'

test_expect_success 'apply without --reject should fail' '
if git apply --verbose patch.1
then
echo "Eh? Why?"
exit 1
fi
test_must_fail git apply --verbose patch.1 &&
test_cmp file1 saved.file1
'

Expand All @@ -81,47 +71,24 @@ test_expect_success 'apply with --reject should fail but update the file' '
cat saved.file1 >file1 &&
rm -f file1.rej file2.rej &&
if git apply --reject patch.1
then
echo "succeeds with --reject?"
exit 1
fi
test_must_fail git apply --reject patch.1 &&
test_cmp file1 expected &&
cat file1.rej &&
if test -f file2.rej
then
echo "file2 should not have been touched"
exit 1
fi
test_path_is_missing file2.rej
'

test_expect_success 'apply with --reject should fail but update the file' '
cat saved.file1 >file1 &&
rm -f file1.rej file2.rej file2 &&
if git apply --reject patch.2 >rejects
then
echo "succeeds with --reject?"
exit 1
fi
test -f file1 && {
echo "file1 still exists?"
exit 1
}
test_must_fail git apply --reject patch.2 >rejects &&
test_path_is_missing file1 &&
test_cmp file2 expected &&
cat file2.rej &&
if test -f file1.rej
then
echo "file2 should not have been touched"
exit 1
fi
test_path_is_missing file1.rej
'

Expand All @@ -130,25 +97,12 @@ test_expect_success 'the same test with --verbose' '
cat saved.file1 >file1 &&
rm -f file1.rej file2.rej file2 &&
if git apply --reject --verbose patch.2 >rejects
then
echo "succeeds with --reject?"
exit 1
fi
test -f file1 && {
echo "file1 still exists?"
exit 1
}
test_must_fail git apply --reject --verbose patch.2 >rejects &&
test_path_is_missing file1 &&
test_cmp file2 expected &&
cat file2.rej &&
if test -f file1.rej
then
echo "file2 should not have been touched"
exit 1
fi
test_path_is_missing file1.rej
'

Expand Down

0 comments on commit e7d053d

Please sign in to comment.