Git fork

t: refactor tests depending on Perl transliteration operator

We have a bunch of tests that use Perl to perform character
transliteration via the "y/" or "tr/" operator. These usecases can be
trivially replaced with tr(1).

Refactor the tests accordingly so that we can drop a couple of
PERL_TEST_HELPERS prerequisites.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>

authored by

Patrick Steinhardt and committed by
Junio C Hamano
db8ff64a 8d531a9d

+19 -31
+2 -2
t/helper/test-sha1.sh
··· 15 15 { 16 16 test -z "$pfx" || echo "$pfx" 17 17 dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null | 18 - perl -pe 'y/\000/g/' 18 + tr "\000" "g" 19 19 } | ./t/helper/test-tool $sha1 $cnt 20 20 ) 21 21 if test "$expect" = "$actual" ··· 61 61 { 62 62 test -z "$pfx" || echo "$pfx" 63 63 dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null | 64 - perl -pe 'y/\000/g/' 64 + tr "\000" "g" 65 65 } | sha1sum | 66 66 sed -e 's/ .*//' 67 67 )
+2 -2
t/lib-diff.sh
··· 21 21 # Also we do not check SHA1 hash generation in this test, which 22 22 # is a job for t0000-basic.sh 23 23 24 - perl -pe 'y/\000/\012/' <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1 25 - perl -pe 'y/\000/\012/' <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2 24 + tr "\000" "\012" <"$1" | sed -e "$sanitize_diff_raw_z" >.tmp-1 25 + tr "\000" "\012" <"$2" | sed -e "$sanitize_diff_raw_z" >.tmp-2 26 26 test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2 27 27 } 28 28
+6 -6
t/t3300-funny-names.sh
··· 63 63 test_cmp expected current 64 64 ' 65 65 66 - test_expect_success PERL_TEST_HELPERS 'ls-files -z does not quote funny filename' ' 66 + test_expect_success 'ls-files -z does not quote funny filename' ' 67 67 cat >expected <<-\EOF && 68 68 just space 69 69 no-funny 70 70 tabs ," (dq) and spaces 71 71 EOF 72 72 git ls-files -z >ls-files.z && 73 - perl -pe "y/\000/\012/" <ls-files.z >current && 73 + tr "\000" "\012" <ls-files.z >current && 74 74 test_cmp expected current 75 75 ' 76 76 ··· 101 101 test_cmp expected current 102 102 ' 103 103 104 - test_expect_success PERL_TEST_HELPERS 'diff-index -z does not quote funny filename' ' 104 + test_expect_success 'diff-index -z does not quote funny filename' ' 105 105 cat >expected <<-\EOF && 106 106 A 107 107 tabs ," (dq) and spaces 108 108 EOF 109 109 git diff-index -z --name-status $t0 >diff-index.z && 110 - perl -pe "y/\000/\012/" <diff-index.z >current && 110 + tr "\000" "\012" <diff-index.z >current && 111 111 test_cmp expected current 112 112 ' 113 113 114 - test_expect_success PERL_TEST_HELPERS 'diff-tree -z does not quote funny filename' ' 114 + test_expect_success 'diff-tree -z does not quote funny filename' ' 115 115 cat >expected <<-\EOF && 116 116 A 117 117 tabs ," (dq) and spaces 118 118 EOF 119 119 git diff-tree -z --name-status $t0 $t1 >diff-tree.z && 120 - perl -pe y/\\000/\\012/ <diff-tree.z >current && 120 + tr "\000" "\012" <diff-tree.z >current && 121 121 test_cmp expected current 122 122 ' 123 123
+3 -3
t/t4020-diff-external.sh
··· 237 237 check_external_diff 1 empty empty 1 on --quiet 238 238 check_external_diff 128 empty error 2 on --quiet 239 239 240 - echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file 240 + echo NULZbetweenZwords | tr "Z" "\000" > file 241 241 242 - test_expect_success PERL_TEST_HELPERS 'force diff with "diff"' ' 242 + test_expect_success 'force diff with "diff"' ' 243 243 after=$(git hash-object file) && 244 244 after=$(git rev-parse --short $after) && 245 245 echo >.gitattributes "file diff" && ··· 300 300 test $(wc -l <crlfed.txt) = $(keep_only_cr <crlfed.txt | wc -c) 301 301 ' 302 302 303 - test_expect_success PERL_TEST_HELPERS 'diff --cached' ' 303 + test_expect_success 'diff --cached' ' 304 304 test_config core.autocrlf true && 305 305 git add file && 306 306 git update-index --assume-unchanged file &&
+3 -9
t/t4103-apply-binary.sh
··· 11 11 12 12 . ./test-lib.sh 13 13 14 - if ! test_have_prereq PERL_TEST_HELPERS 15 - then 16 - skip_all='skipping apply-binary tests; Perl not available' 17 - test_done 18 - fi 19 - 20 14 test_expect_success 'setup' ' 21 15 cat >file1 <<-\EOF && 22 16 A quick brown fox jumps over the lazy dog. ··· 32 26 git commit -m "Initial Version" 2>/dev/null && 33 27 34 28 git checkout -b binary && 35 - perl -pe "y/x/\000/" <file1 >file3 && 29 + tr "x" "\000" <file1 >file3 && 36 30 cat file3 >file4 && 37 31 git add file2 && 38 - perl -pe "y/\000/v/" <file3 >file1 && 32 + tr "y" "\000" <file3 >file1 && 39 33 rm -f file2 && 40 34 git update-index --add --remove file1 file2 file3 file4 && 41 35 git commit -m "Second Version" && ··· 164 158 test -z "$(git diff --name-status binary -- file3)" 165 159 ' 166 160 167 - test_expect_success 'reject truncated binary diff' ' 161 + test_expect_success PERL_TEST_HELPERS 'reject truncated binary diff' ' 168 162 do_reset && 169 163 170 164 # this length is calculated to get us very close to
+2 -8
t/t4116-apply-reverse.sh
··· 10 10 11 11 . ./test-lib.sh 12 12 13 - if ! test_have_prereq PERL_TEST_HELPERS 14 - then 15 - skip_all='skipping apply reverse tests; Perl not available' 16 - test_done 17 - fi 18 - 19 13 test_expect_success setup ' 20 14 21 15 test_write_lines a b c d e f g h i j k l m n >file1 && 22 - perl -pe "y/ijk/\\000\\001\\002/" <file1 >file2 && 16 + tr "ijk" "\000\001\002" <file1 >file2 && 23 17 24 18 git add file1 file2 && 25 19 git commit -m initial && 26 20 git tag initial && 27 21 28 22 test_write_lines a b c g h i J K L m o n p q >file1 && 29 - perl -pe "y/mon/\\000\\001\\002/" <file1 >file2 && 23 + tr "mon" "\000\001\002" <file1 >file2 && 30 24 31 25 git commit -a -m second && 32 26 git tag second &&
+1 -1
t/t4200-rerere.sh
··· 194 194 195 195 test_expect_success 'rerere clear' ' 196 196 mv $rr/postimage .git/post-saved && 197 - echo "$sha1 a1" | perl -pe "y/\012/\000/" >.git/MERGE_RR && 197 + echo "$sha1 a1" | tr "\012" "\000" >.git/MERGE_RR && 198 198 git rerere clear && 199 199 ! test -d $rr 200 200 '