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

Re: Is t7006-pager.sh racy?

From
Jeff King <peff@peff.net>
Date
Oct 28, 2021, 22:10 UTC
Message-ID
<YXsfvU+faPH6m/m/@coredump.intra.peff.net>
In-Reply-To
<20211028195527.GA2574@szeder.dev>
On Thu, Oct 28, 2021 at 09:55:27PM +0200, SZEDER Gábor wrote:
Show 14 quoted lines
> > 
> > My usual test for an intentional SIGPIPE is "yes". So something like:
> > 
> >   git -p \
> >     -c core.pager='exit 0' \
> >     -c alias.yes='!yes' \
> >     yes
> > 
> > will reliably trigger SIGPIPE from yes, which git.c will then translate
> > into an exit code of 141.
> 
> Oh, that's clever.  Alas it's not applicable to our tests, because
> 'yes' is not portable; 8648732e29 (t/test-lib.sh: provide a shell
> implementation of the 'yes' utility, 2009-08-28).
True, though it would be easy enough to do:
  git -c alias.yes='!while true; do echo y; done' yes
> > So something like "git log --stdin" works, but you have to contort
> > yourself a bit to make it race-free:
> [...]
> Ugh.  I think this would work reliably, but...  ugh :)
Yes. :)
Show 6 quoted lines
> I wonder whether we could do this as a new pair of 'test-tool'
> helpers, one to run the pager through the usual pager-invoking
> machinery and to generate a lot of output, the other to be used as the
> early-exiting pager, with a pipe between the two to ensure that the
> SIGPIPE does happen.  Well, essentially the same that you outlined
> above but in C instead of shell, which I somehow find less "ugh".

Maybe, though now we may be diverging from how git.c uses the pager. As gross as what I wrote is, it is testing the code we want to test, I think. I am not sure that the alias vs builtin thing is worth caring about anyway, though, in which case the alias.yes thing above would be fine.

-Peff
Previous: SZEDER GáborNext: Jeff King
Message 5 of 17 in “Is t7006-pager.sh racy?”
  1. Junio C HamanoOct 24, 2021
  2. SZEDER GáborOct 24, 2021
  3. Jeff KingOct 25, 2021
  4. SZEDER GáborOct 28, 2021
  5. Jeff KingOct 28, 2021
  6. Jeff KingNov 21, 2021
  7. Jeff KingNov 21, 2021
  8. t7006: clean up SIGPIPE handling in trace2 testsJeff King, Nov 21, 2021
  9. Jeff KingNov 21, 2021
  10. Junio C HamanoNov 22, 2021
  11. Jeff KingNov 22, 2021
  12. Jeff KingNov 22, 2021
  13. Junio C HamanoNov 22, 2021
  14. Junio C HamanoNov 22, 2021
  15. Jeff KingNov 22, 2021
  16. run-command: unify signal and regular logic for wait_or_whine()Jeff King, Nov 22, 2021
  17. Ævar Arnfjörð BjarmasonDec 1, 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.