diff mbox series

t6006: fix prereq handling with `test_format ()`

Message ID ccb2d7cf817a181fab8fb083bdc9f1fed4671749.1730092261.git.ps@pks.im (mailing list archive)
State Accepted
Commit dd6003f200745ea3f42dc69c2b2901071ae7a726
Headers show
Series t6006: fix prereq handling with `test_format ()` | expand

Commit Message

Patrick Steinhardt Oct. 28, 2024, 5:14 a.m. UTC
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>
---

Oops, good catch. @Taylor, let's maybe queue this fix on top of
ps/platform-compat-fixes, which currently sits in next.

Thanks!

Patrick

 t/t6006-rev-list-format.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Comments

Taylor Blau Oct. 28, 2024, 5:48 p.m. UTC | #1
On Mon, Oct 28, 2024 at 06:14:51AM +0100, Patrick Steinhardt wrote:
> Oops, good catch. @Taylor, let's maybe queue this fix on top of
> ps/platform-compat-fixes, which currently sits in next.

Noted, thanks, and thanks also for hopping on the fix.

I was wondering how to handle this situation with Junio's scripts, but
applying the patch on top of ps/platform-compat-fixes and then
re-building 'next' lands the patch in the expected fashion, without any
additional cruft.

I am not sure whether I will do a push-out on Tuesday (as has been my
schedule since Junio went offline), or Wednesday morning. I suspect that
the latter is more likely, but either way, that integration round will
have the new patch applied down onto 'next'.

Thanks,
Taylor
diff mbox series

Patch

diff --git a/t/t6006-rev-list-format.sh b/t/t6006-rev-list-format.sh
index 2a01a62a2f..b0ec2fe865 100755
--- a/t/t6006-rev-list-format.sh
+++ b/t/t6006-rev-list-format.sh
@@ -75,7 +75,7 @@  test_expect_success 'setup' '
 	git config --unset i18n.commitEncoding
 '
 
-# usage: test_format [argument...] name format_string [failure] <expected_output
+# usage: test_format [argument...] name format_string [success|failure] [prereq] <expected_output
 test_format () {
 	local args=
 	while true
@@ -89,7 +89,7 @@  test_format () {
 		esac
 	done
 	cat >expect.$1
-	test_expect_${3:-success} "format $1" "
+	test_expect_${3:-success} $4 "format $1" "
 		git rev-list $args --pretty=format:'$2' main >output.$1 &&
 		test_cmp expect.$1 output.$1
 	"
@@ -218,7 +218,7 @@  Thu, 7 Apr 2005 15:13:13 -0700
 1112911993
 EOF
 
-test_format ICONV encoding %e <<EOF
+test_format encoding %e success ICONV <<EOF
 commit $head2
 $test_encoding
 commit $head1
@@ -394,7 +394,7 @@  test_expect_success 'setup complex body' '
 	head3_short=$(git rev-parse --short $head3)
 '
 
-test_format ICONV complex-encoding %e <<EOF
+test_format complex-encoding %e success ICONV <<EOF
 commit $head3
 $test_encoding
 commit $head2