t / lib-terminal.shon commit tests: factor out terminal handling from t7006 (cc4e48f)
   1#!/bin/sh
   2
   3test_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
  13        fi
  14'
  15
  16if test -e stdout_is_tty
  17then
  18        test_terminal() { "$@"; }
  19        test_set_prereq TTY
  20elif test -e test_terminal_works
  21then
  22        test_terminal() {
  23                "$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl "$@"
  24        }
  25        test_set_prereq TTY
  26else
  27        say "# no usable terminal, so skipping some tests"
  28fi