Re: [PATCH 3/4] tests: drop here-doc check from internal chain-linter
- From
Jeff King <peff@peff.net>
- Date
- Mar 29, 2023, 06:07 UTC
- Message-ID
- <20230329060709.GB1793752@coredump.intra.peff.net>
- In-Reply-To
- <CAPig+cQiOGrDSUc34jHEBp87Rx-dnXNcPcF76bu0SJoOzD+1hw@mail.gmail.com>
On Tue, Mar 28, 2023 at 11:46:37PM -0400, Eric Sunshine wrote:
Show 9 quoted lines
> > Yes, it would look something like that and you chose the correct spot > > to detect the problem, but to get a "pretty" error message properly > > positioned in the input, we need to capture the input stream position > > of the here-doc tag itself in scan_heredoc_tag(). It doesn't look too > > difficult, and I even started writing a bit of code to do it, but I'm > > not sure how soon I can get around to finishing the implementation. > > The attached patch seems to do the job. Apologies for Gmail messing up > the whitespace. It's also attached to the email.
Thanks! I was going to say "please don't consider this urgent", but I see that my nerd-snipe was successful. ;)
Show 10 quoted lines
> This would probably make a good preparatory patch to your [3/4]. As
> mentioned earlier in the thread, the changes to scan_heredoc_tag ()
> capture the input-stream position of the here-doc tag itself, which is
> necessary since it would be too late to do so by the time the error is
> detected by swallow_heredocs(). I don't now when I'll get time to send
> this as a proper patch, so feel free to write a commit message and
> incorporate it into your series if you want to use it. And, of course,
> you have my sign-off already in the patch. It should be easy to add a
> test, as well, in t/chainlint, perhaps as
> unclosed-here-doc.{text,expect}.Thanks, I can take it from here (and I agree doing it as prep for 3/4 is good, as I can then omit a bunch of explanations there). Here are the tests I'll squash in (along with your $indent fix):
diff --git a/t/chainlint/unclosed-here-doc-indent.expect b/t/chainlint/unclosed-here-doc-indent.expect new file mode 100644 index 00000000000..6e17bb66336 --- /dev/null +++ b/t/chainlint/unclosed-here-doc-indent.expect @@ -0,0 +1,4 @@ +command_which_is_run && +cat >expect <<-\EOF ?!HERE?! && +we forget to end the here-doc +command_which_is_gobbled diff --git a/t/chainlint/unclosed-here-doc-indent.test b/t/chainlint/unclosed-here-doc-indent.test new file mode 100644 index 00000000000..5c841a9dfd4 --- /dev/null +++ b/t/chainlint/unclosed-here-doc-indent.test @@ -0,0 +1,4 @@ +command_which_is_run && +cat >expect <<-\EOF && +we forget to end the here-doc +command_which_is_gobbled diff --git a/t/chainlint/unclosed-here-doc.expect b/t/chainlint/unclosed-here-doc.expect new file mode 100644 index 00000000000..c53b6b794a7 --- /dev/null +++ b/t/chainlint/unclosed-here-doc.expect @@ -0,0 +1,7 @@ +command_which_is_run && +cat >expect <<\EOF ?!HERE?! && + we try to end the here-doc below, + but the indentation throws us off + since the operator is not "<<-". + EOF +command_which_is_gobbled diff --git a/t/chainlint/unclosed-here-doc.test b/t/chainlint/unclosed-here-doc.test new file mode 100644 index 00000000000..69d3786c348 --- /dev/null +++ b/t/chainlint/unclosed-here-doc.test @@ -0,0 +1,7 @@ +command_which_is_run && +cat >expect <<\EOF && + we try to end the here-doc below, + but the indentation throws us off + since the operator is not "<<-". + EOF +command_which_is_gobbled -Peff