summaryrefslogtreecommitdiff
path: root/t/t0061-run-command.sh
diff options
context:
space:
mode:
authorJonathan Nieder <jrnieder@gmail.com>2011-04-20 10:35:08 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-04-20 17:08:54 (GMT)
commitc0f19bf3b9c42036722396ee26d2c173d6abf761 (patch)
treedd7e20beb99fe323f486c68dc2fc7e9205e161de /t/t0061-run-command.sh
parent60e199c4d577514ed810b4ed0b6072fb3dbab903 (diff)
downloadgit-c0f19bf3b9c42036722396ee26d2c173d6abf761.zip
git-c0f19bf3b9c42036722396ee26d2c173d6abf761.tar.gz
git-c0f19bf3b9c42036722396ee26d2c173d6abf761.tar.bz2
tests: check error message from run_command
In git versions starting at v1.7.5-rc0~29^2 until v1.7.5-rc3~2 (Revert "run-command: prettify -D_FORTIFY_SOURCE workaround", 2011-04-18) fixed it, the run_command facility would write a truncated error message when the command is present but cannot be executed for some other reason. For example, if I add a 'hello' command to git: $ echo 'echo hello' >git-hello $ chmod +x git-hello $ PATH=.:$PATH git hello hello and make it non-executable, this is what I normally get: $ chmod -x git-hello $ git hello fatal: cannot exec 'git-hello': Permission denied But with the problematic versions, we get disturbing output: $ PATH=.:$PATH git hello fatal: $ Add some tests to make sure it doesn't happen again. The hello-script used in these tests uses cat instead of echo because on Windows the bash spawned by git converts LF to CRLF in text written by echo while the bash running tests does not, causing the test to fail if "echo" is used. Thanks to Hannes for noticing. Signed-off-by: Jonathan Nieder <jrnieder@gmail.com> Improved-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't/t0061-run-command.sh')
-rwxr-xr-xt/t0061-run-command.sh23
1 files changed, 23 insertions, 0 deletions
diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh
index 10b26e4..8d4938f 100755
--- a/t/t0061-run-command.sh
+++ b/t/t0061-run-command.sh
@@ -7,8 +7,31 @@ test_description='Test run command'
. ./test-lib.sh
+cat >hello-script <<-EOF
+ #!$SHELL_PATH
+ cat hello-script
+EOF
+>empty
+
test_expect_success 'start_command reports ENOENT' '
test-run-command start-command-ENOENT ./does-not-exist
'
+test_expect_success 'run_command can run a command' '
+ cat hello-script >hello.sh &&
+ chmod +x hello.sh &&
+ test-run-command run-command ./hello.sh >actual 2>err &&
+
+ test_cmp hello-script actual &&
+ test_cmp empty err
+'
+
+test_expect_success POSIXPERM 'run_command reports EACCES' '
+ cat hello-script >hello.sh &&
+ chmod -x hello.sh &&
+ test_must_fail test-run-command run-command ./hello.sh 2>err &&
+
+ grep "fatal: cannot exec.*hello.sh" err
+'
+
test_done