Skip to content

Commit a3a9cff

Browse files
committed
Merge branch 'jk/wrap-perl-used-in-tests'
* jk/wrap-perl-used-in-tests: t: use perl instead of "$PERL_PATH" where applicable t: provide a perl() function which uses $PERL_PATH
2 parents 68d5fbe + 94221d2 commit a3a9cff

29 files changed

+62
-54
lines changed

t/README

+8-4
Original file line numberDiff line numberDiff line change
@@ -340,7 +340,11 @@ Don't:
340340
- use perl without spelling it as "$PERL_PATH". This is to help our
341341
friends on Windows where the platform Perl often adds CR before
342342
the end of line, and they bundle Git with a version of Perl that
343-
does not do so, whose path is specified with $PERL_PATH.
343+
does not do so, whose path is specified with $PERL_PATH. Note that we
344+
provide a "perl" function which uses $PERL_PATH under the hood, so
345+
you do not need to worry when simply running perl in the test scripts
346+
(but you do, for example, on a shebang line or in a sub script
347+
created via "write_script").
344348

345349
- use sh without spelling it as "$SHELL_PATH", when the script can
346350
be misinterpreted by broken platform shell (e.g. Solaris).
@@ -387,7 +391,7 @@ of the test_* functions (see the "Test harness library" section
387391
below), e.g.:
388392

389393
test_expect_success PERL 'I need Perl' '
390-
"$PERL_PATH" -e "hlagh() if unf_unf()"
394+
perl -e "hlagh() if unf_unf()"
391395
'
392396

393397
The advantage of skipping tests like this is that platforms that don't
@@ -520,7 +524,7 @@ library for your script to use.
520524

521525
test_external \
522526
'GitwebCache::*FileCache*' \
523-
"$PERL_PATH" "$TEST_DIRECTORY"/t9503/test_cache_interface.pl
527+
perl "$TEST_DIRECTORY"/t9503/test_cache_interface.pl
524528

525529
If the test is outputting its own TAP you should set the
526530
test_external_has_tap variable somewhere before calling the first
@@ -536,7 +540,7 @@ library for your script to use.
536540

537541
test_external_without_stderr \
538542
'Perl API' \
539-
"$PERL_PATH" "$TEST_DIRECTORY"/t9700/test.pl
543+
perl "$TEST_DIRECTORY"/t9700/test.pl
540544

541545
- test_expect_code <exit-code> <command>
542546

