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
Paul Tan <pyokagan@gmail.com>
Date
Aug 12, 2015, 04:16 UTC
Message-ID
<CACRoPnTu=rSMZXaP5y_5Fb9o6u3u=s-HO+Ny4CY226rT6Wx2zA@mail.gmail.com>
In-Reply-To
<CAPig+cS0RxCexLG+2ZjCMhDEBCa9HgF6JgC3RWbxRgQwd6uiZg@mail.gmail.com>
On Fri, Aug 7, 2015 at 6:15 AM, Eric Sunshine <sunshine@sunshineco.com> wrote:
> An alternative would be to have git-am detect that it is being tested
> and pretend that isatty() returns true.

I would vastly prefer a solution that would work for everything, for all the C code and scripts, instead of implementing a workaround in git-am :(

In this case, I implemented a generic solution in test-terminal.perl that works for POSIX systems, so if there are no problems with its implementation, I do think it's better. Other than the fact that it does not work on non-Unix platforms, of course.

The other approach I would consider is to implement a xisatty() function that returns true for xisatty(0) if TEST_TTY=0 or something.

However, I do wonder if this would lead us to have to hack around other functions of terminals as well (e.g. if xisatty(0), tcgetattr()), which would be a big can of worms I think...

> There is some precedent for
> having core functionality recognize that it is being tested. See, for
> instance, environment variable TEST_DATE_NOW,

(Hmm, I took a look, and it seems that TEST_DATE_NOW is only checked in test-date.c...)

> and rev-list --test-bitmap.
> Doing so would allow the tests work on non-Unix
> platforms, as well.

Ehh, if the non-Unix platforms do not implement terminals, it means that the git-am logic to detect if we are attempting to feed it a patch by checking if stdin is a TTY is invalid anyway, so implementing a "yeah-it-is-a-tty" workaround for the sake of tests would be hiding the problem, I think.

Thanks, Paul

Previous: Eric SunshineNext: Paul Tan
Message 19 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.