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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Aug 4, 2015 at 10:08 AM, Paul Tan <pyokagan@xxxxxxxxx> wrote:
> 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.

> 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@xxxxxxxxx>
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]