Skip to content

Commit 8ddfce7

Browse files
peffgitster
authored andcommitted
t: drop "verbose" helper function
We have a small helper function called "verbose", with the idea that you can write: verbose foo to get a message to stderr when the "foo" command fails, even if it does not produce any output itself. This goes back to 8ad1652 (t5304: use helper to report failure of "test foo = bar", 2014-10-10). It does work, but overall it has not been a big success for two reasons: 1. Test writers have to remember to put it there (and the resulting test code is longer as a result). 2. It doesn't handle the opposite case (we expect "foo" to fail, but it succeeds), leading to inconsistencies in tests (which you can see in many hunks of this patch, e.g. ones involving "has_cr"). Most importantly, we added a136f6d (test-lib.sh: support -x option for shell-tracing, 2014-10-10) at the same time, and it does roughly the same thing. The output is not quite as succinct as "verbose", and you have to watch out for stray shell-traces ending up in stderr. But it solves both of the problems above, and has clearly become the preferred tool. Let's consider the "verbose" function a failed experiment and remove the last few callers (which are all many years old, and have been dwindling as we remove them from scripts we touch for other reasons). It will be one less thing for new test writers to see and wonder if they should be using themselves. Signed-off-by: Jeff King <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent a9ea529 commit 8ddfce7

12 files changed

+57
-66
lines changed

t/t0020-crlf.sh

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ test_expect_success 'update with autocrlf=input' '
125125
munge_cr append dir/two &&
126126
git update-index -- one dir/two &&
127127
differs=$(git diff-index --cached HEAD) &&
128-
verbose test -z "$differs"
128+
test -z "$differs"
129129
130130
'
131131

@@ -138,7 +138,7 @@ test_expect_success 'update with autocrlf=true' '
138138
munge_cr append dir/two &&
139139
git update-index -- one dir/two &&
140140
differs=$(git diff-index --cached HEAD) &&
141-
verbose test -z "$differs"
141+
test -z "$differs"
142142
143143
'
144144

@@ -153,7 +153,7 @@ test_expect_success 'checkout with autocrlf=true' '
153153
test "$one" = $(git hash-object --stdin <one) &&
154154
test "$two" = $(git hash-object --stdin <dir/two) &&
155155
differs=$(git diff-index --cached HEAD) &&
156-
verbose test -z "$differs"
156+
test -z "$differs"
157157
'
158158

159159
test_expect_success 'checkout with autocrlf=input' '
@@ -167,7 +167,7 @@ test_expect_success 'checkout with autocrlf=input' '
167167
test "$one" = $(git hash-object --stdin <one) &&
168168
test "$two" = $(git hash-object --stdin <dir/two) &&
169169
differs=$(git diff-index --cached HEAD) &&
170-
verbose test -z "$differs"
170+
test -z "$differs"
171171
'
172172

173173
test_expect_success 'apply patch (autocrlf=input)' '
@@ -177,7 +177,7 @@ test_expect_success 'apply patch (autocrlf=input)' '
177177
git read-tree --reset -u HEAD &&
178178
179179
git apply patch.file &&
180-
verbose test "$patched" = "$(git hash-object --stdin <one)"
180+
test "$patched" = "$(git hash-object --stdin <one)"
181181
'
182182

183183
test_expect_success 'apply patch --cached (autocrlf=input)' '
@@ -187,7 +187,7 @@ test_expect_success 'apply patch --cached (autocrlf=input)' '
187187
git read-tree --reset -u HEAD &&
188188
189189
git apply --cached patch.file &&
190-
verbose test "$patched" = $(git rev-parse :one)
190+
test "$patched" = $(git rev-parse :one)
191191
'
192192

193193
test_expect_success 'apply patch --index (autocrlf=input)' '
@@ -197,8 +197,8 @@ test_expect_success 'apply patch --index (autocrlf=input)' '
197197
git read-tree --reset -u HEAD &&
198198
199199
git apply --index patch.file &&
200-
verbose test "$patched" = $(git rev-parse :one) &&
201-
verbose test "$patched" = $(git hash-object --stdin <one)
200+
test "$patched" = $(git rev-parse :one) &&
201+
test "$patched" = $(git hash-object --stdin <one)
202202
'
203203

