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

[PATCH v2 0/9] here-doc test bodies (now with 100% more chainlinting)

From
Jeff King <peff@peff.net>
Date
Jul 10, 2024, 08:34 UTC
Message-ID
<20240710083416.GA2060328@coredump.intra.peff.net>
In-Reply-To
<20240701220815.GA20293@coredump.intra.peff.net>
On Mon, Jul 01, 2024 at 06:08:15PM -0400, Jeff King wrote:
Show 11 quoted lines
> This is a re-post of an idea from 2021:
> 
>   https://lore.kernel.org/git/YHDUg6ZR5vu93kGm@coredump.intra.peff.net/
> 
> that people seemed mostly positive on, and I just never got around to
> following up. Mostly because it's not life-changing, but I think it is a
> small quality of life improvement, and it came up again recently in:
> 
>   https://lore.kernel.org/git/20240701032047.GA610406@coredump.intra.peff.net/
> 
> So I thought it was worth considering again.

And here's a v2 that addresses the chainlint issue mentioned by Eric. There were a lot of patches flying around, but this is only the second posting of the whole topic. This can replace all of what's in jk/test-body-in-here-doc.

I bailed on trying to notice:
  test_expect_success 'oops, forgot the dash' <<\EOT
or:
  test_expect_success 'oops, forgot the here doc' -
or:
  test_expect_success <<\EOT 'here-doc tag comes first' -

As those all require some big refactoring ScriptParser::check_test(), etc, and this topic has already grown quite a lot.

