Subject: [PATCH v2 32/36] t/helper: merge test-submodule-config into test-tool

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

Signed-off-by: Nguyễn Thái Ngọc Duy <[email-masked]>
---
 Makefile                         |  2 +-
 t/helper/test-submodule-config.c |  3 ++-
 t/helper/test-tool.c             |  1 +
 t/helper/test-tool.h             |  1 +
 t/t7411-submodule-config.sh      | 18 +++++++++---------
 5 files changed, 14 insertions(+), 11 deletions(-)

diff --git a/Makefile b/Makefile
index 6819792c2b..c1dc9ff8d6 100644
--- a/Makefile
+++ b/Makefile
@@ -682,6 +682,7 @@ TEST_BUILTINS_OBJS += test-sha1.o
 TEST_BUILTINS_OBJS += test-sigchain.o
 TEST_BUILTINS_OBJS += test-strcmp-offset.o
 TEST_BUILTINS_OBJS += test-string-list.o
+TEST_BUILTINS_OBJS += test-submodule-config.o
 
 TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
 TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
@@ -689,7 +690,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-submodule-config
 TEST_PROGRAMS_NEED_X += test-subprocess
 TEST_PROGRAMS_NEED_X += test-svn-fe
 TEST_PROGRAMS_NEED_X += test-tool
diff --git a/t/helper/test-submodule-config.c b/t/helper/test-submodule-config.c
index f23db3b19a..5c6e4b010d 100644
--- a/t/helper/test-submodule-config.c
+++ b/t/helper/test-submodule-config.c
@@ -1,3 +1,4 @@
+#include "test-tool.h"
 #include "cache.h"
 #include "config.h"
 #include "submodule-config.h"
@@ -10,7 +11,7 @@ static void die_usage(int argc, const char **argv, const char *msg)
 	exit(1);
 }
 
-int cmd_main(int argc, const char **argv)
+int cmd__submodule_config(int argc, const char **argv)
 {
 	const char **arg = argv;
 	int my_argc = argc;
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index 90008533cd..434fedc8d8 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -37,6 +37,7 @@ static struct test_cmd cmds[] = {
 	{ "sigchain", cmd__sigchain },
 	{ "strcmp-offset", cmd__strcmp_offset },
 	{ "string-list", cmd__string_list },
+	{ "submodule-config", cmd__submodule_config },
 };
 
 int cmd_main(int argc, const char **argv)
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index 19ad2b0df8..be7e79738f 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -31,5 +31,6 @@ int cmd__sha1(int argc, const char **argv);
 int cmd__sigchain(int argc, const char **argv);
 int cmd__strcmp_offset(int argc, const char **argv);
 int cmd__string_list(int argc, const char **argv);
+int cmd__submodule_config(int argc, const char **argv);
 
 #endif
diff --git a/t/t7411-submodule-config.sh b/t/t7411-submodule-config.sh
index 46c09c7765..0bde5850ac 100755
--- a/t/t7411-submodule-config.sh
+++ b/t/t7411-submodule-config.sh
@@ -41,7 +41,7 @@ test_expect_success 'configuration parsing with error' '
 	EOF
 	(
 		cd repo &&
-		test_must_fail test-submodule-config "" s 2>actual &&
+		test_must_fail test-tool submodule-config "" s 2>actual &&
 		test_i18ngrep "bad config" actual
 	)
 '
@@ -55,7 +55,7 @@ EOF
 
 test_expect_success 'test parsing and lookup of submodule config by path' '
 	(cd super &&
-		test-submodule-config \
+		test-tool submodule-config \
 			HEAD^ a \
 			HEAD b \
 			HEAD^ submodule \
@@ -67,7 +67,7 @@ test_expect_success 'test parsing and lookup of submodule config by path' '
 
 test_expect_success 'test parsing and lookup of submodule config by name' '
 	(cd super &&
-		test-submodule-config --name \
+		test-tool submodule-config --name \
 			HEAD^ a \
 			HEAD a \
 			HEAD^ submodule \
@@ -89,7 +89,7 @@ test_expect_success 'error in one submodule config lets continue' '
 		git add .gitmodules &&
 		mv .gitmodules.bak .gitmodules &&
 		git commit -m "add error" &&
-		test-submodule-config \
+		test-tool submodule-config \
 			HEAD b \
 			HEAD submodule \
 				>actual &&
@@ -100,7 +100,7 @@ test_expect_success 'error in one submodule config lets continue' '
 test_expect_success 'error message contains blob reference' '
 	(cd super &&
 		sha1=$(git rev-parse HEAD) &&
-		test-submodule-config \
+		test-tool submodule-config \
 			HEAD b \
 			HEAD submodule \
 				2>actual_err &&
@@ -114,9 +114,9 @@ test_expect_success 'using different treeishs works' '
 		git tag new_tag &&
 		tree=$(git rev-parse HEAD^{tree}) &&
 		commit=$(git rev-parse HEAD^{commit}) &&
-		test-submodule-config $commit b >expect &&
-		test-submodule-config $tree b >actual.1 &&
-		test-submodule-config new_tag b >actual.2 &&
+		test-tool submodule-config $commit b >expect &&
+		test-tool submodule-config $tree b >actual.1 &&
+		test-tool submodule-config new_tag b >actual.2 &&
 		test_cmp expect actual.1 &&
 		test_cmp expect actual.2
 	)
@@ -130,7 +130,7 @@ test_expect_success 'error in history in fetchrecursesubmodule lets continue' '
 		git config --unset -f .gitmodules \
 			submodule.submodule.fetchrecursesubmodules &&
 		git commit -m "add error in fetchrecursesubmodules" &&
-		test-submodule-config \
+		test-tool submodule-config \
 			HEAD b \
 			HEAD submodule \
 				>actual &&
-- 
2.17.0.rc0.348.gd5a49e0b6f