Skip to content

Commit 277b2c9

Browse files
committed
Merge branch 'ps/tests-wo-iconv-fixes' into next
Some tests assumed "iconv" is available without honoring ICONV prerequisite, which has been corrected. * ps/tests-wo-iconv-fixes: t6006: don't use iconv(1) without ICONV prereq t5550: add ICONV prereq to tests that use "$HTTPD_URL/error" t4205: improve handling of ICONV prerequisite t40xx: don't use iconv(1) without ICONV prereq t: don't set ICONV prereq when iconv(1) is missing
2 parents b2a8b7b + eb49c6e commit 277b2c9

7 files changed

Lines changed: 88 additions & 47 deletions

t/t4041-diff-submodule-option.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,12 @@ add_file () {
3737
test_tick &&
3838
# "git commit -m" would break MinGW, as Windows refuse to pass
3939
# $test_encoding encoded parameter to git.
40-
echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
41-
git -c "i18n.commitEncoding=$test_encoding" commit -F -
40+
message="Add $name ($added $name)" &&
41+
if test_have_prereq ICONV
42+
then
43+
message=$(echo "$message" | iconv -f utf-8 -t $test_encoding)
44+
fi &&
45+
echo "$message" | git -c "i18n.commitEncoding=$test_encoding" commit -F -
4246
done >/dev/null &&
4347
git rev-parse --short --verify HEAD
4448
)

t/t4059-diff-submodule-not-initialized.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ add_file () {
3535
test_tick &&
3636
# "git commit -m" would break MinGW, as Windows refuse to pass
3737
# $test_encoding encoded parameter to git.
38-
echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
39-
git -c "i18n.commitEncoding=$test_encoding" commit -F -
38+
message="Add $name ($added $name)" &&
39+
if test_have_prereq ICONV
40+
then
41+
message=$(echo "$message" | iconv -f utf-8 -t $test_encoding)
42+
fi &&
43+
echo "$message" | git -c "i18n.commitEncoding=$test_encoding" commit -F -
4044
done >/dev/null &&
4145
git rev-parse --short --verify HEAD
4246
)

t/t4060-diff-submodule-option-diff-format.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,12 @@ add_file () {
3535
test_tick &&
3636
# "git commit -m" would break MinGW, as Windows refuse to pass
3737
# $test_encoding encoded parameter to git.
38-
echo "Add $name ($added $name)" | iconv -f utf-8 -t $test_encoding |
39-
git -c "i18n.commitEncoding=$test_encoding" commit -F -
38+
message="Add $name ($added $name)" &&
39+
if test_have_prereq ICONV
40+
then
41+
message=$(echo "$message" | iconv -f utf-8 -t $test_encoding)
42+
fi &&
43+
echo "$message" | git -c "i18n.commitEncoding=$test_encoding" commit -F -
4044
done >/dev/null &&
4145
git rev-parse --short --verify HEAD
4246
)

t/t4205-log-pretty-formats.sh

Lines changed: 28 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,12 @@ test_description='Test pretty formats'
99
. ./test-lib.sh
1010

1111
# Tested non-UTF-8 encoding
12-
test_encoding="ISO8859-1"
12+
if test_have_prereq ICONV
13+
then
14+
test_encoding="ISO8859-1"
15+
else
16+
test_encoding="UTF-8"
17+
fi
1318

1419
sample_utf8_part=$(printf "f\303\244ng")
1520

