t/helper: merge test-config into test-tool
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Nguyễn Thái Ngọc Duy committed
Mar 24, 2018 at 08:44 UTC
0e2678af4c90f0cb28d04cb87f2a71ea2ec47f5d
7 files changed
+24
-21
Makefile
+1
-1
@@ -653,11 +653,11 @@ X =
653
PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
654
655
TEST_BUILTINS_OBJS += test-chmtime.o
656
+TEST_BUILTINS_OBJS += test-config.o
657
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
658
TEST_BUILTINS_OBJS += test-sha1.o
659
660
TEST_PROGRAMS_NEED_X += test-ctype
660
-TEST_PROGRAMS_NEED_X += test-config
661
TEST_PROGRAMS_NEED_X += test-date
662
TEST_PROGRAMS_NEED_X += test-delta
663
TEST_PROGRAMS_NEED_X += test-drop-caches
t/helper/test-config.c
+3
-2
@@ -1,3 +1,4 @@
1
+#include "test-tool.h"
2
#include "cache.h"
3
#include "config.h"
4
#include "string-list.h"
@@ -32,7 +33,7 @@
33
* Examples:
34
*
35
* To print the value with highest priority for key "foo.bAr Baz.rock":
35
- * test-config get_value "foo.bAr Baz.rock"
36
+ * test-tool config get_value "foo.bAr Baz.rock"
37
*
38
*/
39
@@ -77,7 +78,7 @@ static int early_config_cb(const char *var, const char *value, void *vdata)
78
return 0;
79
}
80
80
-int cmd_main(int argc, const char **argv)
81
+int cmd__config(int argc, const char **argv)
82
{
83
int i, val;
84
const char *v;
t/helper/test-tool.c
+1
@@ -8,6 +8,7 @@ struct test_cmd {
8
9
static struct test_cmd cmds[] = {
10
{ "chmtime", cmd__chmtime },
11
+ { "config", cmd__config },
12
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
13
{ "sha1", cmd__sha1 },
14
};
t/helper/test-tool.h
+1
@@ -2,6 +2,7 @@
2
#define __TEST_TOOL_H__
3
4
int cmd__chmtime(int argc, const char **argv);
5
+int cmd__config(int argc, const char **argv);
6
int cmd__lazy_init_name_hash(int argc, const char **argv);
7
int cmd__sha1(int argc, const char **argv);
8
t/t1305-config-include.sh
+1
-1
@@ -224,7 +224,7 @@ test_expect_success 'conditional include, early config reading' '
224
echo "[includeIf \"gitdir:foo/\"]path=bar6" >>.git/config &&
225
echo "[test]six=6" >.git/bar6 &&
226
echo 6 >expect &&
227
- test-config read_early_config test.six >actual &&
227
+ test-tool config read_early_config test.six >actual &&
228
test_cmp expect actual
229
)
230
'
t/t1308-config-set.sh
+11
-11
@@ -18,7 +18,7 @@ check_config () {
18
then
19
printf "%s\n" "$@"
20
fi >expect &&
21
- test_expect_code $expect_code test-config "$op" "$key" >actual &&
21
+ test_expect_code $expect_code test-tool config "$op" "$key" >actual &&
22
test_cmp expect actual
23
}
24
@@ -125,7 +125,7 @@ test_expect_success 'find string value for a key' '
125
'
126
127
test_expect_success 'check line error when NULL string is queried' '
128
- test_expect_code 128 test-config get_string case.foo 2>result &&
128
+ test_expect_code 128 test-tool config get_string case.foo 2>result &&
129
test_i18ngrep "fatal: .*case\.foo.*\.git/config.*line 7" result
130
'
131
@@ -155,13 +155,13 @@ test_expect_success 'find value from a configset' '
155
baz = ball
156
EOF
157
echo silk >expect &&
158
- test-config configset_get_value my.new config2 .git/config >actual &&
158
+ test-tool config configset_get_value my.new config2 .git/config >actual &&
159
test_cmp expect actual
160
'
161
162
test_expect_success 'find value with highest priority from a configset' '
163
echo hask >expect &&
164
- test-config configset_get_value case.baz config2 .git/config >actual &&
164
+ test-tool config configset_get_value case.baz config2 .git/config >actual &&
165
test_cmp expect actual
166
'
167
@@ -173,20 +173,20 @@ test_expect_success 'find value_list for a key from a configset' '
173
lama
174
ball
175
EOF
176
- test-config configset_get_value case.baz config2 .git/config >actual &&
176
+ test-tool config configset_get_value case.baz config2 .git/config >actual &&
177
test_cmp expect actual
178
'
179
180
test_expect_success 'proper error on non-existent files' '
181
echo "Error (-1) reading configuration file non-existent-file." >expect &&
182
- test_expect_code 2 test-config configset_get_value foo.bar non-existent-file 2>actual &&
182
+ test_expect_code 2 test-tool config configset_get_value foo.bar non-existent-file 2>actual &&
183
test_cmp expect actual
184
'
185
186
test_expect_success 'proper error on directory "files"' '
187
echo "Error (-1) reading configuration file a-directory." >expect &&
188
mkdir a-directory &&
189
- test_expect_code 2 test-config configset_get_value foo.bar a-directory 2>output &&
189
+ test_expect_code 2 test-tool config configset_get_value foo.bar a-directory 2>output &&
190
grep "^warning:" output &&
191
grep "^Error" output >actual &&
192
test_cmp expect actual
@@ -196,7 +196,7 @@ test_expect_success POSIXPERM,SANITY 'proper error on non-accessible files' '
196
chmod -r .git/config &&
197
test_when_finished "chmod +r .git/config" &&
198
echo "Error (-1) reading configuration file .git/config." >expect &&
199
- test_expect_code 2 test-config configset_get_value foo.bar .git/config 2>output &&
199
+ test_expect_code 2 test-tool config configset_get_value foo.bar .git/config 2>output &&
200
grep "^warning:" output &&
201
grep "^Error" output >actual &&
202
test_cmp expect actual
@@ -207,14 +207,14 @@ test_expect_success 'proper error on error in default config files' '
207
test_when_finished "mv .git/config.old .git/config" &&
208
echo "[" >>.git/config &&
209
echo "fatal: bad config line 34 in file .git/config" >expect &&
210
- test_expect_code 128 test-config get_value foo.bar 2>actual &&
210
+ test_expect_code 128 test-tool config get_value foo.bar 2>actual &&
211
test_i18ncmp expect actual
212
'
213
214
test_expect_success 'proper error on error in custom config files' '
215
echo "[" >>syntax-error &&
216
echo "fatal: bad config line 1 in file syntax-error" >expect &&
217
- test_expect_code 128 test-config configset_get_value foo.bar syntax-error 2>actual &&
217
+ test_expect_code 128 test-tool config configset_get_value foo.bar syntax-error 2>actual &&
218
test_i18ncmp expect actual
219
'
220
@@ -267,7 +267,7 @@ test_expect_success 'iteration shows correct origins' '
267
name=
268
scope=cmdline
269
EOF
270
- GIT_CONFIG_PARAMETERS=$cmdline_config test-config iterate >actual &&
270
+ GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config iterate >actual &&
271
test_cmp expect actual
272
'
273
t/t1309-early-config.sh
+6
-6
@@ -6,7 +6,7 @@ test_description='Test read_early_config()'
6
7
test_expect_success 'read early config' '
8
test_config early.config correct &&
9
- test-config read_early_config early.config >output &&
9
+ test-tool config read_early_config early.config >output &&
10
test correct = "$(cat output)"
11
'
12
@@ -15,7 +15,7 @@ test_expect_success 'in a sub-directory' '
15
mkdir -p sub &&
16
(
17
cd sub &&
18
- test-config read_early_config early.config
18
+ test-tool config read_early_config early.config
19
) >output &&
20
test sub = "$(cat output)"
21
'
@@ -27,7 +27,7 @@ test_expect_success 'ceiling' '
27
GIT_CEILING_DIRECTORIES="$PWD" &&
28
export GIT_CEILING_DIRECTORIES &&
29
cd sub &&
30
- test-config read_early_config early.config
30
+ test-tool config read_early_config early.config
31
) >output &&
32
test -z "$(cat output)"
33
'
@@ -42,7 +42,7 @@ test_expect_success 'ceiling #2' '
42
GIT_CEILING_DIRECTORIES="$PWD" &&
43
export GIT_CEILING_DIRECTORIES XDG_CONFIG_HOME &&
44
cd sub &&
45
- test-config read_early_config early.config
45
+ test-tool config read_early_config early.config
46
) >output &&
47
test xdg = "$(cat output)"
48
'
@@ -54,7 +54,7 @@ test_expect_success 'read config file in right order' '
54
(
55
cd foo &&
56
echo "[test]source = repo" >>.git/config &&
57
- GIT_CONFIG_PARAMETERS=$cmdline_config test-config \
57
+ GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config \
58
read_early_config test.source >actual &&
59
cat >expected <<-\EOF &&
60
home
@@ -71,7 +71,7 @@ test_with_config () {
71
(
72
cd throwaway &&
73
echo "$*" >.git/config &&
74
- test-config read_early_config early.config
74
+ test-tool config read_early_config early.config
75
)
76
}
77