]> git.ipfire.org Git - thirdparty/git.git/commitdiff
tests: move copy/pasted PERL + Test::More checks to a lib-perl.sh
authorÆvar Arnfjörð Bjarmason <avarab@gmail.com>
Wed, 27 Jul 2022 23:13:36 +0000 (01:13 +0200)
committerJunio C Hamano <gitster@pobox.com>
Wed, 27 Jul 2022 23:35:40 +0000 (16:35 -0700)
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. e46f9c8161a (t9700: skip when Test::More is not available,
   2008-06-29)
2. 5e9637c6297 (i18n: add infrastructure for translating Git with
   gettext, 2011-11-18)
3. 8d314d7afec (send-email: reduce dependencies impact on
   parse_address_line, 2015-07-07)
4. f07eeed123b (git-credential-netrc: adapt to test framework for git,
   2018-05-12)

Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
contrib/credential/netrc/t-git-credential-netrc.sh
t/lib-perl.sh [new file with mode: 0644]
t/t0202-gettext-perl.sh
t/t9700-perl-git.sh

index 07227d02287618394d649ae915a1b42d93140950..ff17a9460cdde3cfae0dc1db21a10be86c0efb65 100755 (executable)
@@ -3,16 +3,9 @@
        cd ../../../t
        test_description='git-credential-netrc'
        . ./test-lib.sh
+       . "$TEST_DIRECTORY"/lib-perl.sh
 
-       if ! test_have_prereq PERL; then
-               skip_all='skipping perl interface tests, perl not available'
-               test_done
-       fi
-
-       perl -MTest::More -e 0 2>/dev/null || {
-               skip_all="Perl Test::More unavailable, skipping test"
-               test_done
-       }
+       skip_all_if_no_Test_More
 
        # set up test repository
 
diff --git a/t/lib-perl.sh b/t/lib-perl.sh
new file mode 100644 (file)
index 0000000..d0bf509
--- /dev/null
@@ -0,0 +1,19 @@
+# Copyright (c) 2022 Ævar Arnfjörð Bjarmason
+
+test_lazy_prereq PERL_TEST_MORE '
+       perl -MTest::More -e 0
+'
+
+skip_all_if_no_Test_More () {
+       if ! test_have_prereq PERL
+       then
+               skip_all='skipping perl interface tests, perl not available'
+               test_done
+       fi
+
+       if ! test_have_prereq PERL_TEST_MORE
+       then
+               skip_all="Perl Test::More unavailable, skipping test"
+               test_done
+       fi
+}
index df2ea34932bcfe99cd5719cc2e2f587e6b09c49e..043b190626ce123e9cc3ff2f9cc23b3994b518cb 100755 (executable)
@@ -7,16 +7,8 @@ test_description='Perl gettext interface (Git::I18N)'
 
 TEST_PASSES_SANITIZE_LEAK=true
 . ./lib-gettext.sh
-
-if ! test_have_prereq PERL; then
-       skip_all='skipping perl interface tests, perl not available'
-       test_done
-fi
-
-perl -MTest::More -e 0 2>/dev/null || {
-       skip_all="Perl Test::More unavailable, skipping test"
-       test_done
-}
+. "$TEST_DIRECTORY"/lib-perl.sh
+skip_all_if_no_Test_More
 
 # The external test will outputs its own plan
 test_external_has_tap=1
index 102c133112c7149258d123b95acec807006890b7..17fc43f6e57a23e31c43b2a6f2919c86b85f0b5b 100755 (executable)
@@ -5,16 +5,9 @@
 
 test_description='perl interface (Git.pm)'
 . ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-perl.sh
 
-if ! test_have_prereq PERL; then
-       skip_all='skipping perl interface tests, perl not available'
-       test_done
-fi
-
-perl -MTest::More -e 0 2>/dev/null || {
-       skip_all="Perl Test::More unavailable, skipping test"
-       test_done
-}
+skip_all_if_no_Test_More
 
 # set up test repository