git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v3 08/15] tests: move copy/pasted PERL + Test::More checks to a lib-perl.sh

From
Ævar Arnfjörð Bjarmason <avarab@gmail.com>
Date
Jul 27, 2022, 23:13 UTC
Message-ID
<patch-v3-08.15-53ea78bf417-20220727T230800Z-avarab@gmail.com>
In-Reply-To
<cover-v3-00.15-00000000000-20220727T230800Z-avarab@gmail.com>

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>
---
 .../netrc/t-git-credential-netrc.sh           | 11 ++---------
 t/lib-perl.sh                                 | 19 +++++++++++++++++++
 t/t0202-gettext-perl.sh                       | 12 ++----------
 t/t9700-perl-git.sh                           | 11 ++---------
 4 files changed, 25 insertions(+), 28 deletions(-)
 create mode 100644 t/lib-perl.sh
diff --git a/contrib/credential/netrc/t-git-credential-netrc.sh b/contrib/credential/netrc/t-git-credential-netrc.sh
index 07227d02287..ff17a9460cd 100755
--- a/contrib/credential/netrc/t-git-credential-netrc.sh
+++ b/contrib/credential/netrc/t-git-credential-netrc.sh
@@ -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
index 00000000000..d0bf509a167
--- /dev/null
+++ b/t/lib-perl.sh
@@ -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
+}
diff --git a/t/t0202-gettext-perl.sh b/t/t0202-gettext-perl.sh
index df2ea34932b..043b190626c 100755
--- a/t/t0202-gettext-perl.sh
+++ b/t/t0202-gettext-perl.sh
@@ -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
diff --git a/t/t9700-perl-git.sh b/t/t9700-perl-git.sh
index 102c133112c..17fc43f6e57 100755
--- a/t/t9700-perl-git.sh
+++ b/t/t9700-perl-git.sh
@@ -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
 
