git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 12/19] tests: fix broken &&-chains in `{...}` groups

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Dec 11, 2021, 07:32 UTC
Message-ID
<CAPig+cRDKM3E5ZEV-A8Ze7pzDnM+s=xs0ioW_qXoM3yYfu7jSw@mail.gmail.com>
In-Reply-To
<20211210093827.a5s5mby3if5f7a4u@fs>
On Fri, Dec 10, 2021 at 4:38 AM Fabian Stelzer <fs@gigacodes.de> wrote:
Show 18 quoted lines
> On 09.12.2021 00:11, Eric Sunshine wrote:
> >Fix broken &&-chains in `{...}` groups in order to reduce the number of
> >possible lurking bugs.
> >       {
> >-          echo "*.t filter=rot13"
> >+          echo "*.t filter=rot13" &&
> >           echo "*.i ident"
> >       } >.gitattributes &&
> >       {
> >-              echo "expanded-keywords ident"
> >+              echo "expanded-keywords ident" &&
> >               echo "expanded-keywords-crlf ident text eol=crlf"
> >       } >>.gitattributes &&
> >
>
> Wouldn't some of these be better off as heredocs as well?
> There are a couple more below. I personally don't much mind either way but
> since you changed quite a few in an earlier commit why not these?

It's been months since I made these changes, but I think there were at least a couple reasons for not converting these to here-docs. First, in these cases, there were only one or two missing `&&` per block. Had I bulk converted them to here-docs, it would have made for a much more noisy patch, which would have taxed reviewers more, and reviewer-fatigue is a real concern when crafting a lengthy patch series like this one. In the "here-doc conversion" patch, on the other hand, many of those cases involved a significant number of missing `&&`; often every line was missing `&&`. So, the changes in that patch was going to be very noisy anyhow, whether I added missing `&&` or converted to here-docs.

Second...
Show 6 quoted lines
> >       {
> >               echoid insert 444 1 2 3 4 5 a b c d e &&
> >-              echoid contains 44 441 440 444 4440 4444
> >+              echoid contains 44 441 440 444 4440 4444 &&
> >               echo clear
> >       } | test-tool oidtree >actual &&

... there are a number of cases like this which look like they could easily be converted to here-doc, but in fact `echoid` is a function call, so a here-doc wouldn't work. Also...

Show 6 quoted lines
> >       {
> >               echo $(git rev-parse refs/tags/A) refs/tags/A &&
> >-              echo $(git rev-parse refs/tags/A^0) "refs/tags/A^{}"
> >+              echo $(git rev-parse refs/tags/A^0) "refs/tags/A^{}" &&
> >               echo $(git rev-parse refs/tags/C) refs/tags/C
> >       } >expect &&

... this sort of thing could certainly become a here-doc because $(...) will work in a here-doc, but when there is a preponderance of this sort of `{ echo && ... }` block in the test script, it would feel inconsistent to convert a few of them to here-docs.

Previous: Fabian StelzerNext: Eric Sunshine
Message 28 of 47 in “tests: fix broken &&-chains & abort loops on error”
  1. 00/19 tests: fix broken &&-chains & abort loops on errorEric Sunshine, Dec 9, 2021
  2. 01/19 t/lib-pager: use sane_unset() to avoid breaking &&-chainEric Sunshine, Dec 9, 2021
  3. 02/19 t1010: fix unnoticed failure on WindowsEric Sunshine, Dec 9, 2021
  4. Elijah NewrenDec 9, 2021
  5. Eric SunshineDec 9, 2021
  6. 03/19 t1020: avoid aborting entire test script when one test failsEric Sunshine, Dec 9, 2021
  7. 06/19 t6300: make `%(raw:size) --shell` test more robustEric Sunshine, Dec 9, 2021
  8. Jeff KingDec 10, 2021
  9. 04/19 t4202: clarify intent by creating expected content less cleverlyEric Sunshine, Dec 9, 2021
  10. Jeff KingDec 10, 2021
  11. 05/19 t5516: drop unnecessary subshell and command invocationEric Sunshine, Dec 9, 2021
  12. Jeff KingDec 10, 2021
  13. 07/19 t9107: use shell parameter expansion to avoid breaking &&-chainEric Sunshine, Dec 9, 2021
  14. 08/19 tests: simplify construction of large blocks of textEric Sunshine, Dec 9, 2021
  15. 11/19 tests: fix broken &&-chains in `$(...)` command substitutionsEric Sunshine, Dec 9, 2021
  16. Elijah NewrenDec 9, 2021
  17. Eric SunshineDec 9, 2021
  18. Elijah NewrenDec 9, 2021
  19. Jeff KingDec 10, 2021
  20. 10/19 tests: fix broken &&-chains in compound statementsEric Sunshine, Dec 9, 2021
  21. 09/19 tests: use test_write_lines() to generate line-oriented outputEric Sunshine, Dec 9, 2021
  22. Jeff KingDec 10, 2021
  23. Eric SunshineDec 11, 2021
  24. 12/19 tests: fix broken &&-chains in `{...}` groupsEric Sunshine, Dec 9, 2021
  25. Jeff KingDec 10, 2021
  26. Eric SunshineDec 11, 2021
  27. Fabian StelzerDec 10, 2021
  28. Eric SunshineDec 11, 2021
  29. 13/19 tests: apply modern idiom for signaling test failureEric Sunshine, Dec 9, 2021
  30. Jeff KingDec 10, 2021
  31. Eric SunshineDec 11, 2021
  32. 14/19 tests: apply modern idiom for exiting loop upon failureEric Sunshine, Dec 9, 2021
  33. Jeff KingDec 10, 2021
  34. 16/19 t0000-t3999: detect and signal failure within loopEric Sunshine, Dec 9, 2021
  35. 15/19 tests: simplify by dropping unnecessary `for` loopsEric Sunshine, Dec 9, 2021
  36. Elijah NewrenDec 9, 2021
  37. 17/19 t4000-t4999: detect and signal failure within loopEric Sunshine, Dec 9, 2021
  38. Fabian StelzerDec 10, 2021
  39. Eric SunshineDec 11, 2021
  40. 19/19 t6000-t9999: detect and signal failure within loopEric Sunshine, Dec 9, 2021
  41. 18/19 t5000-t5999: detect and signal failure within loopEric Sunshine, Dec 9, 2021
  42. Elijah NewrenDec 9, 2021
  43. Eric SunshineDec 9, 2021
  44. Jeff KingDec 10, 2021
  45. Fabian StelzerDec 10, 2021
  46. Eric SunshineDec 11, 2021
  47. 2/19 t1010: fix unnoticed failure on WindowsEric Sunshine, Dec 11, 2021

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.