git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 3/5] t4205: improve handling of ICONV prerequisite

From
Patrick Steinhardt <ps@pks.im>
Date
Feb 18, 2026, 04:38 UTC
Message-ID
<20260218-b4-pks-ci-msvc-iconv-fixes-v3-3-08c1ff3ffc9a@pks.im>
In-Reply-To
<20260218-b4-pks-ci-msvc-iconv-fixes-v3-0-08c1ff3ffc9a@pks.im>

In t4205 we have a bunch of tests that depend on the iconv prereq. This is for most of the part because we format commit messages that have been encoded in an encoding different than UTF-8.

Those tests fall into two classes though:
  - One class of tests outputs the data as-is without reencoding.
  - One class of tests outputs the data with "i18n.logOutputEncoding" to
    reencode it.

Curiously enough, both of these classes are marked with the ICONV prereq, even though one might expect that the first class wouldn't need the prereq. This is because we unconditionally use ISO-8859-1 encoding for the initial commit message, and thus we depend on converting to UTF-8 indeed.

This creates another problem though: when the iconv(1) executable does not exist the test setup fails, even in the case where the ICONV prereq has not been set.

Fix these issues by making the test encoding conditional on ICONV: if it's available we use ISO-8859-1, otherwise we use UTF-8. This fixes the test setup on platforms without iconv(1), and it allows us to drop the ICONV prereq from a bunch of tests.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/t4205-log-pretty-formats.sh | 50 ++++++++++++++++++++++++-------------------
 1 file changed, 28 insertions(+), 22 deletions(-)
diff --git a/t/t4205-log-pretty-formats.sh b/t/t4205-log-pretty-formats.sh
index 8f2ba98963..3865f6abc7 100755
--- a/t/t4205-log-pretty-formats.sh
+++ b/t/t4205-log-pretty-formats.sh
@@ -9,7 +9,12 @@ test_description='Test pretty formats'
 . ./test-lib.sh
 
 # Tested non-UTF-8 encoding
-test_encoding="ISO8859-1"
+if test_have_prereq ICONV
+then
+	test_encoding="ISO8859-1"
+else
+	test_encoding="UTF-8"
+fi
 
 sample_utf8_part=$(printf "f\303\244ng")
 
