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>
This commit is contained in:
committed by
Junio C Hamano
parent
6aec8d38fd
commit
4a7af4edbb
@@ -4,12 +4,6 @@ test_description='git grep in binary files'
|
||||
|
||||
. ./test-lib.sh
|
||||
|
||||
if ! test_have_prereq PERL_TEST_HELPERS
|
||||
then
|
||||
skip_all='skipping grep binary tests; Perl not available'
|
||||
test_done
|
||||
fi
|
||||
|
||||
test_expect_success 'setup' "
|
||||
echo 'binaryQfileQm[*]cQ*æQð' | q_to_nul >a &&
|
||||
git add a &&
|
||||
@@ -120,13 +114,10 @@ test_expect_success 'grep respects not-binary diff attribute' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
cat >nul_to_q_textconv <<'EOF'
|
||||
#!/bin/sh
|
||||
"$PERL_PATH" -pe 'y/\000/Q/' < "$1"
|
||||
EOF
|
||||
chmod +x nul_to_q_textconv
|
||||
|
||||
test_expect_success 'setup textconv filters' '
|
||||
write_script nul_to_q_textconv <<-\EOF &&
|
||||
tr "\000" "Q" <"$1"
|
||||
EOF
|
||||
echo a diff=foo >.gitattributes &&
|
||||
git config diff.foo.textconv "\"$(pwd)\""/nul_to_q_textconv
|
||||
'
|
||||
|
||||
Reference in New Issue
Block a user