Message ID | 20250320-b4-pks-t-perlless-v1-15-b1eefe27ac55@pks.im (mailing list archive) |
---|---|
State | Superseded |
Headers | show |
Series | t: drop Perl as a mandatory prerequisite | expand |
On Thu, Mar 20, 2025 at 5:37 AM Patrick Steinhardt <ps@pks.im> wrote: > The `name_from_description()` test helper uses Perl to munge a given > description and convert it into a name. Refactor it to instead use a > combination of sed(1) and tr(1) so that we drop PERL_TEST_HELPERS > prerequisites in users of this library. > > Signed-off-by: Patrick Steinhardt <ps@pks.im> > --- > diff --git a/t/lib-t6000.sh b/t/lib-t6000.sh > @@ -109,13 +109,12 @@ check_output () { > # All alphanums translated into -'s which are then compressed and stripped > # from front and back. > name_from_description () { > - perl -pe ' > - s/[^A-Za-z0-9.]/-/g; > - s/-+/-/g; > - s/-$//; > - s/^-//; > - y/A-Z/a-z/; > - ' > + sed \ > + -e 's/[^A-Za-z0-9.]/-/g' \ > + -e 's/--*/-/g' \ > + -e 's/-$//' \ > + -e 's/^-//' | > + tr 'A-Z' 'a-z' > } Can't you just use sed's `y//` function directly instead of having to separately invoke a `tr` command?
On Thu, Mar 20, 2025 at 03:41:11PM -0400, Eric Sunshine wrote: > On Thu, Mar 20, 2025 at 5:37 AM Patrick Steinhardt <ps@pks.im> wrote: > > The `name_from_description()` test helper uses Perl to munge a given > > description and convert it into a name. Refactor it to instead use a > > combination of sed(1) and tr(1) so that we drop PERL_TEST_HELPERS > > prerequisites in users of this library. > > > > Signed-off-by: Patrick Steinhardt <ps@pks.im> > > --- > > diff --git a/t/lib-t6000.sh b/t/lib-t6000.sh > > @@ -109,13 +109,12 @@ check_output () { > > # All alphanums translated into -'s which are then compressed and stripped > > # from front and back. > > name_from_description () { > > - perl -pe ' > > - s/[^A-Za-z0-9.]/-/g; > > - s/-+/-/g; > > - s/-$//; > > - s/^-//; > > - y/A-Z/a-z/; > > - ' > > + sed \ > > + -e 's/[^A-Za-z0-9.]/-/g' \ > > + -e 's/--*/-/g' \ > > + -e 's/-$//' \ > > + -e 's/^-//' | > > + tr 'A-Z' 'a-z' > > } > > Can't you just use sed's `y//` function directly instead of having to > separately invoke a `tr` command? Ah, of course, will change! Patrick
diff --git a/t/lib-t6000.sh b/t/lib-t6000.sh index fba6778ca35..5191ebb30b8 100644 --- a/t/lib-t6000.sh +++ b/t/lib-t6000.sh @@ -109,13 +109,12 @@ check_output () { # All alphanums translated into -'s which are then compressed and stripped # from front and back. name_from_description () { - perl -pe ' - s/[^A-Za-z0-9.]/-/g; - s/-+/-/g; - s/-$//; - s/^-//; - y/A-Z/a-z/; - ' + sed \ + -e 's/[^A-Za-z0-9.]/-/g' \ + -e 's/--*/-/g' \ + -e 's/-$//' \ + -e 's/^-//' | + tr 'A-Z' 'a-z' } diff --git a/t/t6002-rev-list-bisect.sh b/t/t6002-rev-list-bisect.sh index 5e1482aff78..daa009c9a1b 100755 --- a/t/t6002-rev-list-bisect.sh +++ b/t/t6002-rev-list-bisect.sh @@ -7,12 +7,6 @@ test_description='Tests git rev-list --bisect functionality' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions -if ! test_have_prereq PERL_TEST_HELPERS -then - skip_all='skipping rev-list bisect tests; Perl not available' - test_done -fi - # usage: test_bisection max-diff bisect-option head ^prune... # # e.g. test_bisection 1 --bisect l1 ^l0 diff --git a/t/t6003-rev-list-topo-order.sh b/t/t6003-rev-list-topo-order.sh index 02dd4127aff..0d7055d46d4 100755 --- a/t/t6003-rev-list-topo-order.sh +++ b/t/t6003-rev-list-topo-order.sh @@ -8,12 +8,6 @@ test_description='Tests git rev-list --topo-order functionality' . ./test-lib.sh . "$TEST_DIRECTORY"/lib-t6000.sh # t6xxx specific functions -if ! test_have_prereq PERL_TEST_HELPERS -then - skip_all='skipping rev-list topo-order tests; Perl not available' - test_done -fi - list_duplicates() { "$@" | sort | uniq -d
The `name_from_description()` test helper uses Perl to munge a given description and convert it into a name. Refactor it to instead use a combination of sed(1) and tr(1) so that we drop PERL_TEST_HELPERS prerequisites in users of this library. Signed-off-by: Patrick Steinhardt <ps@pks.im> --- t/lib-t6000.sh | 13 ++++++------- t/t6002-rev-list-bisect.sh | 6 ------ t/t6003-rev-list-topo-order.sh | 6 ------ 3 files changed, 6 insertions(+), 19 deletions(-)