git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Patrick Steinhardt <ps@pks.im>
To: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Cc: git@vger.kernel.org, Eric Sunshine <sunshine@sunshineco.com>,
	Karthik Nayak <karthik.188@gmail.com>,
	Phillip Wood <phillip.wood123@gmail.com>
Subject: Re: [PATCH v3 13/20] t: refactor tests depending on Perl for textconv scripts
Date: Wed, 2 Apr 2025 09:16:36 +0200	[thread overview]
Message-ID: <Z-zkVL8cSYEiR_T1@pks.im> (raw)
In-Reply-To: <9f477166-5667-a051-13d3-43d56a7a8ec1@gmx.de>

On Tue, Apr 01, 2025 at 08:55:22PM +0200, Johannes Schindelin wrote:
> On Thu, 27 Mar 2025, Patrick Steinhardt wrote:
> > diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh
> > index c7d8eb12453..f904fc19f69 100755
> > --- a/t/t4030-diff-textconv.sh
> > +++ b/t/t4030-diff-textconv.sh
> > @@ -26,13 +20,10 @@ cat >expect.text <<'EOF'
> >  +1
> >  EOF
> >
> > -cat >hexdump <<'EOF'
> > -#!/bin/sh
> > -"$PERL_PATH" -e '$/ = undef; $_ = <>; s/./ord($&)/ge; print $_' < "$1"
> > -EOF
> > -chmod +x hexdump
> > -
> >  test_expect_success 'setup binary file with history' '
> > +	write_script hexdump <<-\EOF &&
> > +	tr "\000\001" "01" <"$1"
> > +	EOF
> 
> So here the `hexdump` script is written, basically replacing NUL and SOH
> with the digits zero and one, respectively. I wonder why the script does
> not call `test-tool hexdump` instead? And I wonder even more why no test
> case has to be adapted below this change in the same file. I _guess_ that
> the reason is that the file named, creatively, "file" is initialized with
> a NUL and a newline, committed, then a line is appended that contains SOH
> and a newline, and then the test cases verify the hunk _headers_ only?
> 
> If using `test-tool hexdump <"$1"` would work here, too, I'd actually have
> preferred that over the `tr` invocation, even if would still not be
> recapitulating the functionality of that Perl script (which, contrary to
> its name, seemed never to have output hexadecimal values...).
> 
> To be clear: I do not suggest to change the patch, I am merely puzzled why
> the more obvious `test-tool hexdump <"$1"` was not used here?

Phillip had the same comment, and I was trying to address that by
improving the commit message a bit. But seems like it still isn't clear
enough.

The reason why I decided against using `test-tool hexdump` is that it
would have a ripple effect. The output generated by that helper is not
the same as the output generated by the Perl script, so if we started to
use the hexdump helper I would have to adapt a bunch of tests in this
test file to update their expectations.

The result would look something like the appended patch, which I think
is quite awkward. On the one hand we have trailing whitespace in the
expectation, on the other hand we have weird seemingly-unrelated changes
in other tests. So I shied away from that and instead decided to use a
simpler variant of the textconv script.

Let me adapt the commit message once again and make it a bit more
concrete compared to the current fuzzy description.

Patrick

diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh
index f904fc19f69..16d7fd4c5ca 100755
--- a/t/t4030-diff-textconv.sh
+++ b/t/t4030-diff-textconv.sh
@@ -15,14 +15,14 @@ EOF
 cat >expect.text <<'EOF'
 --- a/file
 +++ b/file
-@@ -1 +1,2 @@
- 0
-+1
+@@ -1 +1 @@
+-00 0a 
++00 0a 01 0a 
 EOF
 
 test_expect_success 'setup binary file with history' '
 	write_script hexdump <<-\EOF &&
-	tr "\000\001" "01" <"$1"
+	test-tool hexdump <"$1"
 	EOF
 	test_commit --printf one file "\\0\\n" &&
 	test_commit --printf --append two file "\\01\\n"
@@ -92,7 +92,7 @@ test_expect_success 'show blob produces binary' '
 
 test_expect_success 'show --textconv blob produces text' '
 	git show --textconv HEAD:file >actual &&
-	printf "0\\n1\\n" >expect &&
+	printf "00 0a 01 0a \n" >expect &&
 	test_cmp expect actual
 '
 
@@ -103,7 +103,7 @@ test_expect_success 'show --no-textconv blob produces binary' '
 '
 
 test_expect_success 'grep-diff (-G) operates on textconv data (add)' '
-	echo one >expect &&
+	printf "two\none\n" >expect &&
 	git log --root --format=%s -G0 >actual &&
 	test_cmp expect actual
 '
@@ -115,7 +115,7 @@ test_expect_success 'grep-diff (-G) operates on textconv data (modification)' '
 '
 
 test_expect_success 'pickaxe (-S) operates on textconv data (add)' '
-	echo one >expect &&
+	printf "two\none\n" >expect &&
 	git log --root --format=%s -S0 >actual &&
 	test_cmp expect actual
 '
