Skip to content

Commit 64f3f5a

Browse files
avargitster
authored andcommitted
tests: move copy/pasted PERL + Test::More checks to a lib-perl.sh
Since the original "perl -MTest::More" prerequisite check was added in [1] it's been copy/pasted in [2], [3] and [4]. As we'll be changing these codepaths in a subsequent commit let's consolidate these. While we're at it let's move these to a lazy prereq, and make them conform to our usual coding style (e.g. "\nthen", not "; then"). 1. e46f9c8 (t9700: skip when Test::More is not available, 2008-06-29) 2. 5e9637c (i18n: add infrastructure for translating Git with gettext, 2011-11-18) 3. 8d314d7 (send-email: reduce dependencies impact on parse_address_line, 2015-07-07) 4. f07eeed (git-credential-netrc: adapt to test framework for git, 2018-05-12) Signed-off-by: Ævar Arnfjörð Bjarmason <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent fee65b1 commit 64f3f5a

File tree

4 files changed

+25
-28
lines changed

4 files changed

+25
-28
lines changed

contrib/credential/netrc/t-git-credential-netrc.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,9 @@
33
cd ../../../t
44
test_description='git-credential-netrc'
55
. ./test-lib.sh
6+
. "$TEST_DIRECTORY"/lib-perl.sh
67

7-
if ! test_have_prereq PERL; then
8-
skip_all='skipping perl interface tests, perl not available'
9-
test_done
10-
fi
11-
12-
perl -MTest::More -e 0 2>/dev/null || {
13-
skip_all="Perl Test::More unavailable, skipping test"
14-
test_done
15-
}
8+
skip_all_if_no_Test_More
169

1710
# set up test repository
1811

t/lib-perl.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
# Copyright (c) 2022 Ævar Arnfjörð Bjarmason
2+
3+
test_lazy_prereq PERL_TEST_MORE '
4+
perl -MTest::More -e 0
5+
'
6+
7+
skip_all_if_no_Test_More () {
8+
if ! test_have_prereq PERL
9+
then
10+
skip_all='skipping perl interface tests, perl not available'
11+
test_done
12+
fi
13+
14+
if ! test_have_prereq PERL_TEST_MORE
15+
then
16+
skip_all="Perl Test::More unavailable, skipping test"
17+
test_done
18+
fi
19+
}

t/t0202-gettext-perl.sh

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,8 @@ test_description='Perl gettext interface (Git::I18N)'
77

88
TEST_PASSES_SANITIZE_LEAK=true
99
. ./lib-gettext.sh
10-
11-
if ! test_have_prereq PERL; then
12-
skip_all='skipping perl interface tests, perl not available'
13-
test_done
14-
fi
15-
16-
perl -MTest::More -e 0 2>/dev/null || {
17-
skip_all="Perl Test::More unavailable, skipping test"
18-
test_done
19-
}
10+
. "$TEST_DIRECTORY"/lib-perl.sh
11+
skip_all_if_no_Test_More
2012

2113
# The external test will outputs its own plan
2214
test_external_has_tap=1

t/t9700-perl-git.sh

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,9 @@
55

66
test_description='perl interface (Git.pm)'
77
. ./test-lib.sh
8+
. "$TEST_DIRECTORY"/lib-perl.sh
89

9-
if ! test_have_prereq PERL; then
10-
skip_all='skipping perl interface tests, perl not available'
11-
test_done
12-
fi
13-
14-
perl -MTest::More -e 0 2>/dev/null || {
15-
skip_all="Perl Test::More unavailable, skipping test"
16-
test_done
17-
}
10+
skip_all_if_no_Test_More
1811

1912
# set up test repository
2013

0 commit comments

Comments
 (0)