[PATCH v2 05/36] t/helper: merge test-config into test-tool

2018-03-24 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 Makefile  |  2 +-
 t/helper/test-config.c|  5 +++--
 t/helper/test-tool.c  |  1 +
 t/helper/test-tool.h  |  1 +
 t/t1305-config-include.sh |  2 +-
 t/t1308-config-set.sh | 22 +++---
 t/t1309-early-config.sh   | 12 ++--
 7 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/Makefile b/Makefile
index 31287cedf2..227f16ad17 100644
--- a/Makefile
+++ b/Makefile
@@ -653,11 +653,11 @@ X =
 PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
 
 TEST_BUILTINS_OBJS += test-chmtime.o
+TEST_BUILTINS_OBJS += test-config.o
 TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
 TEST_BUILTINS_OBJS += test-sha1.o
 
 TEST_PROGRAMS_NEED_X += test-ctype
-TEST_PROGRAMS_NEED_X += test-config
 TEST_PROGRAMS_NEED_X += test-date
 TEST_PROGRAMS_NEED_X += test-delta
 TEST_PROGRAMS_NEED_X += test-drop-caches
diff --git a/t/helper/test-config.c b/t/helper/test-config.c
index 1a7b8bd3d6..214003d5b2 100644
--- a/t/helper/test-config.c
+++ b/t/helper/test-config.c
@@ -1,3 +1,4 @@
+#include "test-tool.h"
 #include "cache.h"
 #include "config.h"
 #include "string-list.h"
@@ -32,7 +33,7 @@
  * Examples:
  *
  * To print the value with highest priority for key "foo.bAr Baz.rock":
- * test-config get_value "foo.bAr Baz.rock"
+ * test-tool config get_value "foo.bAr Baz.rock"
  *
  */
 
@@ -77,7 +78,7 @@ static int early_config_cb(const char *var, const char 
*value, void *vdata)
return 0;
 }
 
-int cmd_main(int argc, const char **argv)
+int cmd__config(int argc, const char **argv)
 {
int i, val;
const char *v;
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index afc7a518d6..e8d6c6b9eb 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -8,6 +8,7 @@ struct test_cmd {
 
 static struct test_cmd cmds[] = {
{ "chmtime", cmd__chmtime },
+   { "config", cmd__config },
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
{ "sha1", cmd__sha1 },
 };
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index 1dc4673c3a..3084f458a0 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -2,6 +2,7 @@
 #define __TEST_TOOL_H__
 
 int cmd__chmtime(int argc, const char **argv);
+int cmd__config(int argc, const char **argv);
 int cmd__lazy_init_name_hash(int argc, const char **argv);
 int cmd__sha1(int argc, const char **argv);
 
diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
index d9d2f545a4..f035ee40a3 100755
--- a/t/t1305-config-include.sh
+++ b/t/t1305-config-include.sh
@@ -224,7 +224,7 @@ test_expect_success 'conditional include, early config 
reading' '
echo "[includeIf \"gitdir:foo/\"]path=bar6" >>.git/config &&
echo "[test]six=6" >.git/bar6 &&
echo 6 >expect &&
-   test-config read_early_config test.six >actual &&
+   test-tool config read_early_config test.six >actual &&
test_cmp expect actual
)
 '
diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh
index bafed5c9b8..3e00d1af01 100755
--- a/t/t1308-config-set.sh
+++ b/t/t1308-config-set.sh
@@ -18,7 +18,7 @@ check_config () {
then
printf "%s\n" "$@"
fi >expect &&
-   test_expect_code $expect_code test-config "$op" "$key" >actual &&
+   test_expect_code $expect_code test-tool config "$op" "$key" >actual &&
test_cmp expect actual
 }
 
@@ -125,7 +125,7 @@ test_expect_success 'find string value for a key' '
 '
 
 test_expect_success 'check line error when NULL string is queried' '
-   test_expect_code 128 test-config get_string case.foo 2>result &&
+   test_expect_code 128 test-tool config get_string case.foo 2>result &&
test_i18ngrep "fatal: .*case\.foo.*\.git/config.*line 7" result
 '
 
@@ -155,13 +155,13 @@ test_expect_success 'find value from a configset' '
baz = ball
EOF
echo silk >expect &&
-   test-config configset_get_value my.new config2 .git/config >actual &&
+   test-tool config configset_get_value my.new config2 .git/config >actual 
&&
test_cmp expect actual
 '
 
 test_expect_success 'find value with highest priority from a configset' '
echo hask >expect &&
-   test-config configset_get_value case.baz config2 .git/config >actual &&
+   test-tool config configset_get_value case.baz config2 .git/config 
>actual &&
test_cmp expect actual
 '
 
@@ -173,20 +173,20 @@ test_expect_success 'find value_list for a key from a 
configset' '
lama
ball
EOF
-   test-config configset_get_value case.baz config2 .git/config >actual &&
+   test-tool config configset_get_value case.baz config2 .git/config 
>actual &&
test_cmp expect actual
 '
 
 test_expect_success 'proper error on non-existent files' '
echo "Error (-1) reading configuration file non-existent-file." >expect 
&&
-   

[PATCH v2 05/36] t/helper: merge test-config into test-tool

2018-03-24 Thread Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy 
---
 Makefile  |  2 +-
 t/helper/test-config.c|  5 +++--
 t/helper/test-tool.c  |  1 +
 t/helper/test-tool.h  |  1 +
 t/t1305-config-include.sh |  2 +-
 t/t1308-config-set.sh | 22 +++---
 t/t1309-early-config.sh   | 12 ++--
 7 files changed, 24 insertions(+), 21 deletions(-)

diff --git a/Makefile b/Makefile
index 31287cedf2..227f16ad17 100644
--- a/Makefile
+++ b/Makefile
@@ -653,11 +653,11 @@ X =
 PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
 
 TEST_BUILTINS_OBJS += test-chmtime.o
+TEST_BUILTINS_OBJS += test-config.o
 TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
 TEST_BUILTINS_OBJS += test-sha1.o
 
 TEST_PROGRAMS_NEED_X += test-ctype
-TEST_PROGRAMS_NEED_X += test-config
 TEST_PROGRAMS_NEED_X += test-date
 TEST_PROGRAMS_NEED_X += test-delta
 TEST_PROGRAMS_NEED_X += test-drop-caches
diff --git a/t/helper/test-config.c b/t/helper/test-config.c
index 1a7b8bd3d6..214003d5b2 100644
--- a/t/helper/test-config.c
+++ b/t/helper/test-config.c
@@ -1,3 +1,4 @@
+#include "test-tool.h"
 #include "cache.h"
 #include "config.h"
 #include "string-list.h"
@@ -32,7 +33,7 @@
  * Examples:
  *
  * To print the value with highest priority for key "foo.bAr Baz.rock":
- * test-config get_value "foo.bAr Baz.rock"
+ * test-tool config get_value "foo.bAr Baz.rock"
  *
  */
 
@@ -77,7 +78,7 @@ static int early_config_cb(const char *var, const char 
*value, void *vdata)
return 0;
 }
 