-- 
2.37.1.1127.g4ecf1c08f67
Previous: Junio C HamanoNext: Ævar Arnfjörð Bjarmason
Message 50 of 57 in “leak test: add "check" test mode, mark leak-free tests”
  1. 00/10 leak test: add "check" test mode, mark leak-free testsÆvar Arnfjörð Bjarmason, Jul 19, 2022
  2. 01/10 test-lib.sh: use $1, not $@ in test_known_broken_{ok,failure}_Ævar Arnfjörð Bjarmason, Jul 19, 2022
  3. 02/10 test-lib.sh: don't set GIT_EXIT_OK before calling test_atexit_handlerÆvar Arnfjörð Bjarmason, Jul 19, 2022
  4. 03/10 test-lib.sh: fix GIT_EXIT_OK logic errors, use BAIL_OUTÆvar Arnfjörð Bjarmason, Jul 19, 2022
  5. 04/10 test-lib.sh: add a --invert-exit-code switchÆvar Arnfjörð Bjarmason, Jul 19, 2022
  6. 07/10 test-lib.sh: add a GIT_TEST_PASSING_SANITIZE_LEAK=check modeÆvar Arnfjörð Bjarmason, Jul 19, 2022
  7. Derrick StoleeJul 20, 2022
  8. 06/10 test-lib: add a SANITIZE=leak logging modeÆvar Arnfjörð Bjarmason, Jul 19, 2022
  9. 05/10 t/README: reword the "GIT_TEST_PASSING_SANITIZE_LEAK" descriptionÆvar Arnfjörð Bjarmason, Jul 19, 2022
  10. Derrick StoleeJul 20, 2022
  11. 09/10 leak tests: mark passing SANITIZE=leak tests as leak-freeÆvar Arnfjörð Bjarmason, Jul 19, 2022
  12. Derrick StoleeJul 20, 2022
  13. 08/10 test-lib: have the "check" mode for SANITIZE=leak consider leak logsÆvar Arnfjörð Bjarmason, Jul 19, 2022
  14. Derrick StoleeJul 20, 2022
  15. 10/10 log tests: don't use "exit 1" outside a sub-shellÆvar Arnfjörð Bjarmason, Jul 19, 2022
  16. Junio C HamanoJul 20, 2022
  17. 00/14 leak test: add "check" test mode, mark leak-free testsÆvar Arnfjörð Bjarmason, Jul 20, 2022
  18. 01/14 test-lib: use $1, not $@ in test_known_broken_{ok,failure}_Ævar Arnfjörð Bjarmason, Jul 20, 2022
  19. 02/14 test-lib: don't set GIT_EXIT_OK before calling test_atexit_handlerÆvar Arnfjörð Bjarmason, Jul 20, 2022
  20. 03/14 test-lib: fix GIT_EXIT_OK logic errors, use BAIL_OUTÆvar Arnfjörð Bjarmason, Jul 20, 2022
  21. 04/14 test-lib: add a --invert-exit-code switchÆvar Arnfjörð Bjarmason, Jul 20, 2022
  22. 05/14 t/README: reword the "GIT_TEST_PASSING_SANITIZE_LEAK" descriptionÆvar Arnfjörð Bjarmason, Jul 20, 2022
  23. 06/14 test-lib: add a SANITIZE=leak logging modeÆvar Arnfjörð Bjarmason, Jul 20, 2022
  24. 07/14 t/Makefile: don't remove test-results in "clean-except-prove-cache"Ævar Arnfjörð Bjarmason, Jul 20, 2022
  25. 08/14 tests: move copy/pasted PERL + Test::More checks to a lib-perl.shÆvar Arnfjörð Bjarmason, Jul 20, 2022
  26. 10/14 test-lib: add a GIT_TEST_PASSING_SANITIZE_LEAK=check modeÆvar Arnfjörð Bjarmason, Jul 20, 2022
  27. 09/14 test-lib: simplify by removing test_externalÆvar Arnfjörð Bjarmason, Jul 20, 2022
  28. 11/14 test-lib: have the "check" mode for SANITIZE=leak consider leak logsÆvar Arnfjörð Bjarmason, Jul 20, 2022
  29. 12/14 leak tests: mark passing SANITIZE=leak tests as leak-freeÆvar Arnfjörð Bjarmason, Jul 20, 2022
  30. 13/14 upload-pack: fix a memory leak in create_pack_file()Ævar Arnfjörð Bjarmason, Jul 20, 2022
  31. 14/14 CI: use "GIT_TEST_SANITIZE_LEAK_LOG=true" in linux-leaksÆvar Arnfjörð Bjarmason, Jul 20, 2022
  32. 00/15 leak test: add "check" test mode, mark leak-free testsÆvar Arnfjörð Bjarmason, Jul 27, 2022
  33. 01/15 test-lib: use $1, not $@ in test_known_broken_{ok,failure}_Ævar Arnfjörð Bjarmason, Jul 27, 2022
  34. 02/15 test-lib: don't set GIT_EXIT_OK before calling test_atexit_handlerÆvar Arnfjörð Bjarmason, Jul 27, 2022
  35. 03/15 test-lib: fix GIT_EXIT_OK logic errors, use BAIL_OUTÆvar Arnfjörð Bjarmason, Jul 27, 2022
  36. 05/15 t/README: reword the "GIT_TEST_PASSING_SANITIZE_LEAK" descriptionÆvar Arnfjörð Bjarmason, Jul 27, 2022
  37. 04/15 test-lib: add a --invert-exit-code switchÆvar Arnfjörð Bjarmason, Jul 27, 2022
  38. 06/15 test-lib: add a SANITIZE=leak logging modeÆvar Arnfjörð Bjarmason, Jul 27, 2022
  39. 07/15 t/Makefile: don't remove test-results in "clean-except-prove-cache"Ævar Arnfjörð Bjarmason, Jul 27, 2022
  40. t/Makefile: remove 'test-results' on 'make clean'SZEDER Gábor, Sep 20, 2022
  41. Jeff KingSep 20, 2022
  42. SZEDER GáborSep 20, 2022
  43. Jeff KingSep 20, 2022
  44. t/Makefile: remove 'test-results' on 'make clean'SZEDER Gábor, Sep 20, 2022
  45. Ævar Arnfjörð BjarmasonSep 21, 2022
  46. Junio C HamanoSep 21, 2022
  47. Junio C HamanoSep 21, 2022
  48. Ævar Arnfjörð BjarmasonSep 26, 2022
  49. Junio C HamanoSep 26, 2022
  50. 08/15 tests: move copy/pasted PERL + Test::More checks to a lib-perl.shÆvar Arnfjörð Bjarmason, Jul 27, 2022
  51. 09/15 test-lib: simplify by removing test_externalÆvar Arnfjörð Bjarmason, Jul 27, 2022
  52. 10/15 test-lib: add a GIT_TEST_PASSING_SANITIZE_LEAK=check modeÆvar Arnfjörð Bjarmason, Jul 27, 2022
  53. 12/15 leak tests: don't skip some tests under SANITIZE=leakÆvar Arnfjörð Bjarmason, Jul 27, 2022
  54. 11/15 test-lib: have the "check" mode for SANITIZE=leak consider leak logsÆvar Arnfjörð Bjarmason, Jul 27, 2022
  55. 13/15 leak tests: mark passing SANITIZE=leak tests as leak-freeÆvar Arnfjörð Bjarmason, Jul 27, 2022
  56. 15/15 CI: use "GIT_TEST_SANITIZE_LEAK_LOG=true" in linux-leaksÆvar Arnfjörð Bjarmason, Jul 27, 2022
  57. 14/15 upload-pack: fix a memory leak in create_pack_file()Ævar Arnfjörð Bjarmason, Jul 27, 2022

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.