Skip to content

Commit f6033be

Browse files
committed
Make MSWin32 Perl available to all tests
Pull out the logic to find a MSWin32 build of Perl, so it can be used by all tests. Signed-off-by: Chris Lindee <[email protected]>
1 parent 5d4934a commit f6033be

File tree

4 files changed

+34
-17
lines changed

4 files changed

+34
-17
lines changed

Makefile

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2475,6 +2475,19 @@ LIB_PERL_GEN := $(patsubst perl/%.pm,perl/build/lib/%.pm,$(LIB_PERL))
24752475
LIB_CPAN := $(wildcard perl/FromCPAN/*.pm perl/FromCPAN/*/*.pm)
24762476
LIB_CPAN_GEN := $(patsubst perl/%.pm,perl/build/lib/%.pm,$(LIB_CPAN))
24772477

2478+
# Set MSWIN32_PERL_PATH=false to disable search
2479+
ifndef MSWIN32_PERL_PATH
2480+
MSWIN32_PERL_PATH = $(shell \
2481+
for perl in $$(type -ap perl); do \
2482+
if "$$perl" -e 'exit 1 if $$^O ne q{MSWin32}'; then \
2483+
echo "$$perl"; \
2484+
exit 0; \
2485+
fi; \
2486+
done \
2487+
)
2488+
endif
2489+
MSWIN32_PERL_PATH_SQ = $(subst ','\'',$(MSWIN32_PERL_PATH))
2490+
24782491
ifndef NO_PERL
24792492
all:: $(LIB_PERL_GEN)
24802493
ifndef NO_PERL_CPAN_FALLBACKS
@@ -2573,6 +2586,7 @@ GIT-BUILD-OPTIONS: FORCE
25732586
@echo PAGER_ENV=\''$(subst ','\'',$(subst ','\'',$(PAGER_ENV)))'\' >>$@+
25742587
@echo DC_SHA1=\''$(subst ','\'',$(subst ','\'',$(DC_SHA1)))'\' >>$@+
25752588
@echo X=\'$(X)\' >>$@+
2589+
@echo MSWIN32_PERL_PATH=\''$(subst ','\'',$(MSWIN32_PERL_PATH_SQ))'\' >>$@+
25762590
ifdef TEST_OUTPUT_DIRECTORY
25772591
@echo TEST_OUTPUT_DIRECTORY=\''$(subst ','\'',$(subst ','\'',$(TEST_OUTPUT_DIRECTORY)))'\' >>$@+
25782592
endif

t/t9701-perl-git-MSWin32.sh

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,24 +6,12 @@
66
test_description='perl interface (Git.pm) on MSWin32'
77
. ./test-lib.sh
88

9-
find_MSWin32_perl() {
10-
local perl
11-
for perl in $(type -ap perl); do
12-
if "$perl" -e 'exit 1 if $^O ne q{MSWin32}'; then
13-
echo "$perl"
14-
return 0
15-
fi
16-
done
17-
return 1
18-
}
19-
20-
MSWin32_Perl="$(find_MSWin32_perl)"
21-
if [ $? -ne 0 ]; then
9+
if ! test_have_prereq MSWIN32_PERL; then
2210
skip_all='skipping perl on MSWin32 interface tests, MSWin32 perl not available'
2311
test_done
2412
fi
2513

26-
"$MSWin32_Perl" -MTest::More -e 0 2>/dev/null || {
14+
mswin32_perl -MTest::More -e 0 2>/dev/null || {
2715
skip_all="MSWin32 Perl Test::More unavailable, skipping test"
2816
test_done
2917
}
@@ -35,11 +23,10 @@ test_external_has_tap=1
3523
perl_test_path="$TEST_DIRECTORY"/t9701/test.pl
3624
if test_have_prereq CYGWIN || test_have_prereq MINGW; then
3725
perl_test_path="$(cygpath -w "$perl_test_path")"
38-
GITPERLLIB="$(cygpath -w -p "$GITPERLLIB")"
3926
fi
4027

4128
test_external_without_stderr \
4229
'Windows command line (Perl API)' \
43-
"$MSWin32_Perl" "$perl_test_path"
30+
mswin32_perl "$perl_test_path"
4431

4532
test_done

t/test-lib-functions.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -933,6 +933,14 @@ perl () {
933933
command "$PERL_PATH" "$@" 2>&7
934934
} 7>&2 2>&4
935935

936+
mswin32_perl () {
937+
local GITPERLLIB="$GITPERLLIB"
938+
if test_have_prereq CYGWIN || test_have_prereq MINGW; then
939+
GITPERLLIB="$(cygpath -w -p "$GITPERLLIB")"
940+
fi
941+
command "$MSWIN32_PERL_PATH" "$@" 2>&7
942+
} 7>&2 2>&4
943+
936944
# Is the value one of the various ways to spell a boolean true/false?
937945
test_normalize_bool () {
938946
git -c magic.variable="$1" config --bool magic.variable 2>/dev/null

t/test-lib.sh

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ then
6464
exit 1
6565
fi
6666
. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS
67-
export PERL_PATH SHELL_PATH
67+
export MSWIN32_PERL_PATH PERL_PATH SHELL_PATH
6868

6969
################################################################
7070
# It appears that people try to run tests without building...
@@ -1268,3 +1268,11 @@ test_lazy_prereq CURL '
12681268
test_lazy_prereq SHA1 '
12691269
test $(git hash-object /dev/null) = e69de29bb2d1d6434b8b29ae775ad8c2e48c5391
12701270
'
1271+
1272+
# Some tests require a native Win32 Perl interpreter, such as Strawberry Perl
1273+
# or ActiveState Perl, which is not distributed with Git for Windows. These
1274+
# tests only run if an appropriate Perl is specified (via MSWIN32_PERL_PATH).
1275+
test_lazy_prereq MSWIN32_PERL '
1276+
test -n "$MSWIN32_PERL_PATH" &&
1277+
$MSWIN32_PERL_PATH -e "exit 1 if \$^O ne q{MSWin32}"
1278+
'

0 commit comments

Comments
 (0)