Re: [PATCH 15/20] t/lib-t6000: refactor `name_from_description()` to not depend on Perl
On Thu, Mar 20, 2025 at 03:41:11PM -0400, Eric Sunshine wrote:
Show 30 quoted lines
> 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