1
0
mirror of https://github.com/git/git.git synced 2024-09-28 06:30:37 +02:00
git/t/lib-terminal.sh
Jeff King e23f436c35 tests: test terminal output to both stdout and stderr
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-18 16:20:19 -07:00

29 lines
534 B
Bash

#!/bin/sh
test_expect_success 'set up terminal for tests' '
if test -t 1 && test -t 2
then
>have_tty
elif
test_have_prereq PERL &&
"$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl \
sh -c "test -t 1 && test -t 2"
then
>test_terminal_works
fi
'
if test -e have_tty
then
test_terminal() { "$@"; }
test_set_prereq TTY
elif test -e test_terminal_works
then
test_terminal() {
"$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl "$@"
}
test_set_prereq TTY
else
say "# no usable terminal, so skipping some tests"
fi