Re: [PATCH 3/3] t/chainlint: add tests for test body in heredoc

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

 



On Sat, Jul 6, 2024 at 2:07 AM Jeff King <peff@xxxxxxxx> wrote:
> 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@xxxxxxxx>
> ---
> 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.

> 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"
   EOF

It'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.





[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