t/helper: merge test-run-command into test-tool

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Nguyễn Thái Ngọc Duy committed Mar 24, 2018 at 08:44 UTC ae6a51f5a1c1bcc241543ee4da5cad4504bd8798
5 files changed +17 -14
Makefile
+1 -1
@@ -675,6 +675,7 @@ TEST_BUILTINS_OBJS += test-read-cache.o
675 TEST_BUILTINS_OBJS += test-ref-store.o
676 TEST_BUILTINS_OBJS += test-regex.o
677 TEST_BUILTINS_OBJS += test-revision-walking.o
678 +TEST_BUILTINS_OBJS += test-run-command.o
679 TEST_BUILTINS_OBJS += test-sha1.o
680
681 TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
@@ -683,7 +684,6 @@ TEST_PROGRAMS_NEED_X += test-fake-ssh
684 TEST_PROGRAMS_NEED_X += test-line-buffer
685 TEST_PROGRAMS_NEED_X += test-parse-options
686 TEST_PROGRAMS_NEED_X += test-write-cache
686 -TEST_PROGRAMS_NEED_X += test-run-command
687 TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
688 TEST_PROGRAMS_NEED_X += test-sha1-array
689 TEST_PROGRAMS_NEED_X += test-sigchain
t/helper/test-run-command.c
+2 -1
@@ -8,6 +8,7 @@
8 * published by the Free Software Foundation.
9 */
10
11 +#include "test-tool.h"
12 #include "git-compat-util.h"
13 #include "run-command.h"
14 #include "argv-array.h"
@@ -49,7 +50,7 @@ static int task_finished(int result,
50 return 1;
51 }
52
52 -int cmd_main(int argc, const char **argv)
53 +int cmd__run_command(int argc, const char **argv)
54 {
55 struct child_process proc = CHILD_PROCESS_INIT;
56 int jobs;
t/helper/test-tool.c
+1
@@ -30,6 +30,7 @@ static struct test_cmd cmds[] = {
30 { "ref-store", cmd__ref_store },
31 { "regex", cmd__regex },
32 { "revision-walking", cmd__revision_walking },
33 + { "run-command", cmd__run_command },
34 { "sha1", cmd__sha1 },
35 };
36
t/helper/test-tool.h
+1
@@ -24,6 +24,7 @@ int cmd__read_cache(int argc, const char **argv);
24 int cmd__ref_store(int argc, const char **argv);
25 int cmd__regex(int argc, const char **argv);
26 int cmd__revision_walking(int argc, const char **argv);
27 +int cmd__run_command(int argc, const char **argv);
28 int cmd__sha1(int argc, const char **argv);
29
30 #endif
t/t0061-run-command.sh
+12 -12
@@ -14,13 +14,13 @@ EOF
14 >empty
15
16 test_expect_success 'start_command reports ENOENT' '
17 - test-run-command start-command-ENOENT ./does-not-exist
17 + test-tool run-command start-command-ENOENT ./does-not-exist
18 '
19
20 test_expect_success 'run_command can run a command' '
21 cat hello-script >hello.sh &&
22 chmod +x hello.sh &&
23 - test-run-command run-command ./hello.sh >actual 2>err &&
23 + test-tool run-command run-command ./hello.sh >actual 2>err &&
24
25 test_cmp hello-script actual &&
26 test_cmp empty err
@@ -31,7 +31,7 @@ test_expect_success !MINGW 'run_command can run a script without a #! line' '
31 cat hello-script
32 EOF
33 chmod +x hello &&
34 - test-run-command run-command ./hello >actual 2>err &&
34 + test-tool run-command run-command ./hello >actual 2>err &&
35
36 test_cmp hello-script actual &&
37 test_cmp empty err
@@ -45,7 +45,7 @@ test_expect_success 'run_command does not try to execute a directory' '
45 EOF
46
47 PATH=$PWD/bin1:$PWD/bin2:$PATH \
48 - test-run-command run-command greet >actual 2>err &&
48 + test-tool run-command run-command greet >actual 2>err &&
49 test_cmp bin2/greet actual &&
50 test_cmp empty err
51 '
@@ -62,7 +62,7 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' '
62 EOF
63
64 PATH=$PWD/bin1:$PWD/bin2:$PATH \
65 - test-run-command run-command greet >actual 2>err &&
65 + test-tool run-command run-command greet >actual 2>err &&
66 test_cmp bin2/greet actual &&
67 test_cmp empty err
68 '
@@ -70,7 +70,7 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' '
70 test_expect_success POSIXPERM 'run_command reports EACCES' '
71 cat hello-script >hello.sh &&
72 chmod -x hello.sh &&
73 - test_must_fail test-run-command run-command ./hello.sh 2>err &&
73 + test_must_fail test-tool run-command run-command ./hello.sh 2>err &&
74
75 grep "fatal: cannot exec.*hello.sh" err
76 '
@@ -104,17 +104,17 @@ World
104 EOF
105
106 test_expect_success 'run_command runs in parallel with more jobs available than tasks' '
107 - test-run-command run-command-parallel 5 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
107 + test-tool run-command run-command-parallel 5 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
108 test_cmp expect actual
109 '
110
111 test_expect_success 'run_command runs in parallel with as many jobs as tasks' '
112 - test-run-command run-command-parallel 4 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
112 + test-tool run-command run-command-parallel 4 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
113 test_cmp expect actual
114 '
115
116 test_expect_success 'run_command runs in parallel with more tasks than jobs available' '
117 - test-run-command run-command-parallel 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
117 + test-tool run-command run-command-parallel 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
118 test_cmp expect actual
119 '
120
@@ -128,7 +128,7 @@ asking for a quick stop
128 EOF
129
130 test_expect_success 'run_command is asked to abort gracefully' '
131 - test-run-command run-command-abort 3 false 2>actual &&
131 + test-tool run-command run-command-abort 3 false 2>actual &&
132 test_cmp expect actual
133 '
134
@@ -137,14 +137,14 @@ no further jobs available
137 EOF
138
139 test_expect_success 'run_command outputs ' '
140 - test-run-command run-command-no-jobs 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
140 + test-tool run-command run-command-no-jobs 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual &&
141 test_cmp expect actual
142 '
143
144 test_trace () {
145 expect="$1"
146 shift
147 - GIT_TRACE=1 test-run-command "$@" run-command true 2>&1 >/dev/null | \
147 + GIT_TRACE=1 test-tool run-command "$@" run-command true 2>&1 >/dev/null | \
148 sed 's/.* run_command: //' >actual &&
149 echo "$expect true" >expect &&
150 test_cmp expect actual