Skip to content

Commit db8ff64

Browse files
pks-tgitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 8d531a9 commit db8ff64

File tree

7 files changed

+19
-31
lines changed

7 files changed

+19
-31
lines changed

t/helper/test-sha1.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ do
1515
{
1616
test -z "$pfx" || echo "$pfx"
1717
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
18-
perl -pe 'y/\000/g/'
18+
tr "\000" "g"
1919
} | ./t/helper/test-tool $sha1 $cnt
2020
)
2121
if test "$expect" = "$actual"
@@ -61,7 +61,7 @@ do
6161
{
6262
test -z "$pfx" || echo "$pfx"
6363
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
64-
perl -pe 'y/\000/g/'
64+
tr "\000" "g"
6565
} | sha1sum |
6666
sed -e 's/ .*//'
6767
)

t/lib-diff.sh

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,8 @@ compare_diff_raw_z () {
2121
# Also we do not check SHA1 hash generation in this test, which
2222
# is a job for t0000-basic.sh
2323

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
2626
test_cmp .tmp-1 .tmp-2 && rm -f .tmp-1 .tmp-2
2727
}
2828

t/t3300-funny-names.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ test_expect_success 'ls-files quotes funny filename' '
6363
test_cmp expected current
6464
'
6565

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' '
6767
cat >expected <<-\EOF &&
6868
just space
6969
no-funny
7070
tabs ," (dq) and spaces
7171
EOF
7272
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 &&
7474
test_cmp expected current
7575
'
7676

@@ -101,23 +101,23 @@ test_expect_success 'diff-tree --name-status quotes funny filename' '
101101
test_cmp expected current
102102
'
103103

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' '
105105
cat >expected <<-\EOF &&
106106
A
107107
tabs ," (dq) and spaces
108108
EOF
109109
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 &&
111111
test_cmp expected current
112112
'
113113

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' '
115115
cat >expected <<-\EOF &&
116116
A
117117
tabs ," (dq) and spaces
118118
EOF
119119
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 &&
121121
test_cmp expected current
122122
'
123123

t/t4020-diff-external.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -237,9 +237,9 @@ check_external_diff 0 empty empty 0 on --quiet
237237
check_external_diff 1 empty empty 1 on --quiet
238238
check_external_diff 128 empty error 2 on --quiet
239239

240-
echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
240+
echo NULZbetweenZwords | tr "Z" "\000" > file
241241

242-
test_expect_success PERL_TEST_HELPERS 'force diff with "diff"' '
242+
test_expect_success 'force diff with "diff"' '
243243
after=$(git hash-object file) &&
244244
after=$(git rev-parse --short $after) &&
245245
echo >.gitattributes "file diff" &&
@@ -300,7 +300,7 @@ test_expect_success 'external diff with autocrlf = true' '
300300
test $(wc -l <crlfed.txt) = $(keep_only_cr <crlfed.txt | wc -c)
301301
'
302302

303-
test_expect_success PERL_TEST_HELPERS 'diff --cached' '
303+
test_expect_success 'diff --cached' '
304304
test_config core.autocrlf true &&
305305
git add file &&
306306
git update-index --assume-unchanged file &&

t/t4103-apply-binary.sh

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME
1111

1212
. ./test-lib.sh
1313

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-
2014
test_expect_success 'setup' '
2115
cat >file1 <<-\EOF &&
2216
A quick brown fox jumps over the lazy dog.
@@ -32,10 +26,10 @@ test_expect_success 'setup' '
3226
git commit -m "Initial Version" 2>/dev/null &&
3327
3428
git checkout -b binary &&
35-
perl -pe "y/x/\000/" <file1 >file3 &&
29+
tr "x" "\000" <file1 >file3 &&
3630
cat file3 >file4 &&
3731
git add file2 &&
38-
perl -pe "y/\000/v/" <file3 >file1 &&
32+
tr "y" "\000" <file3 >file1 &&
3933
rm -f file2 &&
4034
git update-index --add --remove file1 file2 file3 file4 &&
4135
git commit -m "Second Version" &&
@@ -164,7 +158,7 @@ test_expect_success 'apply binary -p0 diff' '
164158
test -z "$(git diff --name-status binary -- file3)"
165159
'
166160

167-
test_expect_success 'reject truncated binary diff' '
161+
test_expect_success PERL_TEST_HELPERS 'reject truncated binary diff' '
168162
do_reset &&
169163
170164
# this length is calculated to get us very close to

t/t4116-apply-reverse.sh

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,17 @@ test_description='git apply in reverse
1010

1111
. ./test-lib.sh
1212

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-
1913
test_expect_success setup '
2014
2115
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 &&
2317
2418
git add file1 file2 &&
2519
git commit -m initial &&
2620
git tag initial &&
2721
2822
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 &&
3024
3125
git commit -a -m second &&
3226
git tag second &&

t/t4200-rerere.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ test_expect_success 'rerere updates postimage timestamp' '
194194

195195
test_expect_success 'rerere clear' '
196196
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 &&
198198
git rerere clear &&
199199
! test -d $rr
200200
'

0 commit comments

Comments
 (0)