aboutsummaryrefslogtreecommitdiffstats
path: root/t/t4030-diff-textconv.sh
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2025-04-03 07:06:04 +0200
committerJunio C Hamano <gitster@pobox.com>2025-04-07 14:47:39 -0700
commit4a7af4edbb800ff8ed0cd131423f45c2c76e1200 (patch)
treede11e6515671a414ec048a079557685f72271cb0 /t/t4030-diff-textconv.sh
parentt: refactor tests depending on Perl to print data (diff)
downloadgit-4a7af4edbb800ff8ed0cd131423f45c2c76e1200.tar.gz
git-4a7af4edbb800ff8ed0cd131423f45c2c76e1200.zip
t: refactor tests depending on Perl for textconv scripts
We have a couple of tests that depend on Perl for textconv scripts. Refactor these tests to instead be implemented via shell utilities so that we can drop a couple of PERL_TEST_HELPERS prerequisites. Note that the conversion in t4030 is not a one-to-one equivalent to the previous textconv script. Before this change we used to essentially do a hexdump via Perl. The obvious conversion here would be to use `test-tool hexdump` like we do for the other tests. But this would lead to a ripple effect where we would have to adapt a bunch of other tests with a bunch of seemingly unrelated changes, which would be somewhat awkward. Instead, we're going with the minimum viable change: the test files we write contain "\001" and "\000", and the test's expectation is that those get translated into proper ASCII characters. So instead of doing a full hexdump, we simply use tr(1) to translate these specific bytes. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t4030-diff-textconv.sh')
-rwxr-xr-xt/t4030-diff-textconv.sh15
1 files changed, 3 insertions, 12 deletions
diff --git a/t/t4030-diff-textconv.sh b/t/t4030-diff-textconv.sh
index c7d8eb1245..f904fc19f6 100755
--- a/t/t4030-diff-textconv.sh
+++ b/t/t4030-diff-textconv.sh
@@ -4,12 +4,6 @@ test_description='diff.*.textconv tests'
. ./test-lib.sh
-if ! test_have_prereq PERL_TEST_HELPERS
-then
- skip_all='skipping diff textconv tests; Perl not available'
- test_done
-fi
-
find_diff() {
sed '1,/^index /d' | sed '/^-- $/,$d'
}
@@ -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
test_commit --printf one file "\\0\\n" &&
test_commit --printf --append two file "\\01\\n"
'