From 9157c5cb0968f1d97bf4a79b8622a9601387a368 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Fri, 20 Mar 2015 06:13:08 -0400 Subject: t0020: use modern test_* helpers This test contains a lot of hand-rolled messages to show when the test fails. We can omit most of these by using "verbose" and "test_must_fail". A few of them are for update-index, but we can assume it produces reasonable error messages when it fails. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t0020-crlf.sh | 144 +++++++++++--------------------------------------------- 1 file changed, 28 insertions(+), 116 deletions(-) (limited to 't') diff --git a/t/t0020-crlf.sh b/t/t0020-crlf.sh index d2e51a81bc..9fa26df729 100755 --- a/t/t0020-crlf.sh +++ b/t/t0020-crlf.sh @@ -104,18 +104,12 @@ test_expect_success 'update with autocrlf=input' ' for f in one dir/two do append_cr <$f >tmp && mv -f tmp $f && - git update-index -- $f || { - echo Oops - false - break - } + git update-index -- $f || + break done && differs=$(git diff-index --cached HEAD) && - test -z "$differs" || { - echo Oops "$differs" - false - } + verbose test -z "$differs" ' @@ -128,18 +122,12 @@ test_expect_success 'update with autocrlf=true' ' for f in one dir/two do append_cr <$f >tmp && mv -f tmp $f && - git update-index -- $f || { - echo "Oops $f" - false - break - } + git update-index -- $f || + break done && differs=$(git diff-index --cached HEAD) && - test -z "$differs" || { - echo Oops "$differs" - false - } + verbose test -z "$differs" ' @@ -152,19 +140,13 @@ test_expect_success 'checkout with autocrlf=true' ' for f in one dir/two do remove_cr <"$f" >tmp && mv -f tmp $f && - git update-index -- $f || { - echo "Eh? $f" - false - break - } + verbose git update-index -- $f || + break done && test "$one" = $(git hash-object --stdin .gitattributes && git read-tree --reset -u HEAD && - if has_cr dir/two - then - : happy - else - echo "Huh?" - false - fi && - - if has_cr three - then - : happy - else - echo "Huh?" - false - fi + verbose has_cr dir/two && + verbose has_cr three ' test_expect_success 'in-tree .gitattributes (1)' ' @@ -352,17 +300,8 @@ test_expect_success 'in-tree .gitattributes (1)' ' rm -rf tmp one dir .gitattributes patch.file three && git read-tree --reset -u HEAD && - if has_cr one - then - echo "Eh? one should not have CRLF" - false - else - : happy - fi && - has_cr three || { - echo "Eh? three should still have CRLF" - false - } + test_must_fail has_cr one && + verbose has_cr three ' test_expect_success 'in-tree .gitattributes (2)' ' @@ -371,17 +310,8 @@ test_expect_success 'in-tree .gitattributes (2)' ' git read-tree --reset HEAD && git checkout-index -f -q -u -a && - if has_cr one - then - echo "Eh? one should not have CRLF" - false - else - : happy - fi && - has_cr three || { - echo "Eh? three should still have CRLF" - false - } + test_must_fail has_cr one && + verbose has_cr three ' test_expect_success 'in-tree .gitattributes (3)' ' @@ -391,17 +321,8 @@ test_expect_success 'in-tree .gitattributes (3)' ' git checkout-index -u .gitattributes && git checkout-index -u one dir/two three && - if has_cr one - then - echo "Eh? one should not have CRLF" - false - else - : happy - fi && - has_cr three || { - echo "Eh? three should still have CRLF" - false - } + test_must_fail has_cr one && + verbose has_cr three ' test_expect_success 'in-tree .gitattributes (4)' ' @@ -411,17 +332,8 @@ test_expect_success 'in-tree .gitattributes (4)' ' git checkout-index -u one dir/two three && git checkout-index -u .gitattributes && - if has_cr one - then - echo "Eh? one should not have CRLF" - false - else - : happy - fi && - has_cr three || { - echo "Eh? three should still have CRLF" - false - } + test_must_fail has_cr one && + verbose has_cr three ' test_expect_success 'checkout with existing .gitattributes' ' -- cgit v1.2.3