Skip to content

Commit ae6a51f

Browse files
pcloudsgitster
authored andcommitted
t/helper: merge test-run-command into test-tool
Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 77d4b8c commit ae6a51f

File tree

5 files changed

+17
-14
lines changed

5 files changed

+17
-14
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,6 +675,7 @@ TEST_BUILTINS_OBJS += test-read-cache.o
675675
TEST_BUILTINS_OBJS += test-ref-store.o
676676
TEST_BUILTINS_OBJS += test-regex.o
677677
TEST_BUILTINS_OBJS += test-revision-walking.o
678+
TEST_BUILTINS_OBJS += test-run-command.o
678679
TEST_BUILTINS_OBJS += test-sha1.o
679680

680681
TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
@@ -683,7 +684,6 @@ TEST_PROGRAMS_NEED_X += test-fake-ssh
683684
TEST_PROGRAMS_NEED_X += test-line-buffer
684685
TEST_PROGRAMS_NEED_X += test-parse-options
685686
TEST_PROGRAMS_NEED_X += test-write-cache
686-
TEST_PROGRAMS_NEED_X += test-run-command
687687
TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
688688
TEST_PROGRAMS_NEED_X += test-sha1-array
689689
TEST_PROGRAMS_NEED_X += test-sigchain

t/helper/test-run-command.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* published by the Free Software Foundation.
99
*/
1010

11+
#include "test-tool.h"
1112
#include "git-compat-util.h"
1213
#include "run-command.h"
1314
#include "argv-array.h"
@@ -49,7 +50,7 @@ static int task_finished(int result,
4950
return 1;
5051
}
5152

52-
int cmd_main(int argc, const char **argv)
53+
int cmd__run_command(int argc, const char **argv)
5354
{
5455
struct child_process proc = CHILD_PROCESS_INIT;
5556
int jobs;

t/helper/test-tool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static struct test_cmd cmds[] = {
3030
{ "ref-store", cmd__ref_store },
3131
{ "regex", cmd__regex },
3232
{ "revision-walking", cmd__revision_walking },
33+
{ "run-command", cmd__run_command },
3334
{ "sha1", cmd__sha1 },
3435
};
3536

t/helper/test-tool.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ int cmd__read_cache(int argc, const char **argv);
2424
int cmd__ref_store(int argc, const char **argv);
2525
int cmd__regex(int argc, const char **argv);
2626
int cmd__revision_walking(int argc, const char **argv);
27+
int cmd__run_command(int argc, const char **argv);
2728
int cmd__sha1(int argc, const char **argv);
2829

2930
#endif

t/t0061-run-command.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ EOF
1414
>empty
1515

1616
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
1818
'
1919

2020
test_expect_success 'run_command can run a command' '
2121
cat hello-script >hello.sh &&
2222
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 &&
2424
2525
test_cmp hello-script actual &&
2626
test_cmp empty err
@@ -31,7 +31,7 @@ test_expect_success !MINGW 'run_command can run a script without a #! line' '
3131
cat hello-script
3232
EOF
3333
chmod +x hello &&
34-
test-run-command run-command ./hello >actual 2>err &&
34+
test-tool run-command run-command ./hello >actual 2>err &&
3535
3636
test_cmp hello-script actual &&
3737
test_cmp empty err
@@ -45,7 +45,7 @@ test_expect_success 'run_command does not try to execute a directory' '
4545
EOF
4646
4747
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 &&
4949
test_cmp bin2/greet actual &&
5050
test_cmp empty err
5151
'
@@ -62,15 +62,15 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' '
6262
EOF
6363
6464
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 &&
6666
test_cmp bin2/greet actual &&
6767
test_cmp empty err
6868
'
6969

7070
test_expect_success POSIXPERM 'run_command reports EACCES' '
7171
cat hello-script >hello.sh &&
7272
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 &&
7474
7575
grep "fatal: cannot exec.*hello.sh" err
7676
'
@@ -104,17 +104,17 @@ World
104104
EOF
105105

106106
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 &&
108108
test_cmp expect actual
109109
'
110110

111111
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 &&
113113
test_cmp expect actual
114114
'
115115

116116
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 &&
118118
test_cmp expect actual
119119
'
120120

@@ -128,7 +128,7 @@ asking for a quick stop
128128
EOF
129129

130130
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 &&
132132
test_cmp expect actual
133133
'
134134

@@ -137,14 +137,14 @@ no further jobs available
137137
EOF
138138

139139
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 &&
141141
test_cmp expect actual
142142
'
143143

144144
test_trace () {
145145
expect="$1"
146146
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 | \
148148
sed 's/.* run_command: //' >actual &&
149149
echo "$expect true" >expect &&
150150
test_cmp expect actual

0 commit comments

Comments
 (0)