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

Re: [PATCH v2 2/2] t1006: ensure cat-file info isn't buffered by default

From
EWEric Wong <e@80x24.org>
Date
Jun 21, 2024, 20:00 UTC
Message-ID
<20240621200002.M726804@dcvr>
In-Reply-To
<20240621071640.GD2105230@coredump.intra.peff.net>
Jeff King <peff@peff.net> wrote:
> On Tue, Jun 18, 2024 at 09:30:41PM +0000, Eric Wong wrote:
> 
> > +script='
<snip>
Show 17 quoted lines
> > +expect="$hello_oid blob $hello_size"
> > +
> > +test_expect_success PERL '--batch-check is unbuffered by default' '
> > +	perl -e "$script" -- --batch-check $hello_oid "$expect"
> > +'
> 
> We often use "perl -e" for one-liners, etc, but this is pretty big.
> Maybe:
> 
>   cat >foo.pl <<-\EOF
>   ...
>   EOF
>   perl foo.pl -- ...
> 
> would be more readable? To be clear I don't think there's anything
> incorrect about your usage, but it would match the style of our suite a
> bit better.

*shrug* It doesn't save the nested quoting/expansion confusion; but it's Junio's call. I don't think a v3 is worth the effort.

> Likewise, it would be usual in our suite for the helper to do the
> minimum that needs to be in perl, and use our normal functions for
> things like comparing output (rather than taking its own "expect"
> argument).
<snip>
Show 5 quoted lines
> +test_expect_success PERL '--batch-check is unbuffered by default' '
> +	echo "$hello_oid" |
> +	perl run-and-wait.pl git cat-file --batch-check >out &&
> +	echo "$hello_oid blob $hello_size" >expect &&
> +	test_cmp expect out

I prefer to avoid process spawning overhead from test_cmp; but that's a small drop in a big bucket.

Show 11 quoted lines
> I went for brevity above. Notably missing are:
> 
>   - the use of strict/warnings. I think we've shied away from these in
>     the test suite because we want to run on any version of perl. In my
>     experience most strict/warnings output is actually telling you about
>     obvious garbage, but not always. IIRC perl got more strict about
>     "()" around lists in some contexts a few years back, and code which
>     used to be OK started generating warnings. OTOH, those warnings were
>     probably a sign of problems-to-come, anyway. Without "FATAL",
>     though, I think "use warnings" is not doing much good (nobody is
>     ever going to see its output if the test isn't failing).

It may make problems easier to find if there are failures, so I think the potential benefits outweight any downsides.

>   - I dropped the close/waitpid. I guess maybe it is valuable to confirm
>     that cat-file did not barf, but IMHO the important thing here is
>     testing that it produced the single line of output we expected.

I've found some unexpected bugs through excessive error checking in the past, so much preferred to keep them.

Previous: Jeff KingNext: Jeff King
Message 11 of 16 in “cat-file related doc and test”
  1. 0/2 cat-file related doc and testEric Wong, Jun 17, 2024
  2. 1/2 Git.pm: use array in command_bidi_pipe exampleEric Wong, Jun 17, 2024
  3. Junio C HamanoJun 17, 2024
  4. 2/2 t9700: ensure cat-file info isn't buffered by defaultEric Wong, Jun 17, 2024
  5. Junio C HamanoJun 17, 2024
  6. 2/2 t1006: ensure cat-file info isn't buffered by defaultEric Wong, Jun 18, 2024
  7. Junio C HamanoJun 18, 2024
  8. Eric WongJun 19, 2024
  9. Junio C HamanoJun 20, 2024
  10. Jeff KingJun 21, 2024
  11. Eric WongJun 21, 2024
  12. Jeff KingJun 24, 2024
  13. Junio C HamanoJun 17, 2024
  14. Phillip WoodJun 19, 2024
  15. Eric WongJun 19, 2024
  16. Phillip WoodJun 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.