t: use verbose instead of hand-rolled errors

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>

Jeff King committed Mar 20, 2015 at 06:09 UTC a167ece0c8cd9470427f8e9a1b43b27303eefa75
5 files changed +10 -45
t/t4022-diff-rewrite.sh
+1 -4
@@ -20,10 +20,7 @@ test_expect_success setup '
20 test_expect_success 'detect rewrite' '
21
22 actual=$(git diff-files -B --summary test) &&
23 - expr "$actual" : " rewrite test ([0-9]*%)$" || {
24 - echo "Eh? <<$actual>>"
25 - false
26 - }
23 + verbose expr "$actual" : " rewrite test ([0-9]*%)$"
24
25 '
26
t/t4202-log.sh
+5 -25
@@ -113,11 +113,7 @@ test_expect_success 'diff-filter=M' '
113
114 actual=$(git log --pretty="format:%s" --diff-filter=M HEAD) &&
115 expect=$(echo second) &&
116 - test "$actual" = "$expect" || {
117 - echo Oops
118 - echo "Actual: $actual"
119 - false
120 - }
116 + verbose test "$actual" = "$expect"
117
118 '
119
@@ -125,11 +121,7 @@ test_expect_success 'diff-filter=D' '
121
122 actual=$(git log --pretty="format:%s" --diff-filter=D HEAD) &&
123 expect=$(echo sixth ; echo third) &&
128 - test "$actual" = "$expect" || {
129 - echo Oops
130 - echo "Actual: $actual"
131 - false
132 - }
124 + verbose test "$actual" = "$expect"
125
126 '
127
@@ -137,11 +129,7 @@ test_expect_success 'diff-filter=R' '
129
130 actual=$(git log -M --pretty="format:%s" --diff-filter=R HEAD) &&
131 expect=$(echo third) &&
140 - test "$actual" = "$expect" || {
141 - echo Oops
142 - echo "Actual: $actual"
143 - false
144 - }
132 + verbose test "$actual" = "$expect"
133
134 '
135
@@ -149,11 +137,7 @@ test_expect_success 'diff-filter=C' '
137
138 actual=$(git log -C -C --pretty="format:%s" --diff-filter=C HEAD) &&
139 expect=$(echo fourth) &&
152 - test "$actual" = "$expect" || {
153 - echo Oops
154 - echo "Actual: $actual"
155 - false
156 - }
140 + verbose test "$actual" = "$expect"
141
142 '
143
@@ -161,11 +145,7 @@ test_expect_success 'git log --follow' '
145
146 actual=$(git log --follow --pretty="format:%s" ichi) &&
147 expect=$(echo third ; echo second ; echo initial) &&
164 - test "$actual" = "$expect" || {
165 - echo Oops
166 - echo "Actual: $actual"
167 - false
168 - }
148 + verbose test "$actual" = "$expect"
149
150 '
151
t/t6006-rev-list-format.sh
+1 -4
@@ -358,10 +358,7 @@ test_expect_success 'empty email' '
358 test_tick &&
359 C=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} </dev/null) &&
360 A=$(git show --pretty=format:%an,%ae,%ad%n -s $C) &&
361 - test "$A" = "A U Thor,,Thu Apr 7 15:14:13 2005 -0700" || {
362 - echo "Eh? $A" >failure
363 - false
364 - }
361 + verbose test "$A" = "A U Thor,,Thu Apr 7 15:14:13 2005 -0700"
362 '
363
364 test_expect_success 'del LF before empty (1)' '
t/t7001-mv.sh
+1 -4
@@ -161,10 +161,7 @@ test_expect_success "Michael Cassar's test case" '
161 git mv papers/unsorted/Thesis.pdf papers/all-papers/moo-blah.pdf &&
162
163 T=`git write-tree` &&
164 - git ls-tree -r $T | grep partA/outline.txt || {
165 - git ls-tree -r $T
166 - (exit 1)
167 - }
164 + git ls-tree -r $T | verbose grep partA/outline.txt
165 '
166
167 rm -fr papers partA path?
t/t7300-clean.sh
+2 -8
@@ -119,10 +119,7 @@ test_expect_success C_LOCALE_OUTPUT 'git clean with relative prefix' '
119 git clean -n ../src |
120 sed -n -e "s|^Would remove ||p"
121 ) &&
122 - test "$would_clean" = ../src/part3.c || {
123 - echo "OOps <$would_clean>"
124 - false
125 - }
122 + verbose test "$would_clean" = ../src/part3.c
123 '
124
125 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' '
131 git clean -n "$(pwd)/../src" |
132 sed -n -e "s|^Would remove ||p"
133 ) &&
137 - test "$would_clean" = ../src/part3.c || {
138 - echo "OOps <$would_clean>"
139 - false
140 - }
134 + verbose test "$would_clean" = ../src/part3.c
135 '
136
137 test_expect_success 'git clean with out of work tree relative path' '