summaryrefslogtreecommitdiff
path: root/t/t1800-hook.sh
diff options
context:
space:
mode:
Diffstat (limited to 't/t1800-hook.sh')
-rwxr-xr-xt/t1800-hook.sh31
1 files changed, 31 insertions, 0 deletions
diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh
index 26ed5e1..210f429 100755
--- a/t/t1800-hook.sh
+++ b/t/t1800-hook.sh
@@ -4,6 +4,7 @@ test_description='git-hook command'
TEST_PASSES_SANITIZE_LEAK=true
. ./test-lib.sh
+. "$TEST_DIRECTORY"/lib-terminal.sh
test_expect_success 'git hook usage' '
test_expect_code 129 git hook &&
@@ -120,4 +121,34 @@ test_expect_success 'git -c core.hooksPath=<PATH> hook run' '
test_cmp expect actual
'
+test_hook_tty () {
+ cat >expect <<-\EOF
+ STDOUT TTY
+ STDERR TTY
+ EOF
+
+ test_when_finished "rm -rf repo" &&
+ git init repo &&
+
+ test_commit -C repo A &&
+ test_commit -C repo B &&
+ git -C repo reset --soft HEAD^ &&
+
+ test_hook -C repo pre-commit <<-EOF &&
+ test -t 1 && echo STDOUT TTY >>actual || echo STDOUT NO TTY >>actual &&
+ test -t 2 && echo STDERR TTY >>actual || echo STDERR NO TTY >>actual
+ EOF
+
+ test_terminal git -C repo "$@" &&
+ test_cmp expect repo/actual
+}
+
+test_expect_success TTY 'git hook run: stdout and stderr are connected to a TTY' '
+ test_hook_tty hook run pre-commit
+'
+
+test_expect_success TTY 'git commit: stdout and stderr are connected to a TTY' '
+ test_hook_tty commit -m"B.new"
+'
+
test_done