diff options
Diffstat (limited to 't/t1800-hook.sh')
-rwxr-xr-x | t/t1800-hook.sh | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/t/t1800-hook.sh b/t/t1800-hook.sh index 210f429..8b0234c 100755 --- a/t/t1800-hook.sh +++ b/t/t1800-hook.sh @@ -95,7 +95,7 @@ test_expect_success 'git hook run -- out-of-repo runs excluded' ' test_expect_success 'git -c core.hooksPath=<PATH> hook run' ' mkdir my-hooks && write_script my-hooks/test-hook <<-\EOF && - echo Hook ran $1 >>actual + echo Hook ran $1 EOF cat >expect <<-\EOF && @@ -151,4 +151,38 @@ test_expect_success TTY 'git commit: stdout and stderr are connected to a TTY' ' test_hook_tty commit -m"B.new" ' +test_expect_success 'git hook run a hook with a bad shebang' ' + test_when_finished "rm -rf bad-hooks" && + mkdir bad-hooks && + write_script bad-hooks/test-hook "/bad/path/no/spaces" </dev/null && + + test_expect_code 1 git \ + -c core.hooksPath=bad-hooks \ + hook run test-hook >out 2>err && + test_must_be_empty out && + + # TODO: We should emit the same (or at least a more similar) + # error on MINGW (essentially Git for Windows) and all other + # platforms.. See the OS-specific code in start_command() + grep -E "^(error|fatal): cannot (exec|spawn) .*bad-hooks/test-hook" err +' + +test_expect_success 'stdin to hooks' ' + write_script .git/hooks/test-hook <<-\EOF && + echo BEGIN stdin + cat + echo END stdin + EOF + + cat >expect <<-EOF && + BEGIN stdin + hello + END stdin + EOF + + echo hello >input && + git hook run --to-stdin=input test-hook 2>actual && + test_cmp expect actual +' + test_done |