t7503: does pre-commit-hook learn authorship?
[gitweb.git] / t / lib-terminal.sh
index 6fc33db6c14ffaa25e8b086a563be5f7b3829949..58d911d21b894ba05e878e6efbc234071795c600 100644 (file)
@@ -1,28 +1,35 @@
 #!/bin/sh
 
-test_expect_success 'set up terminal for tests' '
-       if test -t 1
+test_expect_success PERL 'set up terminal for tests' '
+       # Reading from the pty master seems to get stuck _sometimes_
+       # on Mac OS X 10.5.0, using Perl 5.10.0 or 5.8.9.
+       #
+       # Reproduction recipe: run
+       #
+       #       i=0
+       #       while ./test-terminal.perl echo hi $i
+       #       do
+       #               : $((i = $i + 1))
+       #       done
+       #
+       # After 2000 iterations or so it hangs.
+       # https://rt.cpan.org/Ticket/Display.html?id=65692
+       #
+       if test "$(uname -s)" = Darwin
        then
-               >stdout_is_tty
+               :
        elif
-               test_have_prereq PERL &&
                "$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl \
-                       sh -c "test -t 1"
+                       sh -c "test -t 1 && test -t 2"
        then
-               >test_terminal_works
+               test_set_prereq TTY &&
+               test_terminal () {
+                       if ! test_declared_prereq TTY
+                       then
+                               echo >&4 "test_terminal: need to declare TTY prerequisite"
+                               return 127
+                       fi
+                       "$PERL_PATH" "$TEST_DIRECTORY"/test-terminal.perl "$@"
+               }
        fi
 '
-
-if test -e stdout_is_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