3 # Copyright (c) 2009 Ilari Liusvaara
6 test_description
='Test run command'
10 cat >hello-script
<<-EOF
16 test_expect_success
'start_command reports ENOENT' '
17 test-run-command start-command-ENOENT ./does-not-exist
20 test_expect_success
'run_command can run a command' '
21 cat hello-script >hello.sh &&
23 test-run-command run-command ./hello.sh >actual 2>err &&
25 test_cmp hello-script actual &&
29 test_expect_success
!MINGW
'run_command can run a script without a #! line' '
34 test-run-command run-command ./hello >actual 2>err &&
36 test_cmp hello-script actual &&
40 test_expect_success POSIXPERM
'run_command reports EACCES' '
41 cat hello-script >hello.sh &&
43 test_must_fail test-run-command run-command ./hello.sh 2>err &&
45 grep "fatal: cannot exec.*hello.sh" err
48 test_expect_success POSIXPERM
,SANITY
'unreadable directory in PATH' '
49 mkdir local-command &&
50 test_when_finished "chmod u+rwx local-command && rm -fr local-command" &&
51 git config alias.nitfol "!echo frotz" &&
52 chmod a-rx local-command &&
54 PATH=./local-command:$PATH &&
58 test_cmp expect actual
62 preloaded output of a child
65 preloaded output of a child
68 preloaded output of a child
71 preloaded output of a child
76 test_expect_success
'run_command runs in parallel with more jobs available than tasks' '
77 test-run-command run-command-parallel 5 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
78 test_cmp expect actual
81 test_expect_success
'run_command runs in parallel with as many jobs as tasks' '
82 test-run-command run-command-parallel 4 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
83 test_cmp expect actual
86 test_expect_success
'run_command runs in parallel with more tasks than jobs available' '
87 test-run-command run-command-parallel 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
88 test_cmp expect actual
92 preloaded output of a child
93 asking for a quick stop
94 preloaded output of a child
95 asking for a quick stop
96 preloaded output of a child
97 asking for a quick stop
100 test_expect_success
'run_command is asked to abort gracefully' '
101 test-run-command run-command-abort 3 false 2>actual &&
102 test_cmp expect actual
106 no further jobs available
109 test_expect_success
'run_command outputs ' '
110 test-run-command run-command-no-jobs 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
111 test_cmp expect actual