I won't bother with a range diff; patches 8 and 9 are just the original v1 patches verbatim, and everything else is new.

  [1/9]: chainlint.pl: add test_expect_success call to test snippets
    Test refactoring for chainlint before we change it.
  [2/9]: chainlint.pl: only start threads if jobs > 1
  [3/9]: chainlint.pl: do not spawn more threads than we have scripts
    These two aren't strictly necessary, but some easy speedups I hit
    along the way (they depend on patch 1 for showing the speedup).
  [4/9]: chainlint.pl: force CRLF conversion when opening input files
  [5/9]: chainlint.pl: check line numbers in expected output
    These two make the chainlint tests more robust against the
    line-number bugs we hit while developing patch 6.
  [6/9]: chainlint.pl: recognize test bodies defined via heredoc
    This is Eric's fix (thanks!) for chainlint to recognize the new
    format, including the line-number fixes that we discussed.
  [7/9]: chainlint.pl: add tests for test body in heredoc
    And then I kept my tests of the new feature split into their own
    commit.
  [8/9]: test-lib: allow test snippets as here-docs
  [9/9]: t: convert some here-doc test bodies
    And then this is the actual purpose of the series. ;)
 t/Makefile                                    |  16 +-
 t/README                                      |   8 +
 t/chainlint-cat.pl                            |  29 +++
 t/chainlint.pl                                |  33 ++-
 t/chainlint/arithmetic-expansion.expect       |  18 +-
 t/chainlint/arithmetic-expansion.test         |   2 +
 t/chainlint/bash-array.expect                 |  20 +-
 t/chainlint/bash-array.test                   |   2 +
 t/chainlint/blank-line-before-esac.expect     |  36 ++--
 t/chainlint/blank-line-before-esac.test       |   2 +
 t/chainlint/blank-line.expect                 |  16 +-
 t/chainlint/blank-line.test                   |   2 +
 t/chainlint/block-comment.expect              |  16 +-
 t/chainlint/block-comment.test                |   2 +
 t/chainlint/block.expect                      |  46 ++--
 t/chainlint/block.test                        |   2 +
 t/chainlint/broken-chain.expect               |  12 +-
 t/chainlint/broken-chain.test                 |   2 +
 t/chainlint/case-comment.expect               |  22 +-
 t/chainlint/case-comment.test                 |   2 +
 t/chainlint/case.expect                       |  38 ++--
 t/chainlint/case.test                         |   2 +
 t/chainlint/chain-break-background.expect     |  18 +-
 t/chainlint/chain-break-background.test       |   2 +
 t/chainlint/chain-break-continue.expect       |  24 +--
 t/chainlint/chain-break-continue.test         |   2 +
 t/chainlint/chain-break-false.expect          |  18 +-
 t/chainlint/chain-break-false.test            |   2 +
 t/chainlint/chain-break-return-exit.expect    |  38 ++--
 t/chainlint/chain-break-return-exit.test      |   2 +
 t/chainlint/chain-break-status.expect         |  18 +-
 t/chainlint/chain-break-status.test           |   2 +
 t/chainlint/chained-block.expect              |  18 +-
 t/chainlint/chained-block.test                |   2 +
 t/chainlint/chained-subshell.expect           |  20 +-
 t/chainlint/chained-subshell.test             |   2 +
 .../close-nested-and-parent-together.expect   |   6 +-
 .../close-nested-and-parent-together.test     |   2 +
 t/chainlint/close-subshell.expect             |  52 ++---
 t/chainlint/close-subshell.test               |   2 +
 .../command-substitution-subsubshell.expect   |   4 +-
 .../command-substitution-subsubshell.test     |   2 +
 t/chainlint/command-substitution.expect       |  18 +-
 t/chainlint/command-substitution.test         |   2 +
 t/chainlint/comment.expect                    |  16 +-
 t/chainlint/comment.test                      |   2 +
 t/chainlint/complex-if-in-cuddled-loop.expect |  18 +-
 t/chainlint/complex-if-in-cuddled-loop.test   |   2 +
 t/chainlint/cuddled-if-then-else.expect       |  12 +-
 t/chainlint/cuddled-if-then-else.test         |   2 +
 t/chainlint/cuddled-loop.expect               |   8 +-
 t/chainlint/cuddled-loop.test                 |   2 +
 t/chainlint/cuddled.expect                    |  34 +--
 t/chainlint/cuddled.test                      |   2 +
 t/chainlint/double-here-doc.expect            |  24 +--
 t/chainlint/double-here-doc.test              |   2 +
 t/chainlint/dqstring-line-splice.expect       |  10 +-
 t/chainlint/dqstring-line-splice.test         |   2 +
 t/chainlint/dqstring-no-interpolate.expect    |  24 +--
 t/chainlint/dqstring-no-interpolate.test      |   2 +
 t/chainlint/empty-here-doc.expect             |   8 +-
 t/chainlint/empty-here-doc.test               |   2 +
 t/chainlint/exclamation.expect                |   8 +-
 t/chainlint/exclamation.test                  |   2 +
 t/chainlint/exit-loop.expect                  |  48 ++---
 t/chainlint/exit-loop.test                    |   2 +
 t/chainlint/exit-subshell.expect              |  10 +-
 t/chainlint/exit-subshell.test                |   2 +
 t/chainlint/for-loop-abbreviated.expect       |  10 +-
 t/chainlint/for-loop-abbreviated.test         |   2 +
 t/chainlint/for-loop.expect                   |  28 +--
 t/chainlint/for-loop.test                     |   2 +
 t/chainlint/function.expect                   |  22 +-
 t/chainlint/function.test                     |   2 +
 t/chainlint/here-doc-body-indent.expect       |   2 +
 t/chainlint/here-doc-body-indent.test         |   4 +
 t/chainlint/here-doc-body-pathological.expect |   7 +
 t/chainlint/here-doc-body-pathological.test   |   9 +
 t/chainlint/here-doc-body.expect              |   7 +
 t/chainlint/here-doc-body.test                |   9 +
 t/chainlint/here-doc-close-subshell.expect    |   8 +-
 t/chainlint/here-doc-close-subshell.test      |   2 +
 t/chainlint/here-doc-double.expect            |   2 +
 t/chainlint/here-doc-double.test              |  10 +
 t/chainlint/here-doc-indent-operator.expect   |  22 +-
 t/chainlint/here-doc-indent-operator.test     |   2 +
 .../here-doc-multi-line-command-subst.expect  |  16 +-
 .../here-doc-multi-line-command-subst.test    |   2 +
 t/chainlint/here-doc-multi-line-string.expect |  14 +-
 t/chainlint/here-doc-multi-line-string.test   |   2 +
 t/chainlint/here-doc.expect                   |  50 ++---
 t/chainlint/here-doc.test                     |   2 +
 t/chainlint/if-condition-split.expect         |  14 +-
 t/chainlint/if-condition-split.test           |   2 +
 t/chainlint/if-in-loop.expect                 |  24 +--
 t/chainlint/if-in-loop.test                   |   2 +
 t/chainlint/if-then-else.expect               |  44 ++--
 t/chainlint/if-then-else.test                 |   2 +
 t/chainlint/incomplete-line.expect            |  20 +-
 t/chainlint/incomplete-line.test              |   2 +
 t/chainlint/inline-comment.expect             |  16 +-
 t/chainlint/inline-comment.test               |   2 +
 t/chainlint/loop-detect-failure.expect        |  30 +--
 t/chainlint/loop-detect-failure.test          |   2 +
 t/chainlint/loop-detect-status.expect         |  36 ++--
 t/chainlint/loop-detect-status.test           |   2 +
 t/chainlint/loop-in-if.expect                 |  24 +--
 t/chainlint/loop-in-if.test                   |   2 +
 t/chainlint/loop-upstream-pipe.expect         |  20 +-
 t/chainlint/loop-upstream-pipe.test           |   2 +
 ...ti-line-nested-command-substitution.expect |  36 ++--
 ...ulti-line-nested-command-substitution.test |   2 +
 t/chainlint/multi-line-string.expect          |  28 +--
 t/chainlint/multi-line-string.test            |   2 +
 t/chainlint/negated-one-liner.expect          |  10 +-
 t/chainlint/negated-one-liner.test            |   2 +
 t/chainlint/nested-cuddled-subshell.expect    |  50 ++---
 t/chainlint/nested-cuddled-subshell.test      |   2 +
 t/chainlint/nested-here-doc.expect            |  60 +++---
 t/chainlint/nested-here-doc.test              |   2 +
 t/chainlint/nested-loop-detect-failure.expect |  62 +++---
 t/chainlint/nested-loop-detect-failure.test   |   2 +
 t/chainlint/nested-subshell-comment.expect    |  22 +-
 t/chainlint/nested-subshell-comment.test      |   2 +
 t/chainlint/nested-subshell.expect            |  26 +--
 t/chainlint/nested-subshell.test              |   2 +
 t/chainlint/not-heredoc.expect                |  28 +--
 t/chainlint/not-heredoc.test                  |   2 +
 t/chainlint/one-liner-for-loop.expect         |  18 +-
 t/chainlint/one-liner-for-loop.test           |   2 +
 t/chainlint/one-liner.expect                  |  18 +-
 t/chainlint/one-liner.test                    |   2 +
 t/chainlint/p4-filespec.expect                |   8 +-
 t/chainlint/p4-filespec.test                  |   2 +
 t/chainlint/pipe.expect                       |  20 +-
 t/chainlint/pipe.test                         |   2 +
 t/chainlint/return-loop.expect                |  10 +-
 t/chainlint/return-loop.test                  |   2 +
 t/chainlint/semicolon.expect                  |  38 ++--
 t/chainlint/semicolon.test                    |   2 +
 t/chainlint/sqstring-in-sqstring.expect       |   8 +-
 t/chainlint/sqstring-in-sqstring.test         |   2 +
 t/chainlint/subshell-here-doc.expect          |  60 +++---
 t/chainlint/subshell-here-doc.test            |   2 +
 t/chainlint/subshell-one-liner.expect         |  38 ++--
 t/chainlint/subshell-one-liner.test           |   2 +
 t/chainlint/t7900-subtree.expect              |  44 ++--
 t/chainlint/t7900-subtree.test                |   2 +
 t/chainlint/token-pasting.expect              |  54 ++---
 t/chainlint/token-pasting.test                |   2 +
 t/chainlint/unclosed-here-doc-indent.expect   |   8 +-
 t/chainlint/unclosed-here-doc-indent.test     |   2 +
 t/chainlint/unclosed-here-doc.expect          |  14 +-
 t/chainlint/unclosed-here-doc.test            |   2 +
 t/chainlint/while-loop.expect                 |  28 +--
 t/chainlint/while-loop.test                   |   2 +
 t/t0600-reffiles-backend.sh                   |  38 ++--
 t/t1404-update-ref-errors.sh                  | 196 +++++++++---------
 t/test-lib-functions.sh                       |  32 ++-
 159 files changed, 1285 insertions(+), 1025 deletions(-)
 create mode 100644 t/chainlint-cat.pl
 create mode 100644 t/chainlint/here-doc-body-indent.expect
 create mode 100644 t/chainlint/here-doc-body-indent.test
 create mode 100644 t/chainlint/here-doc-body-pathological.expect
 create mode 100644 t/chainlint/here-doc-body-pathological.test
 create mode 100644 t/chainlint/here-doc-body.expect
 create mode 100644 t/chainlint/here-doc-body.test
 create mode 100644 t/chainlint/here-doc-double.expect
 create mode 100644 t/chainlint/here-doc-double.test
