summaryrefslogtreecommitdiff
path: root/t/lib-terminal.sh
AgeCommit message (Collapse)AuthorFilesLines
2013-10-29t: use perl instead of "$PERL_PATH" where applicableLibravatar Jeff King1-2/+2
As of the last commit, we can use "perl" instead of "$PERL_PATH" when running tests, as the former is now a function which uses the latter. As the shorter "perl" is easier on the eyes, let's switch to using it everywhere. This is not quite a mechanical s/$PERL_PATH/perl/ replacement, though. There are some places where we invoke perl from a script we generate on the fly, and those scripts do not have access to our internal shell functions. The result can be double-checked by running: ln -s /bin/false bin-wrappers/perl make test which continues to pass even after this patch. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2011-02-17tests: skip terminal output tests on OS XLibravatar Jonathan Nieder1-3/+19
On Mac OS X 10.5.0, test_terminal gets stuck reading from the pty master every once in a while. To reproduce the problem: perl -MIO::Pty -MFile::Copy -e ' for (my $i = 0;; $i++) { my $master = new IO::Pty; my $slave = $master->slave; if (fork == 0) { close $master or die "close: $!"; open STDOUT, ">&", $slave or die "dup2: $!"; close $slave or die "close: $!"; exec("echo", "hi", $i) or die "exec: $!"; } close $slave or die "close: $!"; copy($master, \*STDOUT) or die "copy: $!"; close $master or die "close: $!"; wait; } ' It blocks after 7000 iterations or so in sysread(). The relevant sysread() call is the second call by the parent, which presumably executes before the child dies but after the parent has read all output from there. Since this is an intermitent problem, the quick check of terminal support in lib-terminal doesn't catch it. Skip these tests on the Mac for now. Noticed-by: Thomas Rast <trast@student.ethz.ch> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-18test_terminal: ensure redirections work reliablyLibravatar Jonathan Nieder1-28/+10
For terminal tests that capture output/stderr, the TTY prerequisite warning does not quite work for commands like test_terminal foo >out 2>err because the warning gets "swallowed" up by the redirection that's supposed only to be done by the subcommand. Even worse, the outcome depends on whether stdout was already a terminal (in which case test_terminal is a noop) or not (in which case test_terminal introduces a pseudo-tty in the middle of the pipeline). $ test_terminal.perl sh -c 'test -t 1 && echo >&2 YES' >out YES $ sh -c 'test -t 1 && echo >&2 YES' >out $ So: - use the test_terminal script even when running with "-v". - skip tests that require a terminal when the test_terminal script is unusable because IO::Pty is not installed. - write the "need to declare TTY prerequisite" message to fd 4, where it will be printed when running tests with -v, rather than being swallowed up by an unrelated redireciton. Noticed-by: Tay Ray Chuan <rctay89@gmail.com> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-18test_terminal: catch use without TTY prerequisiteLibravatar Jonathan Nieder1-2/+11
It is easy to forget to declare the TTY prerequisite when writing tests on a system where it would always be satisfied (because IO::Pty is installed; see v1.7.3-rc0~33^2, 2010-08-16 for example). Automatically detect this problem so there is no need to remember. test_terminal: need to declare TTY prerequisite test_must_fail: command not found: test_terminal echo hi test_terminal returns status 127 in this case to simulate not being available. Also replace the SIMPLEPAGERTTY prerequisite on one test with "SIMPLEPAGER,TTY", since (1) the latter is supported now and (2) the prerequisite detection relies on the TTY prereq being explicitly declared. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-18tests: test terminal output to both stdout and stderrLibravatar Jeff King1-4/+4
Some outputs (like the pager) care whether stdout is a terminal. Others (like progress meters) care about stderr. This patch sets up both. Technically speaking, we could go further and set up just one (because either the other goes to a terminal, or because our tests are only interested in one). This patch does both to keep the interface to lib-terminal simple. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
2010-10-18tests: factor out terminal handling from t7006Libravatar Jeff King1-0/+28
Other tests besides the pager ones may want to check how we handle output to a terminal. This patch makes the code reusable. Signed-off-by: Jeff King <peff@peff.net> Reviewed-by: Jonathan Nieder <jrnieder@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>