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

Lines changed: 8 additions & 4 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 2 additions & 2 deletions
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

Lines changed: 3 additions & 3 deletions
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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

Lines changed: 1 addition & 1 deletion
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 &&

0 commit comments

Comments
 (0)