t/gitweb-lib.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ gitweb_run () {
6969
# written to web server logs, so we are not interested in that:
7070
# we are interested only in properly formatted errors/warnings
7171
rm -f gitweb.log &&
72-
"$PERL_PATH" -- "$SCRIPT_NAME" \
72+
perl -- "$SCRIPT_NAME" \
7373
>gitweb.output 2>gitweb.log &&
7474
perl -w -e '
7575
open O, ">gitweb.headers";

t/lib-git-svn.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ export svnrepo
2929
svnconf=$PWD/svnconf
3030
export svnconf
3131

32-
"$PERL_PATH" -w -e "
32+
perl -w -e "
3333
use SVN::Core;
3434
use SVN::Repos;
3535
\$SVN::Core::VERSION gt '1.1.0' or exit(42);
@@ -146,7 +146,7 @@ stop_httpd () {
146146
}
147147

148148
convert_to_rev_db () {
149-
"$PERL_PATH" -w -- - "$@" <<\EOF
149+
perl -w -- - "$@" <<\EOF
150150
use strict;
151151
@ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
152152
open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";

t/lib-terminal.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ test_expect_success PERL 'set up terminal for tests' '
1919
then
2020
:
2121
elif
22-
"$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl \
22+
perl "$TEST_DIRECTORY"/test-terminal.perl \
2323
sh -c "test -t 1 && test -t 2"
2424
then
2525
test_set_prereq TTY &&
@@ -29,7 +29,7 @@ test_expect_success PERL 'set up terminal for tests' '
2929
echo >&4 "test_terminal: need to declare TTY prerequisite"
3030
return 127
3131
fi
32-
"$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl "$@"
32+
perl "$TEST_DIRECTORY"/test-terminal.perl "$@"
3333
}
3434
fi
3535
'

t/t0202-gettext-perl.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ if ! test_have_prereq PERL; then
1212
test_done
1313
fi
1414

15-
"$PERL_PATH" -MTest::More -e 0 2>/dev/null || {
15+
perl -MTest::More -e 0 2>/dev/null || {
1616
skip_all="Perl Test::More unavailable, skipping test"
1717
test_done
1818
}
@@ -22,6 +22,6 @@ test_external_has_tap=1
2222

2323
test_external_without_stderr \
2424
'Perl Git::I18N API' \
25-
"$PERL_PATH" "$TEST_DIRECTORY"/t0202/test.pl
25+
perl "$TEST_DIRECTORY"/t0202/test.pl
2626

2727
test_done

t/t1010-mktree.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,13 @@ test_expect_success 'ls-tree piped to mktree (2)' '
4242
'
4343

4444
test_expect_success 'ls-tree output in wrong order given to mktree (1)' '
45-
"$PERL_PATH" -e "print reverse <>" <top |
45+
perl -e "print reverse <>" <top |
4646
git mktree >actual &&
4747
test_cmp tree actual
4848
'
4949

5050
test_expect_success 'ls-tree output in wrong order given to mktree (2)' '
51-
"$PERL_PATH" -e "print reverse <>" <top.withsub |
51+
perl -e "print reverse <>" <top.withsub |
5252
git mktree >actual &&
5353
test_cmp tree.withsub actual
5454
'

t/t3300-funny-names.sh

+3-3
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ test_expect_success 'ls-files -z does not quote funny filename' '
6969
tabs ," (dq) and spaces
7070
EOF
7171
git ls-files -z >ls-files.z &&
72-
"$PERL_PATH" -pe "y/\000/\012/" <ls-files.z >current &&
72+
perl -pe "y/\000/\012/" <ls-files.z >current &&
7373
test_cmp expected current
7474
'
7575

@@ -106,7 +106,7 @@ test_expect_success 'diff-index -z does not quote funny filename' '
106106
tabs ," (dq) and spaces
107107
EOF
108108
git diff-index -z --name-status $t0 >diff-index.z &&
109-
"$PERL_PATH" -pe "y/\000/\012/" <diff-index.z >current &&
109+
perl -pe "y/\000/\012/" <diff-index.z >current &&
110110
test_cmp expected current
111111
'
112112

@@ -116,7 +116,7 @@ test_expect_success 'diff-tree -z does not quote funny filename' '
116116
tabs ," (dq) and spaces
117117
EOF
118118
git diff-tree -z --name-status $t0 $t1 >diff-tree.z &&
119-
"$PERL_PATH" -pe y/\\000/\\012/ <diff-tree.z >current &&
119+
perl -pe y/\\000/\\012/ <diff-tree.z >current &&
120120
test_cmp expected current
121121
'
122122

t/t4014-format-patch.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -293,7 +293,7 @@ check_threading () {
293293
(git format-patch --stdout "$@"; echo $? > status.out) |
294294
# Prints everything between the Message-ID and In-Reply-To,
295295
# and replaces all Message-ID-lookalikes by a sequence number
296-
"$PERL_PATH" -ne '
296+
perl -ne '
297297
if (/^(message-id|references|in-reply-to)/i) {
298298
$printing = 1;
299299
} elsif (/^\S/) {

t/t4020-diff-external.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,7 @@ test_expect_success 'no diff with -diff' '
177177
git diff | grep Binary
178178
'
179179

180-
echo NULZbetweenZwords | "$PERL_PATH" -pe 'y/Z/\000/' > file
180+
echo NULZbetweenZwords | perl -pe 'y/Z/\000/' > file
181181

182182
test_expect_success 'force diff with "diff"' '
183183
echo >.gitattributes "file diff" &&

t/t4029-diff-trailing-space.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test_expect_success \
2727
git config --bool diff.suppressBlankEmpty true &&
2828
git diff f > actual &&
2929
test_cmp exp actual &&
30-
"$PERL_PATH" -i.bak -p -e "s/^\$/ /" exp &&
30+
perl -i.bak -p -e "s/^\$/ /" exp &&
3131
git config --bool diff.suppressBlankEmpty false &&
3232
git diff f > actual &&
3333
test_cmp exp actual &&

t/t4103-apply-binary.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,10 @@ test_expect_success 'setup' '
2323
git commit -m "Initial Version" 2>/dev/null &&
2424
2525
git checkout -b binary &&
26-
"$PERL_PATH" -pe "y/x/\000/" <file1 >file3 &&
26+
perl -pe "y/x/\000/" <file1 >file3 &&
2727
cat file3 >file4 &&
2828
git add file2 &&
29-
"$PERL_PATH" -pe "y/\000/v/" <file3 >file1 &&
29+
perl -pe "y/\000/v/" <file3 >file1 &&
3030
rm -f file2 &&
3131
git update-index --add --remove file1 file2 file3 file4 &&
3232
git commit -m "Second Version" &&

t/t4116-apply-reverse.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,14 @@ test_description='git apply in reverse
1212
test_expect_success setup '
1313
1414
for i in a b c d e f g h i j k l m n; do echo $i; done >file1 &&
15-
"$PERL_PATH" -pe "y/ijk/\\000\\001\\002/" <file1 >file2 &&
15+
perl -pe "y/ijk/\\000\\001\\002/" <file1 >file2 &&
1616
1717
git add file1 file2 &&
1818
git commit -m initial &&
1919
git tag initial &&
2020
2121
for i in a b c g h i J K L m o n p q; do echo $i; done >file1 &&
22-
"$PERL_PATH" -pe "y/mon/\\000\\001\\002/" <file1 >file2 &&
22+
perl -pe "y/mon/\\000\\001\\002/" <file1 >file2 &&
2323
2424
git commit -a -m second &&
2525
git tag second &&

t/t4200-rerere.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ test_expect_success 'activate rerere, old style (conflicting merge)' '
7878
test_might_fail git config --unset rerere.enabled &&
7979
test_must_fail git merge first &&
8080
81-
sha1=$("$PERL_PATH" -pe "s/ .*//" .git/MERGE_RR) &&
81+
sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
8282
rr=.git/rr-cache/$sha1 &&
8383
grep "^=======\$" $rr/preimage &&
8484
! test -f $rr/postimage &&
@@ -91,7 +91,7 @@ test_expect_success 'rerere.enabled works, too' '
9191
git reset --hard &&
9292
test_must_fail git merge first &&
9393
94-
sha1=$("$PERL_PATH" -pe "s/ .*//" .git/MERGE_RR) &&
94+
sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
9595
rr=.git/rr-cache/$sha1 &&
9696
grep ^=======$ $rr/preimage
9797
'
@@ -101,7 +101,7 @@ test_expect_success 'set up rr-cache' '
101101
git config rerere.enabled true &&
102102
git reset --hard &&
103103
test_must_fail git merge first &&
104-
sha1=$("$PERL_PATH" -pe "s/ .*//" .git/MERGE_RR) &&
104+
sha1=$(perl -pe "s/ .*//" .git/MERGE_RR) &&
105105
rr=.git/rr-cache/$sha1
106106
'
107107

@@ -185,7 +185,7 @@ test_expect_success 'rerere updates postimage timestamp' '
185185

186186
test_expect_success 'rerere clear' '
187187
rm $rr/postimage &&
188-
echo "$sha1 a1" | "$PERL_PATH" -pe "y/\012/\000/" >.git/MERGE_RR &&
188+
echo "$sha1 a1" | perl -pe "y/\012/\000/" >.git/MERGE_RR &&
189189
git rerere clear &&
190190
! test -d $rr
191191
'

t/t5300-pack-object.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,9 @@ TRASH=`pwd`
1313
test_expect_success \
1414
'setup' \
1515
'rm -f .git/index* &&
16-
"$PERL_PATH" -e "print \"a\" x 4096;" > a &&
17-
"$PERL_PATH" -e "print \"b\" x 4096;" > b &&
18-
"$PERL_PATH" -e "print \"c\" x 4096;" > c &&
16+
perl -e "print \"a\" x 4096;" > a &&
17+
perl -e "print \"b\" x 4096;" > b &&
18+
perl -e "print \"c\" x 4096;" > c &&
1919
test-genrandom "seed a" 2097152 > a_big &&
2020
test-genrandom "seed b" 2097152 > b_big &&
2121
git update-index --add a a_big b b_big c &&
@@ -129,7 +129,7 @@ test_expect_success \
129129
cd "$TRASH"
130130

131131
test_expect_success 'compare delta flavors' '
132-
"$PERL_PATH" -e '\''
132+
perl -e '\''
133133
defined($_ = -s $_) or die for @ARGV;
134134
exit 1 if $ARGV[0] <= $ARGV[1];
135135
'\'' test-2-$packname_2.pack test-3-$packname_3.pack

t/t5303-pack-corruption-resilience.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ test_expect_success \
9898
'create_new_pack &&
9999
git prune-packed &&
100100
chmod +w ${pack}.pack &&
101-
"$PERL_PATH" -i.bak -pe "s/ base /abcdef/" ${pack}.pack &&
101+
perl -i.bak -pe "s/ base /abcdef/" ${pack}.pack &&
102102
test_must_fail git cat-file blob $blob_1 > /dev/null &&
103103
test_must_fail git cat-file blob $blob_2 > /dev/null &&
104104
test_must_fail git cat-file blob $blob_3 > /dev/null'
@@ -155,7 +155,7 @@ test_expect_success \
155155
'create_new_pack &&
156156
git prune-packed &&
157157
chmod +w ${pack}.pack &&
158-
"$PERL_PATH" -i.bak -pe "s/ delta1 /abcdefgh/" ${pack}.pack &&
158+
perl -i.bak -pe "s/ delta1 /abcdefgh/" ${pack}.pack &&
159159
git cat-file blob $blob_1 > /dev/null &&
160160
test_must_fail git cat-file blob $blob_2 > /dev/null &&
161161
test_must_fail git cat-file blob $blob_3 > /dev/null'

t/t5551-http-fetch.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -235,7 +235,7 @@ test_expect_success EXPENSIVE 'create 50,000 tags in the repo' '
235235
done | git fast-import --export-marks=marks &&
236236
237237
# now assign tags to all the dangling commits we created above
238-
tag=$("$PERL_PATH" -e "print \"bla\" x 30") &&
238+
tag=$(perl -e "print \"bla\" x 30") &&
239239
sed -e "s|^:\([^ ]*\) \(.*\)$|\2 refs/tags/$tag-\1|" <marks >>packed-refs
240240
)
241241
'

t/t6011-rev-list-with-bad-commit.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ test_expect_success 'verify number of revisions' \
3737

3838
test_expect_success 'corrupt second commit object' \
3939
'
40-
"$PERL_PATH" -i.bak -pe "s/second commit/socond commit/" .git/objects/pack/*.pack &&
40+
perl -i.bak -pe "s/second commit/socond commit/" .git/objects/pack/*.pack &&
4141
test_must_fail git fsck --full
4242
'
4343

t/t6013-rev-list-reverse-parents.sh

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@ test_expect_success 'set up --reverse example' '
2525

2626
test_expect_success '--reverse --parents --full-history combines correctly' '
2727
git rev-list --parents --full-history master -- foo |
28-
"$PERL_PATH" -e "print reverse <>" > expected &&
28+
perl -e "print reverse <>" > expected &&
2929
git rev-list --reverse --parents --full-history master -- foo \
3030
> actual &&
3131
test_cmp actual expected
3232
'
3333

3434
test_expect_success '--boundary does too' '
3535
git rev-list --boundary --parents --full-history master ^root -- foo |
36-
"$PERL_PATH" -e "print reverse <>" > expected &&
36+
perl -e "print reverse <>" > expected &&
3737
git rev-list --boundary --reverse --parents --full-history \
3838
master ^root -- foo > actual &&
3939
test_cmp actual expected

t/t7508-status.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -994,7 +994,7 @@ test_expect_success 'status -s submodule summary (clean submodule)' '
994994

995995
test_expect_success 'status -z implies porcelain' '
996996
git status --porcelain |
997-
"$PERL_PATH" -pe "s/\012/\000/g" >expect &&
997+
perl -pe "s/\012/\000/g" >expect &&
998998
git status -z >output &&
999999
test_cmp expect output
10001000
'

t/t9129-git-svn-i18n-commitencoding.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ fi
2929
compare_svn_head_with () {
3030
# extract just the log message and strip out committer info.
3131
# don't use --limit here since svn 1.1.x doesn't have it,
32-
LC_ALL="$a_utf8_locale" svn log `git svn info --url` | "$PERL_PATH" -w -e '
32+
LC_ALL="$a_utf8_locale" svn log `git svn info --url` | perl -w -e '
3333
use bytes;
3434
$/ = ("-"x72) . "\n";
3535
my @x = <STDIN>;

t/t9137-git-svn-dcommit-clobber-series.sh

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ test_expect_success '(supposedly) non-conflicting change from SVN' '
2020
test x"`sed -n -e 61p < file`" = x61 &&
2121
svn_cmd co "$svnrepo" tmp &&
2222
(cd tmp &&
23-
"$PERL_PATH" -i.bak -p -e "s/^58$/5588/" file &&
24-
"$PERL_PATH" -i.bak -p -e "s/^61$/6611/" file &&
23+
perl -i.bak -p -e "s/^58$/5588/" file &&
24+
perl -i.bak -p -e "s/^61$/6611/" file &&
2525
poke file &&
2626
test x"`sed -n -e 58p < file`" = x5588 &&
2727
test x"`sed -n -e 61p < file`" = x6611 &&
@@ -40,8 +40,8 @@ test_expect_success 'some unrelated changes to git' "
4040
test_expect_success 'change file but in unrelated area' "
4141
test x\"\`sed -n -e 4p < file\`\" = x4 &&
4242
test x\"\`sed -n -e 7p < file\`\" = x7 &&
43-
"$PERL_PATH" -i.bak -p -e 's/^4\$/4444/' file &&
44-
"$PERL_PATH" -i.bak -p -e 's/^7\$/7777/' file &&
43+
perl -i.bak -p -e 's/^4\$/4444/' file &&
44+
perl -i.bak -p -e 's/^7\$/7777/' file &&
4545
test x\"\`sed -n -e 4p < file\`\" = x4444 &&
4646
test x\"\`sed -n -e 7p < file\`\" = x7777 &&
4747
git commit -m '4 => 4444, 7 => 7777' file &&

t/t9300-fast-import.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ test_description='test git fast-import utility'
1212
# This could be written as "head -c $1", but IRIX "head" does not
1313
# support the -c option.
1414
head_c () {
15-
"$PERL_PATH" -e '
15+
perl -e '
1616
my $len = $ARGV[1];
1717
while ($len > 0) {
1818
my $s;

t/t9350-fast-export.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -429,7 +429,7 @@ test_expect_success 'fast-export quotes pathnames' '
429429
--cacheinfo 100644 $blob "path with \\backslash" \
430430
--cacheinfo 100644 $blob "path with space" &&
431431
git commit -m addition &&
432-
git ls-files -z -s | "$PERL_PATH" -0pe "s{\\t}{$&subdir/}" >index &&
432+
git ls-files -z -s | perl -0pe "s{\\t}{$&subdir/}" >index &&
433433
git read-tree --empty &&
434434
git update-index -z --index-info <index &&
435435
git commit -m rename &&

t/t9400-git-cvsserver-server.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ then
2020
skip_all='skipping git-cvsserver tests, cvs not found'
2121
test_done
2222
fi
23-
"$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
23+
perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
2424
skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
2525
test_done
2626
}

t/t9401-git-cvsserver-crlf.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ then
6868
skip_all='skipping git-cvsserver tests, perl not available'
6969
test_done
7070
fi
71-
"$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
71+
perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
7272
skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
7373
test_done
7474
}

t/t9402-git-cvsserver-refs.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ then
7676
skip_all='skipping git-cvsserver tests, perl not available'
7777
test_done
7878
fi
79-
"$PERL_PATH" -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
79+
perl -e 'use DBI; use DBD::SQLite' >/dev/null 2>&1 || {
8080
skip_all='skipping git-cvsserver tests, Perl SQLite interface unavailable'
8181
test_done
8282
}

0 commit comments

Comments
 (0)