Previous: Eric SunshineNext: Jeff King
Message 50 of 65 in “here-doc test bodies”
  1. 0/2 here-doc test bodiesJeff King, Jul 1, 2024
  2. 1/2 test-lib: allow test snippets as here-docsJeff King, Jul 1, 2024
  3. Eric SunshineJul 1, 2024
  4. Junio C HamanoJul 1, 2024
  5. Jeff KingJul 2, 2024
  6. Jeff KingJul 2, 2024
  7. Eric SunshineJul 2, 2024
  8. Jeff KingJul 6, 2024
  9. Jeff KingJul 2, 2024
  10. Eric SunshineJul 2, 2024
  11. Jeff KingJul 6, 2024
  12. Eric SunshineJul 2, 2024
  13. Eric SunshineJul 2, 2024
  14. Eric SunshineJul 2, 2024
  15. Jeff KingJul 6, 2024
  16. Jeff KingJul 6, 2024
  17. Eric SunshineJul 6, 2024
  18. Eric SunshineJul 6, 2024
  19. Jeff KingJul 6, 2024
  20. Eric SunshineJul 6, 2024
  21. Jeff KingJul 6, 2024
  22. 2/2 t: convert some here-doc test bodiesJeff King, Jul 1, 2024
  23. chainlint.pl: recognize test bodies defined via heredocEric Sunshine, Jul 2, 2024
  24. Jeff KingJul 6, 2024
  25. 1/3 chainlint.pl: fix line number reportingJeff King, Jul 6, 2024
  26. Eric SunshineJul 8, 2024
  27. Jeff KingJul 8, 2024
  28. 2/3 t/chainlint: add test_expect_success call to test snippetsJeff King, Jul 6, 2024
  29. Jeff KingJul 6, 2024
  30. Eric SunshineJul 8, 2024
  31. 3/3 t/chainlint: add tests for test body in heredocJeff King, Jul 6, 2024
  32. Eric SunshineJul 8, 2024
  33. Jeff KingJul 8, 2024
  34. Junio C HamanoJul 6, 2024
  35. Jeff KingJul 6, 2024
  36. Eric SunshineJul 8, 2024
  37. Jeff KingJul 8, 2024
  38. Eric SunshineJul 8, 2024
  39. Eric SunshineJul 8, 2024
  40. Jeff KingJul 10, 2024
  41. Jeff KingJul 10, 2024
  42. Eric SunshineJul 10, 2024
  43. Jeff KingJul 10, 2024
  44. Eric SunshineJul 10, 2024
  45. Eric SunshineJul 8, 2024
  46. Jeff KingJul 8, 2024
  47. Eric SunshineJul 8, 2024
  48. Jeff KingJul 10, 2024
  49. Eric SunshineJul 10, 2024
  50. 0/9 here-doc test bodies (now with 100% more chainlinting)Jeff King, Jul 10, 2024
  51. 1/9 chainlint.pl: add test_expect_success call to test snippetsJeff King, Jul 10, 2024
  52. 2/9 chainlint.pl: only start threads if jobs > 1Jeff King, Jul 10, 2024
  53. 3/9 chainlint.pl: do not spawn more threads than we have scriptsJeff King, Jul 10, 2024
  54. 4/9 chainlint.pl: force CRLF conversion when opening input filesJeff King, Jul 10, 2024
  55. 5/9 chainlint.pl: check line numbers in expected outputJeff King, Jul 10, 2024
  56. Eric SunshineAug 21, 2024
  57. Jeff KingAug 21, 2024
  58. Eric SunshineAug 21, 2024
  59. 6/9 chainlint.pl: recognize test bodies defined via heredocJeff King, Jul 10, 2024
  60. 7/9 chainlint.pl: add tests for test body in heredocJeff King, Jul 10, 2024
  61. 8/9 test-lib: allow test snippets as here-docsJeff King, Jul 10, 2024
  62. 9/9 t: convert some here-doc test bodiesJeff King, Jul 10, 2024
  63. 10/9 t/.gitattributes: ignore whitespace in chainlint expect filesJeff King, Jul 10, 2024
  64. Junio C HamanoJul 10, 2024
  65. Eric SunshineAug 21, 2024

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.