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

Re: [PATCH 1/2] test-lib: allow test snippets as here-docs

From
Jeff King <peff@peff.net>
Date
Apr 9, 2021, 22:30 UTC
Message-ID
<YHDVhmveVlkHPBNb@coredump.intra.peff.net>
In-Reply-To
<YHDVAxxKDzfTlq3h@coredump.intra.peff.net>
On Fri, Apr 09, 2021 at 06:28:19PM -0400, Jeff King wrote:
Show 7 quoted lines
> +   If <script> is `-` (a single dash), then the script to run is read
> +   from stdin. This lets you more easily use single quotes within the
> +   script by using a here-doc. For example:
> +
> +        test_expect_success 'output contains expected string' <<-\EOT
> +	        grep "this string has 'quotes' in it" output
> +	EOT

Whoops, this should have an extra "-", of course (I got this wrong in the cover letter, too). I.e.:

  test_expect_success 'whatever' - <<\EOT
     ...
  EOT
It would be nice to drop it, but then:
  test_expect_success PREREQ 'whatever' <<\EOT

becomes ambiguous (and I don't think there is a portable and reliable way to decide that our input is coming from a here-doc versus the original stdin).

-Peff
Previous: Jeff KingNext: Junio C Hamano
Message 3 of 10 in “here-doc test bodies”
  1. 0/2 here-doc test bodiesJeff King, Apr 9, 2021
  2. 1/2 test-lib: allow test snippets as here-docsJeff King, Apr 9, 2021
  3. Jeff KingApr 9, 2021
  4. Junio C HamanoApr 9, 2021
  5. Junio C HamanoApr 10, 2021
  6. Jeff KingApr 10, 2021
  7. Ævar Arnfjörð BjarmasonApr 10, 2021
  8. 2/2 t1404: convert to here-doc test bodiesJeff King, Apr 9, 2021
  9. Derrick StoleeApr 10, 2021
  10. Jeff KingApr 10, 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.