t: use verbose instead of hand-rolled errors
authorJeff King <peff@peff.net>
Fri, 20 Mar 2015 10:09:00 +0000 (06:09 -0400)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2015 17:20:15 +0000 (10:20 -0700)
Many tests that predate the "verbose" helper function use a
pattern like:

test ... || {
echo ...
false
}

to give more verbose output. Using the helper, we can do
this with a single line, and avoid a || which interacts
badly with &&-chaining (besides fooling --chain-lint, we hit
the error block no matter which command in the chain failed,
so we may often show useless results).

In most cases, the messages printed by "verbose" are equally
good (in some cases better; t6006 accidentally redirects the
message to a file!). The exception is t7001, whose output
suffers slightly. However, it's still enough to show the
user which part failed, given that we will have just printed
the test script to stderr.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
t/t4022-diff-rewrite.sh
t/t4202-log.sh
t/t6006-rev-list-format.sh
t/t7001-mv.sh
t/t7300-clean.sh
index 2d030a4ec35009105c26e9689dcae1150fed7b2d..cb51d9f9d47d61c5b73de78edeeedcc7652f262d 100755 (executable)
@@ -20,10 +20,7 @@ test_expect_success setup '
 test_expect_success 'detect rewrite' '
 
        actual=$(git diff-files -B --summary test) &&
-       expr "$actual" : " rewrite test ([0-9]*%)$" || {
-               echo "Eh? <<$actual>>"
-               false
-       }
+       verbose expr "$actual" : " rewrite test ([0-9]*%)$"
 
 '
 
index a22ac7c75a6d8b75db6b1e5b5e40c7e8a5ac217b..85230a87b4d5a22c499b3af5e5b967f02c7423f6 100755 (executable)
@@ -113,11 +113,7 @@ test_expect_success 'diff-filter=M' '
 
        actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
        expect=$(echo second) &&
-       test "$actual" = "$expect" || {
-               echo Oops
-               echo "Actual: $actual"
-               false
-       }
+       verbose test "$actual" = "$expect"
 
 '
 
@@ -125,11 +121,7 @@ test_expect_success 'diff-filter=D' '
 
        actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
        expect=$(echo sixth ; echo third) &&
-       test "$actual" = "$expect" || {
-               echo Oops
-               echo "Actual: $actual"
-               false
-       }
+       verbose test "$actual" = "$expect"
 
 '
 
@@ -137,11 +129,7 @@ test_expect_success 'diff-filter=R' '
 
        actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
        expect=$(echo third) &&
-       test "$actual" = "$expect" || {
-               echo Oops
-               echo "Actual: $actual"
-               false
-       }
+       verbose test "$actual" = "$expect"
 
 '
 
@@ -149,11 +137,7 @@ test_expect_success 'diff-filter=C' '
 
        actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
        expect=$(echo fourth) &&
-       test "$actual" = "$expect" || {
-               echo Oops
-               echo "Actual: $actual"
-               false
-       }
+       verbose test "$actual" = "$expect"
 
 '
 
@@ -161,11 +145,7 @@ test_expect_success 'git log --follow' '
 
        actual=$(git log --follow --pretty="format:%s" ichi) &&
        expect=$(echo third ; echo second ; echo initial) &&
-       test "$actual" = "$expect" || {
-               echo Oops
-               echo "Actual: $actual"
-               false
-       }
+       verbose test "$actual" = "$expect"
 
 '
 
index 2b7c0f0c67e0b3c1f6974a81401ead4696187cdd..b77d4c97c1102c4a9bf1313c7e9eb94a6936ac06 100755 (executable)
@@ -358,10 +358,7 @@ test_expect_success 'empty email' '
        test_tick &&
        C=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} </dev/null) &&
        A=$(git show --pretty=format:%an,%ae,%ad%n -s $C) &&
-       test "$A" = "A U Thor,,Thu Apr 7 15:14:13 2005 -0700" || {
-               echo "Eh? $A" >failure
-               false
-       }
+       verbose test "$A" = "A U Thor,,Thu Apr 7 15:14:13 2005 -0700"
 '
 
 test_expect_success 'del LF before empty (1)' '
index 69f11bd40d56cb945023ee0d299acd6d6f4a5fed..7b56081137396680df58c887ffe7919d98f6480c 100755 (executable)
@@ -161,10 +161,7 @@ test_expect_success "Michael Cassar's test case" '
        git mv papers/unsorted/Thesis.pdf papers/all-papers/moo-blah.pdf &&
 
        T=`git write-tree` &&
-       git ls-tree -r $T | grep partA/outline.txt || {
-               git ls-tree -r $T
-               (exit 1)
-       }
+       git ls-tree -r $T | verbose grep partA/outline.txt
 '
 
 rm -fr papers partA path?
index 04118ad75be8462fa2ee1e5e870feb0a44ac0482..99be5d95d063f85873a4cb5c5c7ebefd8ebfc990 100755 (executable)
@@ -119,10 +119,7 @@ test_expect_success C_LOCALE_OUTPUT 'git clean with relative prefix' '
                git clean -n ../src |
                sed -n -e "s|^Would remove ||p"
        ) &&
-       test "$would_clean" = ../src/part3.c || {
-               echo "OOps <$would_clean>"
-               false
-       }
+       verbose test "$would_clean" = ../src/part3.c
 '
 
 test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' '
@@ -134,10 +131,7 @@ test_expect_success C_LOCALE_OUTPUT 'git clean with absolute path' '
                git clean -n "$(pwd)/../src" |
                sed -n -e "s|^Would remove ||p"
        ) &&
-       test "$would_clean" = ../src/part3.c || {
-               echo "OOps <$would_clean>"
-               false
-       }
+       verbose test "$would_clean" = ../src/part3.c
 '
 
 test_expect_success 'git clean with out of work tree relative path' '