t6006: fix prereq handling with `test_format ()`

In df383b5842 (t/test-lib: wire up NO_ICONV prerequisite, 2024-10-16) we have introduced a new NO_ICONV prerequisite that makes us skip tests in case Git is not compiled with support for iconv. This change subtly broke t6006: while the test suite still passes, some of its tests won't execute because they run into an error. ./t6006-rev-list-format.sh: line 92: test_expect_%e: command not found The broken tests use `test_format ()`, and the mentioned commit simply prepended the new prerequisite to its arguments. But that does not work, as the function is not aware of prereqs at all and will now treat all of its arguments incorrectly. Fix this by making the function aware of prereqs by accepting an optional fourth argument. Adapt the callsites accordingly. Reported-by: Josh Steadmon <steadmon@google.com> Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Taylor Blau <me@ttaylorr.com>

Patrick Steinhardt committed Oct 28, 2024 at 06:14 UTC dd6003f200745ea3f42dc69c2b2901071ae7a726
1 file changed +4 -4
t/t6006-rev-list-format.sh
+4 -4
@@ -75,7 +75,7 @@ test_expect_success 'setup' '
75 git config --unset i18n.commitEncoding
76 '
77
78 -# usage: test_format [argument...] name format_string [failure] <expected_output
78 +# usage: test_format [argument...] name format_string [success|failure] [prereq] <expected_output
79 test_format () {
80 local args=
81 while true
@@ -89,7 +89,7 @@ test_format () {
89 esac
90 done
91 cat >expect.$1
92 - test_expect_${3:-success} "format $1" "
92 + test_expect_${3:-success} $4 "format $1" "
93 git rev-list $args --pretty=format:'$2' main >output.$1 &&
94 test_cmp expect.$1 output.$1
95 "
@@ -218,7 +218,7 @@ Thu, 7 Apr 2005 15:13:13 -0700
218 1112911993
219 EOF
220
221 -test_format ICONV encoding %e <<EOF
221 +test_format encoding %e success ICONV <<EOF
222 commit $head2
223 $test_encoding
224 commit $head1
@@ -394,7 +394,7 @@ test_expect_success 'setup complex body' '
394 head3_short=$(git rev-parse --short $head3)
395 '
396
397 -test_format ICONV complex-encoding %e <<EOF
397 +test_format complex-encoding %e success ICONV <<EOF
398 commit $head3
399 $test_encoding
400 commit $head2