@@ -18,7 +23,7 @@ commit_msg () {
 	# (translated with Google Translate),
 	# encoded in UTF-8, used as a commit log message below.
 	msg="initial. an${sample_utf8_part}lich\n"
-	if test -n "$1"
+	if test -n "$1" && test "$1" != "UTF-8"
 	then
 		printf "$msg" | iconv -f utf-8 -t "$1"
 	else
@@ -113,19 +118,19 @@ test_expect_success 'alias loop' '
 	test_must_fail git log --pretty=test-foo
 '
 
-test_expect_success ICONV 'NUL separation' '
+test_expect_success 'NUL separation' '
 	printf "add bar\0$(commit_msg)" >expected &&
 	git log -z --pretty="format:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'NUL termination' '
+test_expect_success 'NUL termination' '
 	printf "add bar\0$(commit_msg)\0" >expected &&
 	git log -z --pretty="tformat:%s" >actual &&
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'NUL separation with --stat' '
+test_expect_success 'NUL separation with --stat' '
 	stat0_part=$(git diff --stat HEAD^ HEAD) &&
 	stat1_part=$(git diff-tree --no-commit-id --stat --root HEAD^) &&
 	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' '
 	head4=$(git rev-parse --verify --short HEAD~3)
 '
 
-test_expect_success ICONV 'left alignment formatting' '
+test_expect_success 'left alignment formatting' '
 	git log --pretty="tformat:%<(40)%s" >actual &&
 	qz_to_tab_space <<-EOF >expected &&
 	message two                            Z
@@ -202,7 +207,7 @@ test_expect_success ICONV 'left alignment formatting. i18n.logOutputEncoding' '
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'left alignment formatting at the nth column' '
+test_expect_success 'left alignment formatting at the nth column' '
 	git log --pretty="tformat:%h %<|(40)%s" >actual &&
 	qz_to_tab_space <<-EOF >expected &&
 	$head1 message two                    Z
@@ -213,7 +218,7 @@ test_expect_success ICONV 'left alignment formatting at the nth column' '
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'left alignment formatting at the nth column' '
+test_expect_success 'left alignment formatting at the nth column' '
 	COLUMNS=50 git log --pretty="tformat:%h %<|(-10)%s" >actual &&
 	qz_to_tab_space <<-EOF >expected &&
 	$head1 message two                    Z
@@ -235,7 +240,7 @@ test_expect_success ICONV 'left alignment formatting at the nth column. i18n.log
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'left alignment formatting with no padding' '
+test_expect_success 'left alignment formatting with no padding' '
 	git log --pretty="tformat:%<(1)%s" >actual &&
 	cat <<-EOF >expected &&
 	message two
@@ -246,7 +251,7 @@ test_expect_success ICONV 'left alignment formatting with no padding' '
 	test_cmp expected actual
 '
 
-test_expect_success 'left alignment formatting with no padding. i18n.logOutputEncoding' '
+test_expect_success ICONV 'left alignment formatting with no padding. i18n.logOutputEncoding' '
 	git -c i18n.logOutputEncoding=$test_encoding log --pretty="tformat:%<(1)%s" >actual &&
 	cat <<-EOF | iconv -f utf-8 -t $test_encoding >expected &&
 	message two
@@ -257,7 +262,7 @@ test_expect_success 'left alignment formatting with no padding. i18n.logOutputEn
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'left alignment formatting with trunc' '
+test_expect_success 'left alignment formatting with trunc' '
 	git log --pretty="tformat:%<(10,trunc)%s" >actual &&
 	qz_to_tab_space <<-\EOF >expected &&
 	message ..
@@ -279,7 +284,7 @@ test_expect_success ICONV 'left alignment formatting with trunc. i18n.logOutputE
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'left alignment formatting with ltrunc' '
+test_expect_success 'left alignment formatting with ltrunc' '
 	git log --pretty="tformat:%<(10,ltrunc)%s" >actual &&
 	qz_to_tab_space <<-EOF >expected &&
 	..sage two
@@ -301,7 +306,7 @@ test_expect_success ICONV 'left alignment formatting with ltrunc. i18n.logOutput
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'left alignment formatting with mtrunc' '
+test_expect_success 'left alignment formatting with mtrunc' '
 	git log --pretty="tformat:%<(10,mtrunc)%s" >actual &&
 	qz_to_tab_space <<-\EOF >expected &&
 	mess.. two
@@ -323,7 +328,7 @@ test_expect_success ICONV 'left alignment formatting with mtrunc. i18n.logOutput
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'right alignment formatting' '
+test_expect_success 'right alignment formatting' '
 	git log --pretty="tformat:%>(40)%s" >actual &&
 	qz_to_tab_space <<-EOF >expected &&
 	Z                            message two
@@ -345,7 +350,7 @@ test_expect_success ICONV 'right alignment formatting. i18n.logOutputEncoding' '
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'right alignment formatting at the nth column' '
+test_expect_success 'right alignment formatting at the nth column' '
 	git log --pretty="tformat:%h %>|(40)%s" >actual &&
 	qz_to_tab_space <<-EOF >expected &&
 	$head1                      message two
@@ -356,7 +361,7 @@ test_expect_success ICONV 'right alignment formatting at the nth column' '
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'right alignment formatting at the nth column' '
+test_expect_success 'right alignment formatting at the nth column' '
 	COLUMNS=50 git log --pretty="tformat:%h %>|(-10)%s" >actual &&
 	qz_to_tab_space <<-EOF >expected &&
 	$head1                      message two
@@ -391,7 +396,7 @@ test_expect_success ICONV 'right alignment formatting at the nth column with --g
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'right alignment formatting with no padding' '
+test_expect_success 'right alignment formatting with no padding' '
 	git log --pretty="tformat:%>(1)%s" >actual &&
 	cat <<-EOF >expected &&
 	message two
@@ -402,7 +407,7 @@ test_expect_success ICONV 'right alignment formatting with no padding' '
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'right alignment formatting with no padding and with --graph' '
+test_expect_success 'right alignment formatting with no padding and with --graph' '
 	git log --graph --pretty="tformat:%>(1)%s" >actual &&
 	cat <<-EOF >expected &&
 	* message two
@@ -424,7 +429,7 @@ test_expect_success ICONV 'right alignment formatting with no padding. i18n.logO
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'center alignment formatting' '
+test_expect_success 'center alignment formatting' '
 	git log --pretty="tformat:%><(40)%s" >actual &&
 	qz_to_tab_space <<-EOF >expected &&
 	Z             message two              Z
@@ -445,7 +450,8 @@ test_expect_success ICONV 'center alignment formatting. i18n.logOutputEncoding'
 	EOF
 	test_cmp expected actual
 '
-test_expect_success ICONV 'center alignment formatting at the nth column' '
+
+test_expect_success 'center alignment formatting at the nth column' '
 	git log --pretty="tformat:%h %><|(40)%s" >actual &&
 	qz_to_tab_space <<-EOF >expected &&
 	$head1           message two          Z
@@ -456,7 +462,7 @@ test_expect_success ICONV 'center alignment formatting at the nth column' '
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'center alignment formatting at the nth column' '
+test_expect_success 'center alignment formatting at the nth column' '
 	COLUMNS=70 git log --pretty="tformat:%h %><|(-30)%s" >actual &&
 	qz_to_tab_space <<-EOF >expected &&
 	$head1           message two          Z
@@ -478,7 +484,7 @@ test_expect_success ICONV 'center alignment formatting at the nth column. i18n.l
 	test_cmp expected actual
 '
 
-test_expect_success ICONV 'center alignment formatting with no padding' '
+test_expect_success 'center alignment formatting with no padding' '
 	git log --pretty="tformat:%><(1)%s" >actual &&
 	cat <<-EOF >expected &&
 	message two
-- 
2.53.0.414.gf7e9f6c205.dirty
Previous: Patrick SteinhardtNext: Patrick Steinhardt
Message 24 of 38 in “Fix tests with missing iconv(1) executable”
  1. 0/4 Fix tests with missing iconv(1) executablePatrick Steinhardt, Feb 9, 2026
  2. 1/4 t4xxx: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 9, 2026
  3. 2/4 t4205: improve handling of ICONV prerequisitePatrick Steinhardt, Feb 9, 2026
  4. 3/4 t5550: add ICONV prereq to tests that use "$HTTPD_URL/error"Patrick Steinhardt, Feb 9, 2026
  5. 4/4 t6006: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 9, 2026
  6. Junio C HamanoFeb 9, 2026
  7. Torsten BögershausenFeb 10, 2026
  8. Patrick SteinhardtFeb 10, 2026
  9. Junio C HamanoFeb 10, 2026
  10. Christian CouderFeb 16, 2026
  11. Christian CouderFeb 16, 2026
  12. Patrick SteinhardtFeb 17, 2026
  13. Patrick SteinhardtFeb 17, 2026
  14. 0/4 Fix tests with missing iconv(1) executablePatrick Steinhardt, Feb 17, 2026
  15. 1/4 t4xxx: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 17, 2026
  16. 2/4 t4205: improve handling of ICONV prerequisitePatrick Steinhardt, Feb 17, 2026
  17. 3/4 t5550: add ICONV prereq to tests that use "$HTTPD_URL/error"Patrick Steinhardt, Feb 17, 2026
  18. 4/4 t6006: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 17, 2026
  19. Christian CouderFeb 17, 2026
  20. Patrick SteinhardtFeb 17, 2026
  21. 0/5 Fix tests with missing iconv(1) executablePatrick Steinhardt, Feb 18, 2026
  22. 1/5 t: don't set ICONV prereq when iconv(1) is missingPatrick Steinhardt, Feb 18, 2026
  23. 2/5 t40xx: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 18, 2026
  24. 3/5 t4205: improve handling of ICONV prerequisitePatrick Steinhardt, Feb 18, 2026
  25. 4/5 t5550: add ICONV prereq to tests that use "$HTTPD_URL/error"Patrick Steinhardt, Feb 18, 2026
  26. 5/5 t6006: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 18, 2026
  27. Christian CouderFeb 18, 2026
  28. Patrick SteinhardtFeb 18, 2026
  29. Junio C HamanoFeb 18, 2026
  30. Eric SunshineFeb 19, 2026
  31. Patrick SteinhardtFeb 20, 2026
  32. 0/5 Fix tests with missing iconv(1) executablePatrick Steinhardt, Feb 20, 2026
  33. 1/5 t: don't set ICONV prereq when iconv(1) is missingPatrick Steinhardt, Feb 20, 2026
  34. 2/5 t40xx: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 20, 2026
  35. 3/5 t4205: improve handling of ICONV prerequisitePatrick Steinhardt, Feb 20, 2026
  36. 4/5 t5550: add ICONV prereq to tests that use "$HTTPD_URL/error"Patrick Steinhardt, Feb 20, 2026
  37. 5/5 t6006: don't use iconv(1) without ICONV prereqPatrick Steinhardt, Feb 20, 2026
  38. Junio C HamanoFeb 20, 2026

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.