tests: factor out terminal handling from t7006
[git/mjg.git] / t / lib-terminal.sh
blob6fc33db6c14ffaa25e8b086a563be5f7b3829949
1 #!/bin/sh
3 test_expect_success 'set up terminal for tests' '
4 if test -t 1
5 then
6 >stdout_is_tty
7 elif
8 test_have_prereq PERL &&
9 "$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl \
10 sh -c "test -t 1"
11 then
12 >test_terminal_works
16 if test -e stdout_is_tty
17 then
18 test_terminal() { "$@"; }
19 test_set_prereq TTY
20 elif test -e test_terminal_works
21 then
22 test_terminal() {
23 "$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl "$@"
25 test_set_prereq TTY
26 else
27 say "# no usable terminal, so skipping some tests"