]> git.ipfire.org Git - thirdparty/git.git/commitdiff
t: use test_expect_code instead of hand-rolled comparison
authorJeff King <peff@peff.net>
Fri, 20 Mar 2015 10:11:46 +0000 (06:11 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2015 17:20:16 +0000 (10:20 -0700)
This makes our output in the event of a failure slightly
nicer, and it means that we do not break the &&-chain.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t0040-parse-options.sh
t/t4035-diff-quiet.sh
t/t4053-diff-no-index.sh

index a90c86bfa3e12cea6f917a32f4f3739e8f0dfc0c..b0447851750e3f196ea2da90f84ce31fefce30ae 100755 (executable)
@@ -172,12 +172,9 @@ test_expect_success 'long options' '
 '
 
 test_expect_success 'missing required value' '
-       test-parse-options -s;
-       test $? = 129 &&
-       test-parse-options --string;
-       test $? = 129 &&
-       test-parse-options --file;
-       test $? = 129
+       test_expect_code 129 test-parse-options -s &&
+       test_expect_code 129 test-parse-options --string &&
+       test_expect_code 129 test-parse-options --file
 '
 
 cat > expect << EOF
@@ -227,8 +224,7 @@ test_expect_success 'unambiguously abbreviated option with "="' '
 '
 
 test_expect_success 'ambiguously abbreviated option' '
-       test-parse-options --strin 123;
-       test $? = 129
+       test_expect_code 129 test-parse-options --strin 123
 '
 
 cat > expect << EOF
index e8ae2a03fdcf5ac57dc0e5bcacd40501960bce1c..461f4bb583d081c58c8ab55bf4cedae8a361cd43 100755 (executable)
@@ -29,67 +29,65 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'git diff-tree HEAD^ HEAD' '
-       git diff-tree --quiet HEAD^ HEAD >cnt
-       test $? = 1 && test_line_count = 0 cnt
+       test_expect_code 1 git diff-tree --quiet HEAD^ HEAD >cnt &&
+       test_line_count = 0 cnt
 '
 test_expect_success 'git diff-tree HEAD^ HEAD -- a' '
-       git diff-tree --quiet HEAD^ HEAD -- a >cnt
-       test $? = 0 && test_line_count = 0 cnt
+       test_expect_code 0 git diff-tree --quiet HEAD^ HEAD -- a >cnt &&
+       test_line_count = 0 cnt
 '
 test_expect_success 'git diff-tree HEAD^ HEAD -- b' '
-       git diff-tree --quiet HEAD^ HEAD -- b >cnt
-       test $? = 1 && test_line_count = 0 cnt
+       test_expect_code 1 git diff-tree --quiet HEAD^ HEAD -- b >cnt &&
+       test_line_count = 0 cnt
 '
 # this diff outputs one line: sha1 of the given head
 test_expect_success 'echo HEAD | git diff-tree --stdin' '
-       echo $(git rev-parse HEAD) | git diff-tree --quiet --stdin >cnt
-       test $? = 1 && test_line_count = 1 cnt
+       echo $(git rev-parse HEAD) |
+       test_expect_code 1 git diff-tree --quiet --stdin >cnt &&
+       test_line_count = 1 cnt
 '
 test_expect_success 'git diff-tree HEAD HEAD' '
-       git diff-tree --quiet HEAD HEAD >cnt
-       test $? = 0 && test_line_count = 0 cnt
+       test_expect_code 0 git diff-tree --quiet HEAD HEAD >cnt &&
+       test_line_count = 0 cnt
 '
 test_expect_success 'git diff-files' '
-       git diff-files --quiet >cnt
-       test $? = 0 && test_line_count = 0 cnt
+       test_expect_code 0 git diff-files --quiet >cnt &&
+       test_line_count = 0 cnt
 '
 test_expect_success 'git diff-index --cached HEAD' '
-       git diff-index --quiet --cached HEAD >cnt
-       test $? = 0 && test_line_count = 0 cnt
+       test_expect_code 0 git diff-index --quiet --cached HEAD >cnt &&
+       test_line_count = 0 cnt
 '
 test_expect_success 'git diff-index --cached HEAD^' '
-       git diff-index --quiet --cached HEAD^ >cnt
-       test $? = 1 && test_line_count = 0 cnt
+       test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
+       test_line_count = 0 cnt
 '
 test_expect_success 'git diff-index --cached HEAD^' '
        echo text >>b &&
        echo 3 >c &&
-       git add . && {
-               git diff-index --quiet --cached HEAD^ >cnt
-               test $? = 1 && test_line_count = 0 cnt
-       }
+       git add . &&
+       test_expect_code 1 git diff-index --quiet --cached HEAD^ >cnt &&
+       test_line_count = 0 cnt
 '
 test_expect_success 'git diff-tree -Stext HEAD^ HEAD -- b' '
-       git commit -m "text in b" && {
-               git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt
-               test $? = 1 && test_line_count = 0 cnt
-       }
+       git commit -m "text in b" &&
+       test_expect_code 1 git diff-tree --quiet -Stext HEAD^ HEAD -- b >cnt &&
+       test_line_count = 0 cnt
 '
 test_expect_success 'git diff-tree -Snot-found HEAD^ HEAD -- b' '
-       git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt
-       test $? = 0 && test_line_count = 0 cnt
+       test_expect_code 0 git diff-tree --quiet -Snot-found HEAD^ HEAD -- b >cnt &&
+       test_line_count = 0 cnt
 '
 test_expect_success 'git diff-files' '
-       echo 3 >>c && {
-               git diff-files --quiet >cnt
-               test $? = 1 && test_line_count = 0 cnt
-       }
+       echo 3 >>c &&
+       test_expect_code 1 git diff-files --quiet >cnt &&
+       test_line_count = 0 cnt
 '
+
 test_expect_success 'git diff-index --cached HEAD' '
-       git update-index c && {
-               git diff-index --quiet --cached HEAD >cnt
-               test $? = 1 && test_line_count = 0 cnt
-       }
+       git update-index c &&
+       test_expect_code 1 git diff-index --quiet --cached HEAD >cnt &&
+       test_line_count = 0 cnt
 '
 
 test_expect_success 'git diff, one file outside repo' '
index 2ab3c487340569d7f2f8164776907ef30df2d415..075ece6db16f9c313504559d95c5b1dc6b4c2e07 100755 (executable)
@@ -17,8 +17,8 @@ test_expect_success 'setup' '
 '
 
 test_expect_success 'git diff --no-index directories' '
-       git diff --no-index a b >cnt
-       test $? = 1 && test_line_count = 14 cnt
+       test_expect_code 1 git diff --no-index a b >cnt &&
+       test_line_count = 14 cnt
 '
 
 test_expect_success 'git diff --no-index relative path outside repo' '