@@ -18,7 +23,7 @@ commit_msg () {
1823
# (translated with Google Translate),
1924
# encoded in UTF-8, used as a commit log message below.
2025
msg="initial. an${sample_utf8_part}lich\n"
21-
if test -n "$1"
26+
if test -n "$1" && test "$1" != "UTF-8"
2227
then
2328
printf "$msg" | iconv -f utf-8 -t "$1"
2429
else
@@ -113,19 +118,19 @@ test_expect_success 'alias loop' '
113118
test_must_fail git log --pretty=test-foo
114119
'
115120

116-
test_expect_success ICONV 'NUL separation' '
121+
test_expect_success 'NUL separation' '
117122
printf "add bar\0$(commit_msg)" >expected &&
118123
git log -z --pretty="format:%s" >actual &&
119124
test_cmp expected actual
120125
'
121126

122-
test_expect_success ICONV 'NUL termination' '
127+
test_expect_success 'NUL termination' '
123128
printf "add bar\0$(commit_msg)\0" >expected &&
124129
git log -z --pretty="tformat:%s" >actual &&
125130
test_cmp expected actual
126131
'
127132

128-
test_expect_success ICONV 'NUL separation with --stat' '
133+
test_expect_success 'NUL separation with --stat' '
129134
stat0_part=$(git diff --stat HEAD^ HEAD) &&
130135
stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
131136
printf "add bar\n$stat0_part\n\0$(commit_msg)\n$stat1_part\n" >expected &&
@@ -180,7 +185,7 @@ test_expect_success 'setup more commits' '
180185
head4=$(git rev-parse --verify --short HEAD~3)
181186
'
182187

183-
test_expect_success ICONV 'left alignment formatting' '
188+
test_expect_success 'left alignment formatting' '
184189
git log --pretty="tformat:%<(40)%s" >actual &&
185190
qz_to_tab_space <<-EOF >expected &&
186191
message two Z
@@ -202,7 +207,7 @@ test_expect_success ICONV 'left alignment formatting. i18n.logOutputEncoding' '
202207
test_cmp expected actual
203208
'
204209

205-
test_expect_success ICONV 'left alignment formatting at the nth column' '
210+
test_expect_success 'left alignment formatting at the nth column' '
206211
git log --pretty="tformat:%h %<|(40)%s" >actual &&
207212
qz_to_tab_space <<-EOF >expected &&
208213
$head1 message two Z
@@ -213,7 +218,7 @@ test_expect_success ICONV 'left alignment formatting at the nth column' '
213218
test_cmp expected actual
214219
'
215220

216-
test_expect_success ICONV 'left alignment formatting at the nth column' '
221+
test_expect_success 'left alignment formatting at the nth column' '
217222
COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual &&
218223
qz_to_tab_space <<-EOF >expected &&
219224
$head1 message two Z
@@ -235,7 +240,7 @@ test_expect_success ICONV 'left alignment formatting at the nth column. i18n.log
235240
test_cmp expected actual
236241
'
237242

238-
test_expect_success ICONV 'left alignment formatting with no padding' '
243+
test_expect_success 'left alignment formatting with no padding' '
239244
git log --pretty="tformat:%<(1)%s" >actual &&
240245
cat <<-EOF >expected &&
241246
message two
@@ -246,7 +251,7 @@ test_expect_success ICONV 'left alignment formatting with no padding' '
246251
test_cmp expected actual
247252
'
248253

249-
test_expect_success 'left alignment formatting with no padding. i18n.logOutputEncoding' '
254+
test_expect_success ICONV 'left alignment formatting with no padding. i18n.logOutputEncoding' '
250255
git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual &&
251256
cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
252257
message two
@@ -257,7 +262,7 @@ test_expect_success 'left alignment formatting with no padding. i18n.logOutputEn
257262
test_cmp expected actual
258263
'
259264

260-
test_expect_success ICONV 'left alignment formatting with trunc' '
265+
test_expect_success 'left alignment formatting with trunc' '
261266
git log --pretty="tformat:%<(10,trunc)%s" >actual &&
262267
qz_to_tab_space <<-\EOF >expected &&
263268
message ..
@@ -279,7 +284,7 @@ test_expect_success ICONV 'left alignment formatting with trunc. i18n.logOutputE
279284
test_cmp expected actual
280285
'
281286

282-
test_expect_success ICONV 'left alignment formatting with ltrunc' '
287+
test_expect_success 'left alignment formatting with ltrunc' '
283288
git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
284289
qz_to_tab_space <<-EOF >expected &&
285290
..sage two
@@ -301,7 +306,7 @@ test_expect_success ICONV 'left alignment formatting with ltrunc. i18n.logOutput
301306
test_cmp expected actual
302307
'
303308

304-
test_expect_success ICONV 'left alignment formatting with mtrunc' '
309+
test_expect_success 'left alignment formatting with mtrunc' '
305310
git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
306311
qz_to_tab_space <<-\EOF >expected &&
307312
mess.. two
@@ -323,7 +328,7 @@ test_expect_success ICONV 'left alignment formatting with mtrunc. i18n.logOutput
323328
test_cmp expected actual
324329
'
325330

326-
test_expect_success ICONV 'right alignment formatting' '
331+
test_expect_success 'right alignment formatting' '
327332
git log --pretty="tformat:%>(40)%s" >actual &&
328333
qz_to_tab_space <<-EOF >expected &&
329334
Z message two
@@ -345,7 +350,7 @@ test_expect_success ICONV 'right alignment formatting. i18n.logOutputEncoding' '
345350
test_cmp expected actual
346351
'
347352

348-
test_expect_success ICONV 'right alignment formatting at the nth column' '
353+
test_expect_success 'right alignment formatting at the nth column' '
349354
git log --pretty="tformat:%h %>|(40)%s" >actual &&
350355
qz_to_tab_space <<-EOF >expected &&
351356
$head1 message two
@@ -356,7 +361,7 @@ test_expect_success ICONV 'right alignment formatting at the nth column' '
356361
test_cmp expected actual
357362
'
358363

359-
test_expect_success ICONV 'right alignment formatting at the nth column' '
364+
test_expect_success 'right alignment formatting at the nth column' '
360365
COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual &&
361366
qz_to_tab_space <<-EOF >expected &&
362367
$head1 message two
@@ -391,7 +396,7 @@ test_expect_success ICONV 'right alignment formatting at the nth column with --g
391396
test_cmp expected actual
392397
'
393398

394-
test_expect_success ICONV 'right alignment formatting with no padding' '
399+
test_expect_success 'right alignment formatting with no padding' '
395400
git log --pretty="tformat:%>(1)%s" >actual &&
396401
cat <<-EOF >expected &&
397402
message two
@@ -402,7 +407,7 @@ test_expect_success ICONV 'right alignment formatting with no padding' '
402407
test_cmp expected actual
403408
'
404409

405-
test_expect_success ICONV 'right alignment formatting with no padding and with --graph' '
410+
test_expect_success 'right alignment formatting with no padding and with --graph' '
406411
git log --graph --pretty="tformat:%>(1)%s" >actual &&
407412
cat <<-EOF >expected &&
408413
* message two
@@ -424,7 +429,7 @@ test_expect_success ICONV 'right alignment formatting with no padding. i18n.logO
424429
test_cmp expected actual
425430
'
426431

427-
test_expect_success ICONV 'center alignment formatting' '
432+
test_expect_success 'center alignment formatting' '
428433
git log --pretty="tformat:%><(40)%s" >actual &&
429434
qz_to_tab_space <<-EOF >expected &&
430435
Z message two Z
@@ -445,7 +450,8 @@ test_expect_success ICONV 'center alignment formatting. i18n.logOutputEncoding'
445450
EOF
446451
test_cmp expected actual
447452
'
448-
test_expect_success ICONV 'center alignment formatting at the nth column' '
453+
454+
test_expect_success 'center alignment formatting at the nth column' '
449455
git log --pretty="tformat:%h %><|(40)%s" >actual &&
450456
qz_to_tab_space <<-EOF >expected &&
451457
$head1 message two Z
@@ -456,7 +462,7 @@ test_expect_success ICONV 'center alignment formatting at the nth column' '
456462
test_cmp expected actual
457463
'
458464

459-
test_expect_success ICONV 'center alignment formatting at the nth column' '
465+
test_expect_success 'center alignment formatting at the nth column' '
460466
COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual &&
461467
qz_to_tab_space <<-EOF >expected &&
462468
$head1 message two Z
@@ -478,7 +484,7 @@ test_expect_success ICONV 'center alignment formatting at the nth column. i18n.l
478484
test_cmp expected actual
479485
'
480486

481-
test_expect_success ICONV 'center alignment formatting with no padding' '
487+
test_expect_success 'center alignment formatting with no padding' '
482488
git log --pretty="tformat:%><(1)%s" >actual &&
483489
cat <<-EOF >expected &&
484490
message two

t/t5550-http-fetch-dumb.sh

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -339,32 +339,32 @@ test_expect_success 'fetch can handle previously-fetched .idx files' '
339339
'
340340

341341
test_expect_success 'did not use upload-pack service' '
342-
! grep "/git-upload-pack" "$HTTPD_ROOT_PATH/access.log"
342+
test_grep ! "/git-upload-pack" "$HTTPD_ROOT_PATH/access.log"
343343
'
344344

345-
test_expect_success 'git client shows text/plain errors' '
345+
test_expect_success ICONV 'git client shows text/plain errors' '
346346
test_must_fail git clone "$HTTPD_URL/error/text" 2>stderr &&
347-
grep "this is the error message" stderr
347+
test_grep "this is the error message" stderr
348348
'
349349

350-
test_expect_success 'git client does not show html errors' '
350+
test_expect_success ICONV 'git client does not show html errors' '
351351
test_must_fail git clone "$HTTPD_URL/error/html" 2>stderr &&
352-
! grep "this is the error message" stderr
352+
test_grep ! "this is the error message" stderr
353353
'
354354

355-
test_expect_success 'git client shows text/plain with a charset' '
355+
test_expect_success ICONV 'git client shows text/plain with a charset' '
356356
test_must_fail git clone "$HTTPD_URL/error/charset" 2>stderr &&
357-
grep "this is the error message" stderr
357+
test_grep "this is the error message" stderr
358358
'
359359

360360
test_expect_success ICONV 'http error messages are reencoded' '
361361
test_must_fail git clone "$HTTPD_URL/error/utf16" 2>stderr &&
362-
grep "this is the error message" stderr
362+
test_grep "this is the error message" stderr
363363
'
364364

365365
test_expect_success ICONV 'reencoding is robust to whitespace oddities' '
366366
test_must_fail git clone "$HTTPD_URL/error/odd-spacing" 2>stderr &&
367-
grep "this is the error message" stderr
367+
test_grep "this is the error message" stderr
368368
'
369369

370370
check_language () {
@@ -406,7 +406,7 @@ ja;q=0.95, zh;q=0.94, sv;q=0.93, pt;q=0.92, nb;q=0.91, *;q=0.90" \
406406

407407
test_expect_success 'git client send an empty Accept-Language' '
408408
GIT_TRACE_CURL=true LANGUAGE= git ls-remote "$HTTPD_URL/dumb/repo.git" 2>stderr &&
409-
! grep "^=> Send header: Accept-Language:" stderr
409+
test_grep ! "^=> Send header: Accept-Language:" stderr
410410
'
411411

412412
test_expect_success 'remote-http complains cleanly about malformed urls' '

t/t6006-rev-list-format.sh

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -378,15 +378,23 @@ test_expect_success 'rev-list %C(auto,...) respects --color' '
378378
test_cmp expect actual
379379
'
380380

381-
iconv -f utf-8 -t $test_encoding > commit-msg <<EOF
382-
Test printing of complex bodies
381+
test_expect_success 'setup complex body' '
382+
message=$(cat <<-EOF
383+
Test printing of complex bodies
383384
384-
This commit message is much longer than the others,
385-
and it will be encoded in $test_encoding. We should therefore
386-
include an ISO8859 character: ¡bueno!
387-
EOF
385+
This commit message is much longer than the others,
386+
and it will be encoded in $test_encoding. We should therefore
387+
include an ISO8859 character: ¡bueno!
388+
EOF
389+
) &&
390+
391+
if test_have_prereq ICONV
392+
then
393+
echo "$message" | iconv -f utf-8 -t $test_encoding >commit-msg
394+
else
395+
echo "$message" >commit-msg
396+
fi &&
388397
389-
test_expect_success 'setup complex body' '
390398
git config i18n.commitencoding $test_encoding &&
391399
echo change2 >foo && git commit -a -F commit-msg &&
392400
head3=$(git rev-parse --verify HEAD) &&
@@ -448,7 +456,12 @@ test_expect_success 'setup expected messages (for test %b)' '
448456
commit $head2
449457
commit $head1
450458
EOF
451-
iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
459+
if test_have_prereq ICONV
460+
then
461+
iconv -f utf-8 -t $test_encoding expected.utf-8 >expected.ISO8859-1
462+
else
463+
cp expected.utf-8 expected.ISO8859-1
464+
fi
452465
'
453466

454467
test_format complex-body %b <expected.ISO8859-1

t/test-lib.sh

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1720,7 +1720,6 @@ esac
17201720
( COLUMNS=1 && test $COLUMNS = 1 ) && test_set_prereq COLUMNS_CAN_BE_1
17211721
test -z "$NO_CURL" && test_set_prereq LIBCURL
17221722
test -z "$NO_GITWEB" && test_set_prereq GITWEB
1723-
test -z "$NO_ICONV" && test_set_prereq ICONV
17241723
test -z "$NO_PERL" && test_set_prereq PERL
17251724
test -z "$NO_PTHREADS" && test_set_prereq PTHREADS
17261725
test -z "$NO_PYTHON" && test_set_prereq PYTHON
@@ -1731,6 +1730,17 @@ test -n "$SANITIZE_LEAK" && test_set_prereq SANITIZE_LEAK
17311730
test -n "$GIT_VALGRIND_ENABLED" && test_set_prereq VALGRIND
17321731
test -n "$PERL_PATH" && test_set_prereq PERL_TEST_HELPERS
17331732

1733+
test_lazy_prereq ICONV '
1734+
# We require Git to be built with iconv support, and we require the
1735+
# iconv binary to exist.
1736+
#
1737+
# NEEDSWORK: We might eventually want to split this up into two
1738+
# prerequisites: one for NO_ICONV, and one for the iconv(1) binary, as
1739+
# some tests only depend on either of these.
1740+
test -z "$NO_ICONV" &&
1741+
iconv -f utf8 -t utf8 </dev/null
1742+
'
1743+
17341744
if test -z "$GIT_TEST_CHECK_CACHE_TREE"
17351745
then
17361746
GIT_TEST_CHECK_CACHE_TREE=true

0 commit comments

Comments
 (0)