Re: [PATCH 1/2] test-lib: allow test snippets as here-docs

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Jul 02, 2024 at 05:59:46PM -0400, Eric Sunshine wrote:

> > diff --git a/t/Makefile b/t/Makefile
> > @@ -106,18 +106,28 @@ clean: clean-except-prove-cache
> > +       for i in $$(grep -L "'" $(CHAINLINTTESTS_SRC)); do \
> > +               echo "test_expect_success '$$i' - <<\\\\EOT" && \
> > +               sed -e '/^# LINT: /d' $$i && \
> > +               echo "EOT"; \
> > +       done >>'$(CHAINLINTTMP_SQ)'/tests && \
> 
> Unfortunately, `grep -L` is not POSIX.

Yeah, this was just for illustration. Even if it were portable, I don't
think it's a good direction. :)

> >   1. Move the test_expect_success wrapping lines into each
> >      chainlint/*.test file. It's a little bit of extra boilerplate, but
> >      it makes them a bit easier to reason about on their own.
> 
> Yes. This is exactly what I had in mind for moving forward. It's just
> a one-time noise-patch cost but gives us much more flexibility in
> terms of testing.
> 
> It also makes spot-testing the chainlint self-test files much simpler.
> We would be able to do this:
> 
>     ./chainlint.pl chainlint/block.test
> 
> rather than much more painful:
> 
>     { echo "test_expect_success foo '" && cat chainlint/block.test &&
> echo "'"; } >dummy && ./chainlint.pl dummy; rm dummy

Oh, nice. Having just written new chainlint tests, this made checking
them _way_ easier.

> >   2. Add a few new tests that use here-docs with a few variations
> >      ("<<EOT", "<<\EOT", probably a here-doc inside the test here-doc).
> >
> > Does that sound OK to you?
> 
> Absolutely. I'm very much in favor of these changes.

Great! I have patches which I'll send out in a moment.

-Peff




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux