Re: [PATCH 3/3] t/chainlint: add tests for test body in heredoc
- From
Eric Sunshine <sunshine@sunshineco.com>
- Date
- Jul 8, 2024, 02:43 UTC
- Message-ID
- <CAPig+cRzoyxQpNf15nGeHDdDQK64KRJXLdgKN2rkXaN+2SjTZQ@mail.gmail.com>
- In-Reply-To
- <20240706060754.GC700151@coredump.intra.peff.net>
On Sat, Jul 6, 2024 at 2:07 AM Jeff King <peff@peff.net> wrote:
Show 13 quoted lines
> The chainlint.pl script recently learned about our new: > > test_expect_success 'some test' - <<\EOT > TEST_BODY > EOT > > syntax, where TEST_BODY should be checked in the usual way. Let's make > sure this works by adding a few tests. [...] > > Signed-off-by: Jeff King <peff@peff.net> > --- > These could also be squashed into Eric's patch which introduces the new > functionality.
As the author of these tests, you should get credit, so I'd proposed not squashing this into my patch.
Show 11 quoted lines
> diff --git a/t/chainlint/here-doc-body.test b/t/chainlint/here-doc-body.test > @@ -0,0 +1,9 @@ > +test_expect_success 'here-doc-body' - <<\EOT > + echo "missing chain before" > + cat >file <<-\EOF && > + inside inner here-doc > + these are not shell commands > + EOF > + echo "missing chain after" > + echo "but this line is OK because it's the end" > +EOT
This one made me think of an additional pathological case, though I'm not sure it's worth having a test:
test_expect_success 'pathological-here-doc-body' - <<\EOF
echo "missing chain before"
cat >file <<-\EOF &&
inside inner here-doc
these are not shell commands
EOF
echo "missing chain after"
echo "but this line is OK because it's the end"
EOFIt's exactly the same as your test except that the same tag ("EOF") is used for both outer and inner heredocs. It works because the outer heredoc is introduced with `<<` whereas the inner with `<<-`. The opposite case, in which outer is introduced with `<<-` and inner with `<<`, obviously would be bogus.