204204
test_expect_success 'apply patch (autocrlf=true)' '
@@ -208,7 +208,7 @@ test_expect_success 'apply patch (autocrlf=true)' '
208208
git read-tree --reset -u HEAD &&
209209
210210
git apply patch.file &&
211-
verbose test "$patched" = "$(remove_cr <one | git hash-object --stdin)"
211+
test "$patched" = "$(remove_cr <one | git hash-object --stdin)"
212212
'
213213

214214
test_expect_success 'apply patch --cached (autocrlf=true)' '
@@ -218,7 +218,7 @@ test_expect_success 'apply patch --cached (autocrlf=true)' '
218218
git read-tree --reset -u HEAD &&
219219
220220
git apply --cached patch.file &&
221-
verbose test "$patched" = $(git rev-parse :one)
221+
test "$patched" = $(git rev-parse :one)
222222
'
223223

224224
test_expect_success 'apply patch --index (autocrlf=true)' '
@@ -228,8 +228,8 @@ test_expect_success 'apply patch --index (autocrlf=true)' '
228228
git read-tree --reset -u HEAD &&
229229
230230
git apply --index patch.file &&
231-
verbose test "$patched" = $(git rev-parse :one) &&
232-
verbose test "$patched" = "$(remove_cr <one | git hash-object --stdin)"
231+
test "$patched" = $(git rev-parse :one) &&
232+
test "$patched" = "$(remove_cr <one | git hash-object --stdin)"
233233
'
234234

235235
test_expect_success '.gitattributes says two is binary' '
@@ -240,7 +240,7 @@ test_expect_success '.gitattributes says two is binary' '
240240
git read-tree --reset -u HEAD &&
241241
242242
! has_cr dir/two &&
243-
verbose has_cr one &&
243+
has_cr one &&
244244
! has_cr three
245245
'
246246

@@ -259,8 +259,8 @@ test_expect_success '.gitattributes says two and three are text' '
259259
echo "t* crlf" >.gitattributes &&
260260
git read-tree --reset -u HEAD &&
261261
262-
verbose has_cr dir/two &&
263-
verbose has_cr three
262+
has_cr dir/two &&
263+
has_cr three
264264
'
265265

266266
test_expect_success 'in-tree .gitattributes (1)' '
@@ -273,7 +273,7 @@ test_expect_success 'in-tree .gitattributes (1)' '
273273
git read-tree --reset -u HEAD &&
274274
275275
! has_cr one &&
276-
verbose has_cr three
276+
has_cr three
277277
'
278278

279279
test_expect_success 'in-tree .gitattributes (2)' '
@@ -283,7 +283,7 @@ test_expect_success 'in-tree .gitattributes (2)' '
283283
git checkout-index -f -q -u -a &&
284284
285285
! has_cr one &&
286-
verbose has_cr three
286+
has_cr three
287287
'
288288

289289
test_expect_success 'in-tree .gitattributes (3)' '
@@ -294,7 +294,7 @@ test_expect_success 'in-tree .gitattributes (3)' '
294294
git checkout-index -u one dir/two three &&
295295
296296
! has_cr one &&
297-
verbose has_cr three
297+
has_cr three
298298
'
299299

300300
test_expect_success 'in-tree .gitattributes (4)' '
@@ -305,7 +305,7 @@ test_expect_success 'in-tree .gitattributes (4)' '
305305
git checkout-index -u .gitattributes &&
306306
307307
! has_cr one &&
308-
verbose has_cr three
308+
has_cr three
309309
'
310310

311311
test_expect_success 'checkout with existing .gitattributes' '

t/t1301-shared-repo.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ do
8989
rm -f .git/info/refs &&
9090
git update-server-info &&
9191
actual="$(test_modebits .git/info/refs)" &&
92-
verbose test "x$actual" = "x-$y"
92+
test "x$actual" = "x-$y"
9393
9494
'
9595

@@ -99,7 +99,7 @@ do
9999
rm -f .git/info/refs &&
100100
git update-server-info &&
101101
actual="$(test_modebits .git/info/refs)" &&
102-
verbose test "x$actual" = "x-$x"
102+
test "x$actual" = "x-$x"
103103
104104
'
105105

t/t3427-rebase-subtree.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,9 @@ test_expect_success 'Rebase -Xsubtree --empty=ask --onto commit' '
7474
test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --onto files-main main &&
7575
: first pick results in no changes &&
7676
git rebase --skip &&
77-
verbose test "$(commit_message HEAD~2)" = "topic_4" &&
78-
verbose test "$(commit_message HEAD~)" = "files_subtree/topic_5" &&
79-
verbose test "$(commit_message HEAD)" = "Empty commit"
77+
test "$(commit_message HEAD~2)" = "topic_4" &&
78+
test "$(commit_message HEAD~)" = "files_subtree/topic_5" &&
79+
test "$(commit_message HEAD)" = "Empty commit"
8080
'
8181

8282
test_expect_success 'Rebase -Xsubtree --empty=ask --rebase-merges --onto commit' '
@@ -85,9 +85,9 @@ test_expect_success 'Rebase -Xsubtree --empty=ask --rebase-merges --onto commit'
8585
test_must_fail git rebase -Xsubtree=files_subtree --empty=ask --rebase-merges --onto files-main --root &&
8686
: first pick results in no changes &&
8787
git rebase --skip &&
88-
verbose test "$(commit_message HEAD~2)" = "topic_4" &&
89-
verbose test "$(commit_message HEAD~)" = "files_subtree/topic_5" &&
90-
verbose test "$(commit_message HEAD)" = "Empty commit"
88+
test "$(commit_message HEAD~2)" = "topic_4" &&
89+
test "$(commit_message HEAD~)" = "files_subtree/topic_5" &&
90+
test "$(commit_message HEAD)" = "Empty commit"
9191
'
9292

9393
test_done

t/t4022-diff-rewrite.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test_expect_success setup '
2424
test_expect_success 'detect rewrite' '
2525
2626
actual=$(git diff-files -B --summary test) &&
27-
verbose expr "$actual" : " rewrite test ([0-9]*%)$"
27+
expr "$actual" : " rewrite test ([0-9]*%)$"
2828
2929
'
3030

t/t4062-diff-pickaxe.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ test_expect_success '-G matches' '
2424

2525
test_expect_success '-S --pickaxe-regex' '
2626
git diff --name-only -S0 --pickaxe-regex HEAD^ >out &&
27-
verbose test 4096-zeroes.txt = "$(cat out)"
27+
test 4096-zeroes.txt = "$(cat out)"
2828
'
2929

3030
test_done

t/t5304-prune.sh

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ add_blob() {
1616
before=$(git count-objects | sed "s/ .*//") &&
1717
BLOB=$(echo aleph_0 | git hash-object -w --stdin) &&
1818
BLOB_FILE=.git/objects/$(echo $BLOB | sed "s/^../&\//") &&
19-
verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
19+
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
2020
test_path_is_file $BLOB_FILE &&
2121
test-tool chmtime =+0 $BLOB_FILE
2222
}
@@ -51,23 +51,23 @@ test_expect_success 'prune stale packs' '
5151
test_expect_success 'prune --expire' '
5252
add_blob &&
5353
git prune --expire=1.hour.ago &&
54-
verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
54+
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
5555
test_path_is_file $BLOB_FILE &&
5656
test-tool chmtime =-86500 $BLOB_FILE &&
5757
git prune --expire 1.day &&
58-
verbose test $before = $(git count-objects | sed "s/ .*//") &&
58+
test $before = $(git count-objects | sed "s/ .*//") &&
5959
test_path_is_missing $BLOB_FILE
6060
'
6161

