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

Re: [PATCH v2 1/3] test_terminal: redirect child process' stdin to a pty

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Aug 6, 2015, 22:15 UTC
Message-ID
<CAPig+cS0RxCexLG+2ZjCMhDEBCa9HgF6JgC3RWbxRgQwd6uiZg@mail.gmail.com>
In-Reply-To
<1438697331-29948-2-git-send-email-pyokagan@gmail.com>
On Tue, Aug 4, 2015 at 10:08 AM, Paul Tan <pyokagan@gmail.com> wrote:
Show 10 quoted lines
> When resuming, git-am detects if we are trying to feed it patches or not
> by checking if stdin is a TTY.
>
> However, the test library redirects stdin to /dev/null. This makes it
> difficult, for instance, to test the behavior of "git am -3" when
> resuming, as git-am will think we are trying to feed it patches and
> error out.
>
> Support this use case by extending test-terminal.perl to create a
> pseudo-tty for the child process' standard input as well.

An alternative would be to have git-am detect that it is being tested and pretend that isatty() returns true. There is some precedent for having core functionality recognize that it is being tested. See, for instance, environment variable TEST_DATE_NOW, and rev-list --test-bitmap. Doing so would allow the tests work on non-Unix platforms, as well.

Show 12 quoted lines
> Note that due to the way the code is structured, the child's stdin
> pseudo-tty will be closed when we finish reading from our stdin. This
> means that in the common case, where our stdin is attached to /dev/null,
> the child's stdin pseudo-tty will be closed immediately. Some operations
> like isatty(), which git-am uses, require the file descriptor to be
> open, and hence if the success of the command depends on such functions,
> test_terminal's stdin should be redirected to a source with large amount
> of data to ensure that the child's stdin is not closed, e.g.
>
>         test_terminal git am --3way </dev/zero
>
> Signed-off-by: Paul Tan <pyokagan@gmail.com>
Previous: Paul TanNext: Paul Tan
Message 18 of 26 in “"git am" and then "git am -3" regression?”
  1. Junio C HamanoJul 24, 2015
  2. Jeff KingJul 24, 2015
  3. Paul TanJul 26, 2015
  4. Jeff KingJul 26, 2015
  5. Matthieu MoyJul 27, 2015
  6. Jeff KingJul 27, 2015
  7. Junio C HamanoJul 27, 2015
  8. am: let command-line options override saved optionsPaul Tan, Jul 28, 2015
  9. Junio C HamanoJul 28, 2015
  10. Junio C HamanoJul 28, 2015
  11. Paul TanJul 31, 2015
  12. Junio C HamanoJul 31, 2015
  13. Paul TanAug 1, 2015
  14. 0/3 am: let command-line options override saved optionsPaul Tan, Aug 4, 2015
  15. Junio C HamanoAug 4, 2015
  16. 0/3 am: let command-line options override saved optionsPaul Tan, Aug 4, 2015
  17. 1/3 test_terminal: redirect child process' stdin to a ptyPaul Tan, Aug 4, 2015
  18. Eric SunshineAug 6, 2015
  19. Paul TanAug 12, 2015
  20. 2/3 am: let command-line options override saved optionsPaul Tan, Aug 4, 2015
  21. 3/3 am: let --signoff override --no-signoffPaul Tan, Aug 4, 2015
  22. Johannes SchindelinAug 7, 2015
  23. Paul TanAug 12, 2015
  24. Paul TanAug 12, 2015
  25. Junio C HamanoAug 5, 2015
  26. Paul TanAug 5, 2015

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.