@@ -146,9 +146,8 @@ symlink=$(git rev-parse --short $(printf frotz | git hash-object --stdin))
 cat >expect.typechange <<EOF
 --- a/file
 +++ /dev/null
-@@ -1,2 +0,0 @@
--0
--1
+@@ -1 +0,0 @@
+-00 0a 01 0a 
 diff --git a/file b/file
 new file mode 120000
 index 0000000..$symlink

  reply	other threads:[~2025-04-02  7:16 UTC|newest]

Thread overview: 125+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-03-20  9:35 [PATCH 00/20] t: drop Perl as a mandatory prerequisite Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 01/20] t: skip chain lint when PERL_PATH is unset Patrick Steinhardt
2025-03-20 18:36   ` Eric Sunshine
2025-03-20  9:35 ` [PATCH 02/20] t: refactor environment sanitization to not use Perl Patrick Steinhardt
2025-03-21  9:52   ` Karthik Nayak
2025-03-20  9:35 ` [PATCH 03/20] t: adapt character translation helpers " Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 04/20] t: adapt `test_copy_bytes()` " Patrick Steinhardt
2025-03-21  9:56   ` Karthik Nayak
2025-03-20  9:35 ` [PATCH 05/20] t: adapt `test_readlink()` " Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 06/20] t: introduce PERL_TEST_HELPERS prerequisite Patrick Steinhardt
2025-03-20 18:55   ` Eric Sunshine
2025-03-24 12:46     ` Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 07/20] t: adapt existing PERL prerequisites Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 08/20] meson: stop requiring Perl when tests are enabled Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 09/20] Makefile: stop requiring Perl when running tests Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 10/20] t: refactor tests depending on Perl transliteration operator Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 11/20] t: refactor tests depending on Perl substitution operator Patrick Steinhardt
2025-03-24 16:16   ` Phillip Wood
2025-03-20  9:35 ` [PATCH 12/20] t: refactor tests depending on Perl to print data Patrick Steinhardt
2025-03-20 19:33   ` Eric Sunshine
2025-03-24 12:46     ` Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 13/20] t: refactor tests depending on Perl for textconv scripts Patrick Steinhardt
2025-03-20 19:37   ` Eric Sunshine
2025-03-24 12:46     ` Patrick Steinhardt
2025-03-24 16:07       ` Eric Sunshine
2025-03-25 12:42         ` Patrick Steinhardt
2025-03-24 16:16   ` Phillip Wood
2025-03-25 12:43     ` Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 14/20] t/lib-gpg: refactor `sanitize_pgp()` to not depend on Perl Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 15/20] t/lib-t6000: refactor `name_from_description()` " Patrick Steinhardt
2025-03-20 19:41   ` Eric Sunshine
2025-03-24 12:46     ` Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 16/20] t/lib-httpd: refactor "one-time-perl" CGI script " Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 17/20] t0021: refactor `generate_random_characters()` " Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 18/20] t0210: refactor trace2 scrubbing to not use Perl Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 19/20] t5316: refactor `max_chain()` to not depend on Perl Patrick Steinhardt
2025-03-20  9:35 ` [PATCH 20/20] t5703: refactor test " Patrick Steinhardt
2025-03-25 13:14 ` [PATCH v2 00/20] t: drop Perl as a mandatory prerequisite Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 01/20] t: skip chain lint when PERL_PATH is unset Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 02/20] t: refactor environment sanitization to not use Perl Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 03/20] t: adapt character translation helpers " Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 04/20] t: adapt `test_copy_bytes()` " Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 05/20] t: adapt `test_readlink()` " Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 06/20] t: introduce PERL_TEST_HELPERS prerequisite Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 07/20] t: adapt existing PERL prerequisites Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 08/20] meson: stop requiring Perl when tests are enabled Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 09/20] Makefile: stop requiring Perl when running tests Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 10/20] t: refactor tests depending on Perl transliteration operator Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 11/20] t: refactor tests depending on Perl substitution operator Patrick Steinhardt
2025-03-25 14:35     ` Phillip Wood
2025-03-27 10:19       ` Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 12/20] t: refactor tests depending on Perl to print data Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 13/20] t: refactor tests depending on Perl for textconv scripts Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 14/20] t/lib-gpg: refactor `sanitize_pgp()` to not depend on Perl Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 15/20] t/lib-t6000: refactor `name_from_description()` " Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 16/20] t/lib-httpd: refactor "one-time-perl" CGI script " Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 17/20] t0021: refactor `generate_random_characters()` " Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 18/20] t0210: refactor trace2 scrubbing to not use Perl Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 19/20] t5316: refactor `max_chain()` to not depend on Perl Patrick Steinhardt
2025-03-25 13:14   ` [PATCH v2 20/20] t5703: refactor test " Patrick Steinhardt
2025-03-27 10:36 ` [PATCH v3 00/20] t: drop Perl as a mandatory prerequisite Patrick Steinhardt
2025-03-27 10:36   ` [PATCH v3 01/20] t: skip chain lint when PERL_PATH is unset Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 02/20] t: refactor environment sanitization to not use Perl Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 03/20] t: adapt character translation helpers " Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 04/20] t: adapt `test_copy_bytes()` " Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 05/20] t: adapt `test_readlink()` " Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 06/20] t: introduce PERL_TEST_HELPERS prerequisite Patrick Steinhardt
2025-04-01 18:26     ` Johannes Schindelin
2025-04-02  7:16       ` Patrick Steinhardt
2025-04-02 19:10         ` Johannes Schindelin
2025-04-03  5:05           ` Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 07/20] t: adapt existing PERL prerequisites Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 08/20] meson: stop requiring Perl when tests are enabled Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 09/20] Makefile: stop requiring Perl when running tests Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 10/20] t: refactor tests depending on Perl transliteration operator Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 11/20] t: refactor tests depending on Perl substitution operator Patrick Steinhardt
2025-04-01 18:32     ` Johannes Schindelin
2025-04-02  7:16       ` Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 12/20] t: refactor tests depending on Perl to print data Patrick Steinhardt
2025-04-01 18:35     ` Johannes Schindelin
2025-04-02  7:16       ` Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 13/20] t: refactor tests depending on Perl for textconv scripts Patrick Steinhardt
2025-04-01 18:55     ` Johannes Schindelin
2025-04-02  7:16       ` Patrick Steinhardt [this message]
2025-04-02 19:17         ` Johannes Schindelin
2025-03-27 10:37   ` [PATCH v3 14/20] t/lib-gpg: refactor `sanitize_pgp()` to not depend on Perl Patrick Steinhardt
2025-04-01 18:56     ` Johannes Schindelin
2025-04-02  7:16       ` Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 15/20] t/lib-t6000: refactor `name_from_description()` " Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 16/20] t/lib-httpd: refactor "one-time-perl" CGI script " Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 17/20] t0021: refactor `generate_random_characters()` " Patrick Steinhardt
2025-04-01 19:04     ` Johannes Schindelin
2025-04-02  7:16       ` Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 18/20] t0210: refactor trace2 scrubbing to not use Perl Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 19/20] t5316: refactor `max_chain()` to not depend on Perl Patrick Steinhardt
2025-03-27 10:37   ` [PATCH v3 20/20] t5703: refactor test " Patrick Steinhardt
2025-03-28 10:29   ` [PATCH v3 00/20] t: drop Perl as a mandatory prerequisite Phillip Wood
2025-04-02 19:32   ` Johannes Schindelin
2025-04-03  5:05 ` [PATCH v4 " Patrick Steinhardt
2025-04-03  5:05   ` [PATCH v4 01/20] t: skip chain lint when PERL_PATH is unset Patrick Steinhardt
2025-04-03  5:05   ` [PATCH v4 02/20] t: refactor environment sanitization to not use Perl Patrick Steinhardt
2025-04-03  5:05   ` [PATCH v4 03/20] t: adapt character translation helpers " Patrick Steinhardt
2025-04-03  5:05   ` [PATCH v4 04/20] t: adapt `test_copy_bytes()` " Patrick Steinhardt
2025-04-03  5:05   ` [PATCH v4 05/20] t: adapt `test_readlink()` " Patrick Steinhardt
2025-04-03  5:05   ` [PATCH v4 06/20] t: introduce PERL_TEST_HELPERS prerequisite Patrick Steinhardt
2025-04-03  5:05   ` [PATCH v4 07/20] t: adapt existing PERL prerequisites Patrick Steinhardt
2025-04-03  5:05   ` [PATCH v4 08/20] meson: stop requiring Perl when tests are enabled Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 09/20] Makefile: stop requiring Perl when running tests Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 10/20] t: refactor tests depending on Perl transliteration operator Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 11/20] t: refactor tests depending on Perl substitution operator Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 12/20] t: refactor tests depending on Perl to print data Patrick Steinhardt
2025-06-10 19:52     ` SZEDER Gábor
2025-06-10 21:31       ` Junio C Hamano
2025-07-07  9:53         ` Patrick Steinhardt
2025-06-10 21:44       ` Junio C Hamano
2025-04-03  5:06   ` [PATCH v4 13/20] t: refactor tests depending on Perl for textconv scripts Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 14/20] t/lib-gpg: refactor `sanitize_pgp()` to not depend on Perl Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 15/20] t/lib-t6000: refactor `name_from_description()` " Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 16/20] t/lib-httpd: refactor "one-time-perl" CGI script " Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 17/20] t0021: refactor `generate_random_characters()` " Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 18/20] t0210: refactor trace2 scrubbing to not use Perl Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 19/20] t5316: refactor `max_chain()` to not depend on Perl Patrick Steinhardt
2025-04-03  5:06   ` [PATCH v4 20/20] t5703: refactor test " Patrick Steinhardt
2025-04-03 12:12   ` [PATCH v4 00/20] t: drop Perl as a mandatory prerequisite Johannes Schindelin
2025-04-08  0:32     ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Z-zkVL8cSYEiR_T1@pks.im \
    --to=ps@pks.im \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=karthik.188@gmail.com \
    --cc=phillip.wood123@gmail.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).