In the early days of Git, Perl was used quite prominently throughout the
project. This has changed significantly as almost all of the executables
we ship nowadays have eventually been rewritten in C. Only a handful of
subsystems remain that require Perl:
- gitweb, a read-only web interface.
- A couple of scripts that allow importing repositories from GNU Arch,
CVS and Subversion.
- git-send-email(1), which can be used to send mails.
- git-request-pull(1), which is used to request somebody to pull from
a URL by sending an email.
- git-filter-branch(1), which uses Perl with the `--state-branch`
option. This command is typically recommended against nowadays in
favor of git-filter-repo(1).
- Our Perl bindings for Git.
- The netrc Git credential helper.
None of these subsystems can really be considered to be part of the
"core" of Git, and an installation without them is fully functional.
It is more likely than not that an end user wouldn't even notice that
any features are missing if those tools weren't installed. But while
Perl nowadays very much is an optional dependency of Git, there is a
significant limitation when Perl isn't available: developers cannot run
our test suite.
Preceding commits have started to lift this restriction by removing the
strict dependency on Perl in many central parts of the test library. But
there are still many tests that rely on small Perl helpers to do various
different things.
Introduce a new PERL_TEST_HELPERS prerequisite that guards all tests
that require Perl. This prerequisite is explicitly different than the
preexisting PERL prerequisite:
- PERL records whether or not features depending on the Perl
interpreter are built.
- PERL_TEST_HELPERS records whether or not a Perl interpreter is
available for our tests.
By having these two separate prerequisites we can thus distinguish
between tests that inherently depend on Perl because the underlying
feature does, and those tests that depend on Perl because the test
itself is using Perl.
Adapt all tests to set the PERL_TEST_HELPERS prerequisite as needed.
Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Patrick Steinhardt committedApr 3, 2025 at 07:05 UTC23e21a58d5c7b5ae7b4b5532933e0f82e24024fe
index 3f6433d304..9c3738ebb3 100755--- a/t/t0021-conversion.sh+++ b/t/t0021-conversion.sh@@ -619,7 +619,7 @@ test_expect_success 'required process filter should be used only for "clean" ope ) '-test_expect_success 'required process filter should process multiple packets' '+test_expect_success PERL_TEST_HELPERS 'required process filter should process multiple packets' ' test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" && test_config_global filter.protocol.required true &&@@ -684,7 +684,7 @@ test_expect_success 'required process filter should process multiple packets' ' ) '-test_expect_success 'required process filter with clean error should fail' '+test_expect_success PERL_TEST_HELPERS 'required process filter with clean error should fail' ' test_config_global filter.protocol.process "test-tool rot13-filter --log=debug.log clean smudge" && test_config_global filter.protocol.required true && rm -rf repo &&
t/t0210-trace2-normal.sh
+6
index 4287ed3fbb..ba4c0442b8 100755--- a/t/t0210-trace2-normal.sh+++ b/t/t0210-trace2-normal.sh@@ -4,6 +4,12 @@ test_description='test trace2 facility (normal target)' . ./test-lib.sh+if ! test_have_prereq PERL_TEST_HELPERS+then+ skip_all='skipping trace2 tests; Perl not available'+ test_done+fi+ # Turn off any inherited trace2 settings for this test. sane_unset GIT_TRACE2 GIT_TRACE2_PERF GIT_TRACE2_EVENT sane_unset GIT_TRACE2_BRIEF
t/t0211-trace2-perf.sh
+6
index bac9046540..760cf69087 100755--- a/t/t0211-trace2-perf.sh+++ b/t/t0211-trace2-perf.sh@@ -4,6 +4,12 @@ test_description='test trace2 facility (perf target)' . ./test-lib.sh+if ! test_have_prereq PERL_TEST_HELPERS+then+ skip_all='skipping trace2 tests; Perl not available'+ test_done+fi+ # Turn off any inherited trace2 settings for this test. sane_unset GIT_TRACE2 GIT_TRACE2_PERF GIT_TRACE2_EVENT sane_unset GIT_TRACE2_PERF_BRIEF
t/t0610-reftable-basics.sh
+1-1
index 4618ffc108..5e0a1fa176 100755--- a/t/t0610-reftable-basics.sh+++ b/t/t0610-reftable-basics.sh@@ -643,7 +643,7 @@ test_expect_success 'basic: commit and list refs' ' test_cmp actual expect '-test_expect_success 'basic: can write large commit message' '+test_expect_success PERL_TEST_HELPERS 'basic: can write large commit message' ' test_when_finished "rm -rf repo" && git init repo && perl -e "
t/t0613-reftable-write-options.sh
+1-1
index e2708e11d5..fa1e2f9eef 100755--- a/t/t0613-reftable-write-options.sh+++ b/t/t0613-reftable-write-options.sh@@ -139,7 +139,7 @@ test_expect_success 'small block size leads to multiple ref blocks' ' ) '-test_expect_success 'small block size fails with large reflog message' '+test_expect_success PERL_TEST_HELPERS 'small block size fails with large reflog message' ' test_when_finished "rm -rf repo" && git init repo && (
index a0481139de..b3cf53ff8c 100755--- a/t/t1007-hash-object.sh+++ b/t/t1007-hash-object.sh@@ -205,7 +205,7 @@ test_expect_success 'too-short tree' ' grep "too-short tree object" err '-test_expect_success 'malformed mode in tree' '+test_expect_success PERL_TEST_HELPERS 'malformed mode in tree' ' hex_oid=$(echo foo | git hash-object --stdin -w) && bin_oid=$(echo $hex_oid | hex2oct) && printf "9100644 \0$bin_oid" >tree-with-malformed-mode &&@@ -213,7 +213,7 @@ test_expect_success 'malformed mode in tree' ' grep "malformed mode in tree entry" err '-test_expect_success 'empty filename in tree' '+test_expect_success PERL_TEST_HELPERS 'empty filename in tree' ' hex_oid=$(echo foo | git hash-object --stdin -w) && bin_oid=$(echo $hex_oid | hex2oct) && printf "100644 \0$bin_oid" >tree-with-empty-filename &&@@ -221,7 +221,7 @@ test_expect_success 'empty filename in tree' ' grep "empty filename in tree entry" err '-test_expect_success 'duplicate filename in tree' '+test_expect_success PERL_TEST_HELPERS 'duplicate filename in tree' ' hex_oid=$(echo foo | git hash-object --stdin -w) && bin_oid=$(echo $hex_oid | hex2oct) && {
t/t1010-mktree.sh
+2-2
index c291a2b33d..4977998e20 100755--- a/t/t1010-mktree.sh+++ b/t/t1010-mktree.sh@@ -41,13 +41,13 @@ test_expect_success 'ls-tree piped to mktree (2)' ' test_cmp tree.withsub actual '-test_expect_success 'ls-tree output in wrong order given to mktree (1)' '+test_expect_success PERL_TEST_HELPERS 'ls-tree output in wrong order given to mktree (1)' ' perl -e "print reverse <>" <top | git mktree >actual && test_cmp tree actual '-test_expect_success 'ls-tree output in wrong order given to mktree (2)' '+test_expect_success PERL_TEST_HELPERS 'ls-tree output in wrong order given to mktree (2)' ' perl -e "print reverse <>" <top.withsub | git mktree >actual && test_cmp tree.withsub actual
t/t1450-fsck.sh
+3-3
index 8a456b1142..0105045376 100755--- a/t/t1450-fsck.sh+++ b/t/t1450-fsck.sh@@ -346,7 +346,7 @@ test_expect_success 'unparseable tree object' ' test_grep ! "fatal: empty filename in tree entry" out '-test_expect_success 'tree entry with type mismatch' '+test_expect_success PERL_TEST_HELPERS 'tree entry with type mismatch' ' test_when_finished "remove_object \$blob" && test_when_finished "remove_object \$tree" && test_when_finished "remove_object \$commit" &&@@ -364,7 +364,7 @@ test_expect_success 'tree entry with type mismatch' ' test_grep ! "dangling blob" out '-test_expect_success 'tree entry with bogus mode' '+test_expect_success PERL_TEST_HELPERS 'tree entry with bogus mode' ' test_when_finished "remove_object \$blob" && test_when_finished "remove_object \$tree" && blob=$(echo blob | git hash-object -w --stdin) &&@@ -984,7 +984,7 @@ corrupt_index_checksum () { # Corrupt the checksum on the index and then # verify that only fsck notices.-test_expect_success 'detect corrupt index file in fsck' '+test_expect_success PERL_TEST_HELPERS 'detect corrupt index file in fsck' ' cp .git/index .git/index.backup && test_when_finished "mv .git/index.backup .git/index" && corrupt_index_checksum &&
t/t3300-funny-names.sh
+3-3
index f5bf16abcd..502b157205 100755--- a/t/t3300-funny-names.sh+++ b/t/t3300-funny-names.sh@@ -63,7 +63,7 @@ test_expect_success 'ls-files quotes funny filename' ' test_cmp expected current '-test_expect_success 'ls-files -z does not quote funny filename' '+test_expect_success PERL_TEST_HELPERS 'ls-files -z does not quote funny filename' ' cat >expected <<-\EOF && just space no-funny@@ -101,7 +101,7 @@ test_expect_success 'diff-tree --name-status quotes funny filename' ' test_cmp expected current '-test_expect_success 'diff-index -z does not quote funny filename' '+test_expect_success PERL_TEST_HELPERS 'diff-index -z does not quote funny filename' ' cat >expected <<-\EOF && A tabs ," (dq) and spaces@@ -111,7 +111,7 @@ test_expect_success 'diff-index -z does not quote funny filename' ' test_cmp expected current '-test_expect_success 'diff-tree -z does not quote funny filename' '+test_expect_success PERL_TEST_HELPERS 'diff-tree -z does not quote funny filename' ' cat >expected <<-\EOF && A tabs ," (dq) and spaces
index 2fce4a9897..16266dff2a 100755--- a/t/t4058-diff-duplicates.sh+++ b/t/t4058-diff-duplicates.sh@@ -13,6 +13,12 @@ test_description='test tree diff when trees have duplicate entries' . ./test-lib.sh+if ! test_have_prereq PERL_TEST_HELPERS+then+ skip_all='skipping diff duplicates tests; Perl not available'+ test_done+fi+ # make_tree_entry <mode> <mode> <sha1> # # We have to rely on perl here because not all printfs understand
t/t4103-apply-binary.sh
+6
index d370ecfe0d..59d38793ae 100755--- a/t/t4103-apply-binary.sh+++ b/t/t4103-apply-binary.sh@@ -11,6 +11,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh+if ! test_have_prereq PERL_TEST_HELPERS+then+ skip_all='skipping apply-binary tests; Perl not available'+ test_done+fi+ test_expect_success 'setup' ' cat >file1 <<-\EOF && A quick brown fox jumps over the lazy dog.
t/t4116-apply-reverse.sh
+6
index 0784ba033a..6f414ad27f 100755--- a/t/t4116-apply-reverse.sh+++ b/t/t4116-apply-reverse.sh@@ -10,6 +10,12 @@ test_description='git apply in reverse . ./test-lib.sh+if ! test_have_prereq PERL_TEST_HELPERS+then+ skip_all='skipping apply reverse tests; Perl not available'+ test_done+fi+ test_expect_success setup ' test_write_lines a b c d e f g h i j k l m n >file1 &&
t/t4150-am.sh
+1-1
index 5e2b6c80ea..4794510d70 100755--- a/t/t4150-am.sh+++ b/t/t4150-am.sh@@ -1073,7 +1073,7 @@ test_expect_success 'am --patch-format=mboxrd handles mboxrd' ' test_cmp msg out '-test_expect_success 'am works with multi-line in-body headers' '+test_expect_success PERL_TEST_HELPERS 'am works with multi-line in-body headers' ' FORTY="String that has a length of more than forty characters" && LONG="$FORTY $FORTY" && rm -fr .git/rebase-apply &&
t/t4200-rerere.sh
+6
index b0a3e84984..50fe8b0fd0 100755--- a/t/t4200-rerere.sh+++ b/t/t4200-rerere.sh@@ -27,6 +27,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh+if ! test_have_prereq PERL_TEST_HELPERS+then+ skip_all='skipping rerere tests; Perl not available'+ test_done+fi+ test_expect_success 'setup' ' cat >a1 <<-\EOF && Some title
t/t4205-log-pretty-formats.sh
+3-3
index f81e42a84d..8f2ba98963 100755--- a/t/t4205-log-pretty-formats.sh+++ b/t/t4205-log-pretty-formats.sh@@ -698,7 +698,7 @@ test_expect_success '%(trailers:only=no,only=true) shows only "key: value" trail test_cmp expect actual '-test_expect_success '%(trailers:unfold) unfolds trailers' '+test_expect_success PERL_TEST_HELPERS '%(trailers:unfold) unfolds trailers' ' git log --no-walk --pretty="%(trailers:unfold)" >actual && { unfold <trailers &&@@ -707,7 +707,7 @@ test_expect_success '%(trailers:unfold) unfolds trailers' ' test_cmp expect actual '-test_expect_success ':only and :unfold work together' '+test_expect_success PERL_TEST_HELPERS ':only and :unfold work together' ' git log --no-walk --pretty="%(trailers:only,unfold)" >actual && git log --no-walk --pretty="%(trailers:unfold,only)" >reverse && test_cmp actual reverse &&@@ -754,7 +754,7 @@ test_expect_success '%(trailers:key=foo) handles multiple lines even if folded' test_cmp expect actual '-test_expect_success '%(trailers:key=foo,unfold) properly unfolds' '+test_expect_success PERL_TEST_HELPERS '%(trailers:key=foo,unfold) properly unfolds' ' git log --no-walk --pretty="format:%(trailers:key=Signed-Off-by,unfold)" >actual && unfold <trailers | grep Signed-off-by >expect && test_cmp expect actual
t/t4216-log-bloom.sh
+4-4
index 3f163dc396..8910d53cac 100755--- a/t/t4216-log-bloom.sh+++ b/t/t4216-log-bloom.sh@@ -738,20 +738,20 @@ check_corrupt_graph () { test_cmp expect.out out }-test_expect_success 'Bloom reader notices too-small data chunk' '+test_expect_success PERL_TEST_HELPERS 'Bloom reader notices too-small data chunk' ' check_corrupt_graph BDAT clear 00000000 && echo "warning: ignoring too-small changed-path chunk" \ "(4 < 12) in commit-graph file" >expect.err && test_cmp expect.err err '-test_expect_success 'Bloom reader notices out-of-bounds filter offsets' '+test_expect_success PERL_TEST_HELPERS 'Bloom reader notices out-of-bounds filter offsets' ' check_corrupt_graph BIDX 12 FFFFFFFF && # use grep to avoid depending on exact chunk size grep "warning: ignoring out-of-range offset (4294967295) for changed-path filter at pos 3 of .git/objects/info/commit-graph" err '-test_expect_success 'Bloom reader notices too-small index chunk' '+test_expect_success PERL_TEST_HELPERS 'Bloom reader notices too-small index chunk' ' # replace the index with a single entry, making most # lookups out-of-bounds check_corrupt_graph BIDX clear 00000000 &&@@ -760,7 +760,7 @@ test_expect_success 'Bloom reader notices too-small index chunk' ' test_cmp expect.err err '-test_expect_success 'Bloom reader notices out-of-order index offsets' '+test_expect_success PERL_TEST_HELPERS 'Bloom reader notices out-of-order index offsets' ' # we do not know any real offsets, but we can pick # something plausible; we should not get to the point of # actually reading from the bogus offsets anyway.
t/t5004-archive-corner-cases.sh
+6
index 50344e17ca..5174995191 100755--- a/t/t5004-archive-corner-cases.sh+++ b/t/t5004-archive-corner-cases.sh@@ -4,6 +4,12 @@ test_description='test corner cases of git-archive' . ./test-lib.sh+if ! test_have_prereq PERL_TEST_HELPERS+then+ skip_all='skipping archive corner cases tests; Perl not available'+ test_done+fi+ # the 10knuls.tar file is used to test for an empty git generated tar # without having to invoke tar because an otherwise valid empty GNU tar # will be considered broken by {Open,Net}BSD tar
index de58ca654a..ac5e370e1e 100755--- a/t/t5303-pack-corruption-resilience.sh+++ b/t/t5303-pack-corruption-resilience.sh@@ -99,7 +99,7 @@ test_expect_success '... and loose copy of first delta allows for partial recove git cat-file blob $blob_3 > /dev/null '-test_expect_success 'create corruption in data of first object' '+test_expect_success PERL_TEST_HELPERS 'create corruption in data of first object' ' create_new_pack && git prune-packed && chmod +w ${pack}.pack &&@@ -156,7 +156,7 @@ test_expect_success '... and then a repack "clears" the corruption' ' git cat-file blob $blob_3 > /dev/null '-test_expect_success 'create corruption in data of first delta' '+test_expect_success PERL_TEST_HELPERS 'create corruption in data of first delta' ' create_new_pack && git prune-packed && chmod +w ${pack}.pack &&
index 845ca43ea0..febe441041 100755--- a/t/t5503-tagfollow.sh+++ b/t/t5503-tagfollow.sh@@ -7,6 +7,12 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh+if ! test_have_prereq PERL_TEST_HELPERS+then+ skip_all='skipping tagfollow tests; Perl not available'+ test_done+fi+ # End state of the repository: # # T - tag1 S - tag2
t/t5504-fetch-receive-strict.sh
+1-1
index 58074506c5..438250c75e 100755--- a/t/t5504-fetch-receive-strict.sh+++ b/t/t5504-fetch-receive-strict.sh@@ -359,7 +359,7 @@ test_expect_success \ grep "Cannot demote unterminatedheader" act '-test_expect_success 'badFilemode is not a strict error' '+test_expect_success PERL_TEST_HELPERS 'badFilemode is not a strict error' ' git init --bare badmode.git && tree=$( cd badmode.git &&
index d0c18660e3..d743d986c4 100755--- a/t/t5601-clone.sh+++ b/t/t5601-clone.sh@@ -649,7 +649,7 @@ test_expect_success 'GIT_TRACE_PACKFILE produces a usable pack' ' git -C replay.git index-pack -v --stdin <tmp.pack '-test_expect_success 'clone on case-insensitive fs' '+test_expect_success PERL_TEST_HELPERS 'clone on case-insensitive fs' ' git init icasefs && ( cd icasefs &&@@ -662,7 +662,7 @@ test_expect_success 'clone on case-insensitive fs' ' ) '-test_expect_success CASE_INSENSITIVE_FS 'colliding file detection' '+test_expect_success PERL_TEST_HELPERS,CASE_INSENSITIVE_FS 'colliding file detection' ' grep X icasefs/warning && grep x icasefs/warning && test_grep "the following paths have collided" icasefs/warning
t/t5616-partial-clone.sh
+3-3
index 4650451964..bc7e0fec8d 100755--- a/t/t5616-partial-clone.sh+++ b/t/t5616-partial-clone.sh@@ -751,7 +751,7 @@ replace_packfile () { }' >"$HTTPD_ROOT_PATH/one-time-perl" }-test_expect_success 'upon cloning, check that all refs point to objects' '+test_expect_success PERL_TEST_HELPERS 'upon cloning, check that all refs point to objects' ' SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" && rm -rf "$SERVER" repo && test_create_repo "$SERVER" &&@@ -784,7 +784,7 @@ test_expect_success 'upon cloning, check that all refs point to objects' ' ! test -e "$HTTPD_ROOT_PATH/one-time-perl" '-test_expect_success 'when partial cloning, tolerate server not sending target of tag' '+test_expect_success PERL_TEST_HELPERS 'when partial cloning, tolerate server not sending target of tag' ' SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" && rm -rf "$SERVER" repo && test_create_repo "$SERVER" &&@@ -825,7 +825,7 @@ test_expect_success 'when partial cloning, tolerate server not sending target of ! test -e "$HTTPD_ROOT_PATH/one-time-perl" '-test_expect_success 'tolerate server sending REF_DELTA against missing promisor objects' '+test_expect_success PERL_TEST_HELPERS 'tolerate server sending REF_DELTA against missing promisor objects' ' SERVER="$HTTPD_DOCUMENT_ROOT_PATH/server" && rm -rf "$SERVER" repo && test_create_repo "$SERVER" &&
t/t5701-git-serve.sh
+1-1
index 678a346ed0..200bf06ecb 100755--- a/t/t5701-git-serve.sh+++ b/t/t5701-git-serve.sh@@ -220,7 +220,7 @@ test_expect_success 'refs/heads prefix' ' test_cmp expect actual '-test_expect_success 'ignore very large set of prefixes' '+test_expect_success PERL_TEST_HELPERS 'ignore very large set of prefixes' ' # generate a large number of ref-prefixes that we expect # to match nothing; the value here exceeds TOO_MANY_PREFIXES # from ls-refs.c.
t/t5702-protocol-v2.sh
+3-3
index d3df81e785..ad5e772cd7 100755--- a/t/t5702-protocol-v2.sh+++ b/t/t5702-protocol-v2.sh@@ -1120,7 +1120,7 @@ test_expect_success 'push with http:// and a config of v2 does not request v2' ' ! grep "git< version 2" log '-test_expect_success 'when server sends "ready", expect DELIM' '+test_expect_success PERL_TEST_HELPERS 'when server sends "ready", expect DELIM' ' rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child && git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&@@ -1140,7 +1140,7 @@ test_expect_success 'when server sends "ready", expect DELIM' ' test_grep "expected packfile to be sent after .ready." err '-test_expect_success 'when server does not send "ready", expect FLUSH' '+test_expect_success PERL_TEST_HELPERS 'when server does not send "ready", expect FLUSH' ' rm -rf "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" http_child log && git init "$HTTPD_DOCUMENT_ROOT_PATH/http_parent" &&@@ -1446,7 +1446,7 @@ test_expect_success 'http:// --negotiate-only' ' grep "$COMMON" out '-test_expect_success 'http:// --negotiate-only without wait-for-done support' '+test_expect_success PERL_TEST_HELPERS 'http:// --negotiate-only without wait-for-done support' ' SERVER="server" && URI="$HTTPD_URL/one_time_perl/server" &&
index bad02cf5b8..6131c36109 100755--- a/t/t6011-rev-list-with-bad-commit.sh+++ b/t/t6011-rev-list-with-bad-commit.sh@@ -4,6 +4,12 @@ test_description='git rev-list should notice bad commits' . ./test-lib.sh+if ! test_have_prereq PERL_TEST_HELPERS+then+ skip_all='skipping rev-list with bad commit tests; Perl not available'+ test_done+fi+ # Note: # - compression level is set to zero to make "corruptions" easier to perform # - reflog is disabled to avoid extra references which would twart the test
index 3385fe9f13..6a74be576a 100755--- a/t/t6115-rev-list-du.sh+++ b/t/t6115-rev-list-du.sh@@ -4,6 +4,12 @@ test_description='basic tests of rev-list --disk-usage' . ./test-lib.sh+if ! test_have_prereq PERL_TEST_HELPERS+then+ skip_all='skipping rev-list disk usage tests; Perl not available'+ test_done+fi+ # we want a mix of reachable and unreachable, as well as # objects in the bitmapped pack and some outside of it test_expect_success 'set up repository' '