Subject: [PATCH 29/36] t/helper: merge test-sigchain into test-tool

From: Nguyễn Thái Ngọc Duy <[email-masked]>
Date: Sat, 17 Mar 2018 08:54:14 +0100

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 Makefile                 | 2 +-
 t/helper/test-sigchain.c | 3 ++-
 t/helper/test-tool.c     | 1 +
 t/helper/test-tool.h     | 1 +
 t/t0005-signals.sh       | 4 ++--
 5 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/Makefile b/Makefile
index b50a0818a9..51de8882d0 100644
--- a/Makefile
+++ b/Makefile
@@ -679,6 +679,7 @@ TEST_BUILTINS_OBJS += test-run-command.o
 TEST_BUILTINS_OBJS += test-scrap-cache-tree.o
 TEST_BUILTINS_OBJS += test-sha1-array.o
 TEST_BUILTINS_OBJS += test-sha1.o
+TEST_BUILTINS_OBJS += test-sigchain.o
 
 TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
 TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
@@ -686,7 +687,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-sigchain
 TEST_PROGRAMS_NEED_X += test-strcmp-offset
 TEST_PROGRAMS_NEED_X += test-string-list
 TEST_PROGRAMS_NEED_X += test-submodule-config
diff --git a/t/helper/test-sigchain.c b/t/helper/test-sigchain.c
index b71edbd442..0cfbf9e0af 100644
--- a/t/helper/test-sigchain.c
+++ b/t/helper/test-sigchain.c
@@ -1,3 +1,4 @@
+#include "test-tool.h"
 #include "cache.h"
 #include "sigchain.h"
 
@@ -13,7 +14,7 @@ X(two)
 X(three)
 #undef X
 
-int cmd_main(int argc, const char **argv) {
+int test_sigchain(int argc, const char **argv) {
 	sigchain_push(SIGTERM, one);
 	sigchain_push(SIGTERM, two);
 	sigchain_push(SIGTERM, three);
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index 54d62b8b32..99db507a24 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -34,6 +34,7 @@ static struct test_cmd cmds[] = {
 	{ "scrap-cache-tree", test_scrap_cache_tree },
 	{ "sha1-array", test_sha1_array },
 	{ "sha1", test_sha1 },
+	{ "sigchain", test_sigchain },
 };
 
 int cmd_main(int argc, const char **argv)
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index 10d1322e0d..4c71df8c79 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -28,5 +28,6 @@ int test_run_command(int argc, const char **argv);
 int test_scrap_cache_tree(int argc, const char **argv);
 int test_sha1_array(int argc, const char **argv);
 int test_sha1(int argc, const char **argv);
+int test_sigchain(int argc, const char **argv);
 
 #endif
diff --git a/t/t0005-signals.sh b/t/t0005-signals.sh
index c16947cf5d..4c214bd11c 100755
--- a/t/t0005-signals.sh
+++ b/t/t0005-signals.sh
@@ -10,7 +10,7 @@ one
 EOF
 
 test_expect_success 'sigchain works' '
-	{ test-sigchain >actual; ret=$?; } &&
+	{ test-tool sigchain >actual; ret=$?; } &&
 	{
 		# Signal death by raise() on Windows acts like exit(3),
 		# regardless of the signal number. So we must allow that
@@ -24,7 +24,7 @@ test_expect_success 'sigchain works' '
 test_expect_success !MINGW 'signals are propagated using shell convention' '
 	# we use exec here to avoid any sub-shell interpretation
 	# of the exit code
-	git config alias.sigterm "!exec test-sigchain" &&
+	git config alias.sigterm "!exec test-tool sigchain" &&
 	test_expect_code 143 git sigterm
 '
 
-- 
2.16.2.903.gd04caf5039