Skip to content

Commit eb49c6e

Browse files
pks-tgitster
authored andcommitted
t6006: don't use iconv(1) without ICONV prereq
Two tests in t6006 depend on the iconv(1) prerequisite to reencode a commit message. This executable may not even exist though in case the prereq is not set, which will cause the tests to fail. Fix this by using UTF-8 instead when the prereq is not set. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent c70bea2 commit eb49c6e

1 file changed

Lines changed: 21 additions & 8 deletions

File tree

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

0 commit comments

Comments
 (0)