-int cmd_main(int argc, const char **argv)
+int cmd__config(int argc, const char **argv)
 {
int i, val;
const char *v;
diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c
index afc7a518d6..e8d6c6b9eb 100644
--- a/t/helper/test-tool.c
+++ b/t/helper/test-tool.c
@@ -8,6 +8,7 @@ struct test_cmd {
 
 static struct test_cmd cmds[] = {
{ "chmtime", cmd__chmtime },
+   { "config", cmd__config },
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
{ "sha1", cmd__sha1 },
 };
diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h
index 1dc4673c3a..3084f458a0 100644
--- a/t/helper/test-tool.h
+++ b/t/helper/test-tool.h
@@ -2,6 +2,7 @@
 #define __TEST_TOOL_H__
 
 int cmd__chmtime(int argc, const char **argv);
+int cmd__config(int argc, const char **argv);
 int cmd__lazy_init_name_hash(int argc, const char **argv);
 int cmd__sha1(int argc, const char **argv);
 
diff --git a/t/t1305-config-include.sh b/t/t1305-config-include.sh
index d9d2f545a4..f035ee40a3 100755
--- a/t/t1305-config-include.sh
+++ b/t/t1305-config-include.sh
@@ -224,7 +224,7 @@ test_expect_success 'conditional include, early config 
reading' '
echo "[includeIf \"gitdir:foo/\"]path=bar6" >>.git/config &&
echo "[test]six=6" >.git/bar6 &&
echo 6 >expect &&
-   test-config read_early_config test.six >actual &&
+   test-tool config read_early_config test.six >actual &&
test_cmp expect actual
)
 '
diff --git a/t/t1308-config-set.sh b/t/t1308-config-set.sh
index bafed5c9b8..3e00d1af01 100755
--- a/t/t1308-config-set.sh
+++ b/t/t1308-config-set.sh
@@ -18,7 +18,7 @@ check_config () {
then
printf "%s\n" "$@"
fi >expect &&
-   test_expect_code $expect_code test-config "$op" "$key" >actual &&
+   test_expect_code $expect_code test-tool config "$op" "$key" >actual &&
test_cmp expect actual
 }
 
@@ -125,7 +125,7 @@ test_expect_success 'find string value for a key' '
 '
 
 test_expect_success 'check line error when NULL string is queried' '
-   test_expect_code 128 test-config get_string case.foo 2>result &&
+   test_expect_code 128 test-tool config get_string case.foo 2>result &&
test_i18ngrep "fatal: .*case\.foo.*\.git/config.*line 7" result
 '
 
@@ -155,13 +155,13 @@ test_expect_success 'find value from a configset' '
baz = ball
EOF
echo silk >expect &&
-   test-config configset_get_value my.new config2 .git/config >actual &&
+   test-tool config configset_get_value my.new config2 .git/config >actual 
&&
test_cmp expect actual
 '
 
 test_expect_success 'find value with highest priority from a configset' '
echo hask >expect &&
-   test-config configset_get_value case.baz config2 .git/config >actual &&
+   test-tool config configset_get_value case.baz config2 .git/config 
>actual &&
test_cmp expect actual
 '
 
@@ -173,20 +173,20 @@ test_expect_success 'find value_list for a key from a 
configset' '
lama
ball
EOF
-   test-config configset_get_value case.baz config2 .git/config >actual &&
+   test-tool config configset_get_value case.baz config2 .git/config 
>actual &&
test_cmp expect actual
 '
 
 test_expect_success 'proper error on non-existent files' '
echo "Error (-1) reading configuration file non-existent-file." >expect 
&&
-