diff mbox series

[01/20] t: skip chain lint when PERL_PATH is unset

Message ID 20250320-b4-pks-t-perlless-v1-1-b1eefe27ac55@pks.im (mailing list archive)
State Superseded
Headers show
Series t: drop Perl as a mandatory prerequisite | expand

Commit Message

Patrick Steinhardt March 20, 2025, 9:35 a.m. UTC
Our chainlint scripts verify that test files have proper '&&' chains.
These scripts are written in Perl and are executed for every test file
before executing the test logic itself.

In subsequent commits we're about to refactor our test suite so that
Perl becomes an optional dependency, only. And while it is already
possible to disable this linter, developers that don't have Perl
available at all would always have to disable the linter manually, which
is rather cumbersome.

Disable the chain linter automatically in case PERL_PATH isn't set to
make this a bit less annoying. Bail out with an error in case the
developer has asked explicitly for the chain linter.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
---
 t/test-lib.sh | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

Comments

Eric Sunshine March 20, 2025, 6:36 p.m. UTC | #1
On Thu, Mar 20, 2025 at 5:35 AM Patrick Steinhardt <ps@pks.im> wrote:
> Our chainlint scripts verify that test files have proper '&&' chains.

It's just a single script, so: s/scripts verify/script verifies/

> These scripts are written in Perl and are executed for every test file

s/These scripts/This script/
s/are/is/g

> before executing the test logic itself.
>
> In subsequent commits we're about to refactor our test suite so that
> Perl becomes an optional dependency, only. And while it is already
> possible to disable this linter, developers that don't have Perl
> available at all would always have to disable the linter manually, which
> is rather cumbersome.
>
> Disable the chain linter automatically in case PERL_PATH isn't set to
> make this a bit less annoying. Bail out with an error in case the
> developer has asked explicitly for the chain linter.
>
> Signed-off-by: Patrick Steinhardt <ps@pks.im>

Not worth a reroll, of course.
diff mbox series

Patch

diff --git a/t/test-lib.sh b/t/test-lib.sh
index 9001ed3a647..1ce3b32fcac 100644
--- a/t/test-lib.sh
+++ b/t/test-lib.sh
@@ -1523,6 +1523,22 @@  then
 	export LSAN_OPTIONS
 fi
 
+if test -z "$PERL_PATH"
+then
+	case "${GIT_TEST_CHAIN_LINT:-unset}" in
+	unset)
+		GIT_TEST_CHAIN_LINT=0
+		;;
+	0)
+		# The user has explicitly disabled the chain linter, so we
+		# don't have anything to worry about.
+		;;
+	*)
+		BAIL_OUT 'You need Perl for the chain linter'
+		;;
+	esac
+fi
+
 if test "${GIT_TEST_CHAIN_LINT:-1}" != 0 &&
    test "${GIT_TEST_EXT_CHAIN_LINT:-1}" != 0
 then