t/helper: merge test-dump-cache-tree 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>
maint
Nguyễn Thái Ngọc Duy 2018-03-24 08:44:39 +01:00 committed by Junio C Hamano
parent 1c854745bd
commit 06ccb29e8b
6 changed files with 9 additions and 6 deletions

View File

@ -658,10 +658,10 @@ TEST_BUILTINS_OBJS += test-ctype.o
TEST_BUILTINS_OBJS += test-date.o TEST_BUILTINS_OBJS += test-date.o
TEST_BUILTINS_OBJS += test-delta.o TEST_BUILTINS_OBJS += test-delta.o
TEST_BUILTINS_OBJS += test-drop-caches.o TEST_BUILTINS_OBJS += test-drop-caches.o
TEST_BUILTINS_OBJS += test-dump-cache-tree.o
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
TEST_BUILTINS_OBJS += test-sha1.o TEST_BUILTINS_OBJS += test-sha1.o


TEST_PROGRAMS_NEED_X += test-dump-cache-tree
TEST_PROGRAMS_NEED_X += test-dump-fsmonitor TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
TEST_PROGRAMS_NEED_X += test-dump-split-index TEST_PROGRAMS_NEED_X += test-dump-split-index
TEST_PROGRAMS_NEED_X += test-dump-untracked-cache TEST_PROGRAMS_NEED_X += test-dump-untracked-cache

View File

@ -1,3 +1,4 @@
#include "test-tool.h"
#include "cache.h" #include "cache.h"
#include "tree.h" #include "tree.h"
#include "cache-tree.h" #include "cache-tree.h"
@ -54,7 +55,7 @@ static int dump_cache_tree(struct cache_tree *it,
return errs; return errs;
} }


int cmd_main(int ac, const char **av) int cmd__dump_cache_tree(int ac, const char **av)
{ {
struct index_state istate; struct index_state istate;
struct cache_tree *another = cache_tree(); struct cache_tree *another = cache_tree();

View File

@ -13,6 +13,7 @@ static struct test_cmd cmds[] = {
{ "date", cmd__date }, { "date", cmd__date },
{ "delta", cmd__delta }, { "delta", cmd__delta },
{ "drop-caches", cmd__drop_caches }, { "drop-caches", cmd__drop_caches },
{ "dump-cache-tree", cmd__dump_cache_tree },
{ "lazy-init-name-hash", cmd__lazy_init_name_hash }, { "lazy-init-name-hash", cmd__lazy_init_name_hash },
{ "sha1", cmd__sha1 }, { "sha1", cmd__sha1 },
}; };

View File

@ -7,6 +7,7 @@ int cmd__ctype(int argc, const char **argv);
int cmd__date(int argc, const char **argv); int cmd__date(int argc, const char **argv);
int cmd__delta(int argc, const char **argv); int cmd__delta(int argc, const char **argv);
int cmd__drop_caches(int argc, const char **argv); int cmd__drop_caches(int argc, const char **argv);
int cmd__dump_cache_tree(int argc, const char **argv);
int cmd__lazy_init_name_hash(int argc, const char **argv); int cmd__lazy_init_name_hash(int argc, const char **argv);
int cmd__sha1(int argc, const char **argv); int cmd__sha1(int argc, const char **argv);



View File

@ -8,13 +8,13 @@ cache-tree extension.
. ./test-lib.sh . ./test-lib.sh


cmp_cache_tree () { cmp_cache_tree () {
test-dump-cache-tree | sed -e '/#(ref)/d' >actual && test-tool dump-cache-tree | sed -e '/#(ref)/d' >actual &&
sed "s/$_x40/SHA/" <actual >filtered && sed "s/$_x40/SHA/" <actual >filtered &&
test_cmp "$1" filtered test_cmp "$1" filtered
} }


# We don't bother with actually checking the SHA1: # We don't bother with actually checking the SHA1:
# test-dump-cache-tree already verifies that all existing data is # test-tool dump-cache-tree already verifies that all existing data is
# correct. # correct.
generate_expected_cache_tree_rec () { generate_expected_cache_tree_rec () {
dir="$1${1:+/}" && dir="$1${1:+/}" &&
@ -47,7 +47,7 @@ test_cache_tree () {


test_invalid_cache_tree () { test_invalid_cache_tree () {
printf "invalid %s ()\n" "" "$@" >expect && printf "invalid %s ()\n" "" "$@" >expect &&
test-dump-cache-tree | test-tool dump-cache-tree |
sed -n -e "s/[0-9]* subtrees//" -e '/#(ref)/d' -e '/^invalid /p' >actual && sed -n -e "s/[0-9]* subtrees//" -e '/#(ref)/d' -e '/^invalid /p' >actual &&
test_cmp expect actual test_cmp expect actual
} }

View File

@ -435,7 +435,7 @@ test_expect_success 'writing split index with null sha1 does not write cache tre
commit=$(git commit-tree $tree -p HEAD <msg) && commit=$(git commit-tree $tree -p HEAD <msg) &&
git update-ref HEAD "$commit" && git update-ref HEAD "$commit" &&
GIT_ALLOW_NULL_SHA1=1 git reset --hard && GIT_ALLOW_NULL_SHA1=1 git reset --hard &&
(test-dump-cache-tree >cache-tree.out || true) && (test-tool dump-cache-tree >cache-tree.out || true) &&
test_line_count = 0 cache-tree.out test_line_count = 0 cache-tree.out
' '