diff --git a/Makefile b/Makefile index 3ed461cd55..adece67b8e 100644 --- a/Makefile +++ b/Makefile @@ -675,6 +675,7 @@ TEST_BUILTINS_OBJS += test-read-cache.o TEST_BUILTINS_OBJS += test-ref-store.o TEST_BUILTINS_OBJS += test-regex.o TEST_BUILTINS_OBJS += test-revision-walking.o +TEST_BUILTINS_OBJS += test-run-command.o TEST_BUILTINS_OBJS += test-sha1.o TEST_PROGRAMS_NEED_X += test-dump-fsmonitor @@ -683,7 +684,6 @@ TEST_PROGRAMS_NEED_X += test-fake-ssh TEST_PROGRAMS_NEED_X += test-line-buffer TEST_PROGRAMS_NEED_X += test-parse-options TEST_PROGRAMS_NEED_X += test-write-cache -TEST_PROGRAMS_NEED_X += test-run-command TEST_PROGRAMS_NEED_X += test-scrap-cache-tree TEST_PROGRAMS_NEED_X += test-sha1-array TEST_PROGRAMS_NEED_X += test-sigchain diff --git a/t/helper/test-run-command.c b/t/helper/test-run-command.c index 153342e44d..2cc93bb69c 100644 --- a/t/helper/test-run-command.c +++ b/t/helper/test-run-command.c @@ -8,6 +8,7 @@ * published by the Free Software Foundation. */ +#include "test-tool.h" #include "git-compat-util.h" #include "run-command.h" #include "argv-array.h" @@ -49,7 +50,7 @@ static int task_finished(int result, return 1; } -int cmd_main(int argc, const char **argv) +int cmd__run_command(int argc, const char **argv) { struct child_process proc = CHILD_PROCESS_INIT; int jobs; diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index 7da5fb4d83..54bdee04b9 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -30,6 +30,7 @@ static struct test_cmd cmds[] = { { "ref-store", cmd__ref_store }, { "regex", cmd__regex }, { "revision-walking", cmd__revision_walking }, + { "run-command", cmd__run_command }, { "sha1", cmd__sha1 }, }; diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index 4dff220646..0fe2dd640b 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -24,6 +24,7 @@ int cmd__read_cache(int argc, const char **argv); int cmd__ref_store(int argc, const char **argv); int cmd__regex(int argc, const char **argv); int cmd__revision_walking(int argc, const char **argv); +int cmd__run_command(int argc, const char **argv); int cmd__sha1(int argc, const char **argv); #endif diff --git a/t/t0061-run-command.sh b/t/t0061-run-command.sh index 24c92b6cd7..d03149be9f 100755 --- a/t/t0061-run-command.sh +++ b/t/t0061-run-command.sh @@ -14,13 +14,13 @@ EOF >empty test_expect_success 'start_command reports ENOENT' ' - test-run-command start-command-ENOENT ./does-not-exist + test-tool 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-tool run-command run-command ./hello.sh >actual 2>err && test_cmp hello-script actual && test_cmp empty err @@ -31,7 +31,7 @@ test_expect_success !MINGW 'run_command can run a script without a #! line' ' cat hello-script EOF chmod +x hello && - test-run-command run-command ./hello >actual 2>err && + test-tool run-command run-command ./hello >actual 2>err && test_cmp hello-script actual && test_cmp empty err @@ -45,7 +45,7 @@ test_expect_success 'run_command does not try to execute a directory' ' EOF PATH=$PWD/bin1:$PWD/bin2:$PATH \ - test-run-command run-command greet >actual 2>err && + test-tool run-command run-command greet >actual 2>err && test_cmp bin2/greet actual && test_cmp empty err ' @@ -62,7 +62,7 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' ' EOF PATH=$PWD/bin1:$PWD/bin2:$PATH \ - test-run-command run-command greet >actual 2>err && + test-tool run-command run-command greet >actual 2>err && test_cmp bin2/greet actual && test_cmp empty err ' @@ -70,7 +70,7 @@ test_expect_success POSIXPERM 'run_command passes over non-executable file' ' 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 && + test_must_fail test-tool run-command run-command ./hello.sh 2>err && grep "fatal: cannot exec.*hello.sh" err ' @@ -104,17 +104,17 @@ World EOF test_expect_success 'run_command runs in parallel with more jobs available than tasks' ' - test-run-command run-command-parallel 5 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && + test-tool run-command run-command-parallel 5 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && test_cmp expect actual ' test_expect_success 'run_command runs in parallel with as many jobs as tasks' ' - test-run-command run-command-parallel 4 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && + test-tool run-command run-command-parallel 4 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && test_cmp expect actual ' test_expect_success 'run_command runs in parallel with more tasks than jobs available' ' - test-run-command run-command-parallel 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && + test-tool run-command run-command-parallel 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && test_cmp expect actual ' @@ -128,7 +128,7 @@ asking for a quick stop EOF test_expect_success 'run_command is asked to abort gracefully' ' - test-run-command run-command-abort 3 false 2>actual && + test-tool run-command run-command-abort 3 false 2>actual && test_cmp expect actual ' @@ -137,14 +137,14 @@ no further jobs available EOF test_expect_success 'run_command outputs ' ' - test-run-command run-command-no-jobs 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && + test-tool run-command run-command-no-jobs 3 sh -c "printf \"%s\n%s\n\" Hello World" 2>actual && test_cmp expect actual ' test_trace () { expect="$1" shift - GIT_TRACE=1 test-run-command "$@" run-command true 2>&1 >/dev/null | \ + GIT_TRACE=1 test-tool run-command "$@" run-command true 2>&1 >/dev/null | \ sed 's/.* run_command: //' >actual && echo "$expect true" >expect && test_cmp expect actual