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