6262
test_expect_success 'gc: implicit prune --expire' '
6363
add_blob &&
6464
test-tool chmtime =-$((2*$week-30)) $BLOB_FILE &&
6565
git gc --no-cruft &&
66-
verbose test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
66+
test $((1 + $before)) = $(git count-objects | sed "s/ .*//") &&
6767
test_path_is_file $BLOB_FILE &&
6868
test-tool chmtime =-$((2*$week+1)) $BLOB_FILE &&
6969
git gc --no-cruft &&
70-
verbose test $before = $(git count-objects | sed "s/ .*//") &&
70+
test $before = $(git count-objects | sed "s/ .*//") &&
7171
test_path_is_missing $BLOB_FILE
7272
'
7373

@@ -138,7 +138,7 @@ test_expect_success 'gc --no-prune' '
138138
test-tool chmtime =-$((5001*$day)) $BLOB_FILE &&
139139
git config gc.pruneExpire 2.days.ago &&
140140
git gc --no-prune --no-cruft &&
141-
verbose test 1 = $(git count-objects | sed "s/ .*//") &&
141+
test 1 = $(git count-objects | sed "s/ .*//") &&
142142
test_path_is_file $BLOB_FILE
143143
'
144144

@@ -192,10 +192,10 @@ test_expect_success 'gc: prune old objects after local clone' '
192192
git clone --no-hardlinks . aclone &&
193193
(
194194
cd aclone &&
195-
verbose test 1 = $(git count-objects | sed "s/ .*//") &&
195+
test 1 = $(git count-objects | sed "s/ .*//") &&
196196
test_path_is_file $BLOB_FILE &&
197197
git gc --prune --no-cruft &&
198-
verbose test 0 = $(git count-objects | sed "s/ .*//") &&
198+
test 0 = $(git count-objects | sed "s/ .*//") &&
199199
test_path_is_missing $BLOB_FILE
200200
)
201201
'

t/t6006-rev-list-format.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -493,7 +493,7 @@ test_expect_success 'empty email' '
493493
test_tick &&
494494
C=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} </dev/null) &&
495495
A=$(git show --pretty=format:%an,%ae,%ad%n -s $C) &&
496-
verbose test "$A" = "$GIT_AUTHOR_NAME,,Thu Apr 7 15:14:13 2005 -0700"
496+
test "$A" = "$GIT_AUTHOR_NAME,,Thu Apr 7 15:14:13 2005 -0700"
497497
'
498498

499499
test_expect_success 'del LF before empty (1)' '

t/t6501-freshen-objects.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ test_expect_success 'do not complain about existing broken links (commit)' '
152152
EOF
153153
commit=$(git hash-object -t commit -w broken-commit) &&
154154
git gc --no-cruft -q 2>stderr &&
155-
verbose git cat-file -e $commit &&
155+
git cat-file -e $commit &&
156156
test_must_be_empty stderr
157157
'
158158

t/t7001-mv.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ test_expect_success "Michael Cassar's test case" '
192192
193193
T=$(git write-tree) &&
194194
git ls-tree -r $T >out &&
195-
verbose grep partA/outline.txt out
195+
grep partA/outline.txt out
196196
'
197197

198198
rm -fr papers partA path?

t/t7300-clean.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ test_expect_success 'git clean with relative prefix' '
120120
grep part3 |
121121
sed -n -e "s|^Would remove ||p"
122122
) &&
123-
verbose test "$would_clean" = ../src/part3.c
123+
test "$would_clean" = ../src/part3.c
124124
'
125125

126126
test_expect_success 'git clean with absolute path' '
@@ -133,7 +133,7 @@ test_expect_success 'git clean with absolute path' '
133133
grep part3 |
134134
sed -n -e "s|^Would remove ||p"
135135
) &&
136-
verbose test "$would_clean" = ../src/part3.c
136+
test "$would_clean" = ../src/part3.c
137137
'
138138

139139
test_expect_success 'git clean with out of work tree relative path' '

0 commit comments

Comments
 (0)