зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
64eb82fea8
Коммит
0e2678af4c
2
Makefile
2
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
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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 },
|
||||
};
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
)
|
||||
'
|
||||
|
|
|
@ -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 &&
|
||||
test_expect_code 2 test-config configset_get_value foo.bar non-existent-file 2>actual &&
|
||||
test_expect_code 2 test-tool config configset_get_value foo.bar non-existent-file 2>actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'proper error on directory "files"' '
|
||||
echo "Error (-1) reading configuration file a-directory." >expect &&
|
||||
mkdir a-directory &&
|
||||
test_expect_code 2 test-config configset_get_value foo.bar a-directory 2>output &&
|
||||
test_expect_code 2 test-tool config configset_get_value foo.bar a-directory 2>output &&
|
||||
grep "^warning:" output &&
|
||||
grep "^Error" output >actual &&
|
||||
test_cmp expect actual
|
||||
|
@ -196,7 +196,7 @@ test_expect_success POSIXPERM,SANITY 'proper error on non-accessible files' '
|
|||
chmod -r .git/config &&
|
||||
test_when_finished "chmod +r .git/config" &&
|
||||
echo "Error (-1) reading configuration file .git/config." >expect &&
|
||||
test_expect_code 2 test-config configset_get_value foo.bar .git/config 2>output &&
|
||||
test_expect_code 2 test-tool config configset_get_value foo.bar .git/config 2>output &&
|
||||
grep "^warning:" output &&
|
||||
grep "^Error" output >actual &&
|
||||
test_cmp expect actual
|
||||
|
@ -207,14 +207,14 @@ test_expect_success 'proper error on error in default config files' '
|
|||
test_when_finished "mv .git/config.old .git/config" &&
|
||||
echo "[" >>.git/config &&
|
||||
echo "fatal: bad config line 34 in file .git/config" >expect &&
|
||||
test_expect_code 128 test-config get_value foo.bar 2>actual &&
|
||||
test_expect_code 128 test-tool config get_value foo.bar 2>actual &&
|
||||
test_i18ncmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'proper error on error in custom config files' '
|
||||
echo "[" >>syntax-error &&
|
||||
echo "fatal: bad config line 1 in file syntax-error" >expect &&
|
||||
test_expect_code 128 test-config configset_get_value foo.bar syntax-error 2>actual &&
|
||||
test_expect_code 128 test-tool config configset_get_value foo.bar syntax-error 2>actual &&
|
||||
test_i18ncmp expect actual
|
||||
'
|
||||
|
||||
|
@ -267,7 +267,7 @@ test_expect_success 'iteration shows correct origins' '
|
|||
name=
|
||||
scope=cmdline
|
||||
EOF
|
||||
GIT_CONFIG_PARAMETERS=$cmdline_config test-config iterate >actual &&
|
||||
GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config iterate >actual &&
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ test_description='Test read_early_config()'
|
|||
|
||||
test_expect_success 'read early config' '
|
||||
test_config early.config correct &&
|
||||
test-config read_early_config early.config >output &&
|
||||
test-tool config read_early_config early.config >output &&
|
||||
test correct = "$(cat output)"
|
||||
'
|
||||
|
||||
|
@ -15,7 +15,7 @@ test_expect_success 'in a sub-directory' '
|
|||
mkdir -p sub &&
|
||||
(
|
||||
cd sub &&
|
||||
test-config read_early_config early.config
|
||||
test-tool config read_early_config early.config
|
||||
) >output &&
|
||||
test sub = "$(cat output)"
|
||||
'
|
||||
|
@ -27,7 +27,7 @@ test_expect_success 'ceiling' '
|
|||
GIT_CEILING_DIRECTORIES="$PWD" &&
|
||||
export GIT_CEILING_DIRECTORIES &&
|
||||
cd sub &&
|
||||
test-config read_early_config early.config
|
||||
test-tool config read_early_config early.config
|
||||
) >output &&
|
||||
test -z "$(cat output)"
|
||||
'
|
||||
|
@ -42,7 +42,7 @@ test_expect_success 'ceiling #2' '
|
|||
GIT_CEILING_DIRECTORIES="$PWD" &&
|
||||
export GIT_CEILING_DIRECTORIES XDG_CONFIG_HOME &&
|
||||
cd sub &&
|
||||
test-config read_early_config early.config
|
||||
test-tool config read_early_config early.config
|
||||
) >output &&
|
||||
test xdg = "$(cat output)"
|
||||
'
|
||||
|
@ -54,7 +54,7 @@ test_expect_success 'read config file in right order' '
|
|||
(
|
||||
cd foo &&
|
||||
echo "[test]source = repo" >>.git/config &&
|
||||
GIT_CONFIG_PARAMETERS=$cmdline_config test-config \
|
||||
GIT_CONFIG_PARAMETERS=$cmdline_config test-tool config \
|
||||
read_early_config test.source >actual &&
|
||||
cat >expected <<-\EOF &&
|
||||
home
|
||||
|
@ -71,7 +71,7 @@ test_with_config () {
|
|||
(
|
||||
cd throwaway &&
|
||||
echo "$*" >.git/config &&
|
||||
test-config read_early_config early.config
|
||||
test-tool config read_early_config early.config
|
||||
)
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче