t/helper: merge test-dump-untracked-cache 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 Sep 9, 2018 at 19:36 UTC cd780f0b6930d6bd337ad3dad4b014020b175c94
6 files changed +41 -38
Makefile
+1 -1
@@ -710,6 +710,7 @@ TEST_BUILTINS_OBJS += test-delta.o
710 TEST_BUILTINS_OBJS += test-drop-caches.o
711 TEST_BUILTINS_OBJS += test-dump-cache-tree.o
712 TEST_BUILTINS_OBJS += test-dump-split-index.o
713 +TEST_BUILTINS_OBJS += test-dump-untracked-cache.o
714 TEST_BUILTINS_OBJS += test-example-decorate.o
715 TEST_BUILTINS_OBJS += test-genrandom.o
716 TEST_BUILTINS_OBJS += test-hashmap.o
@@ -741,7 +742,6 @@ TEST_BUILTINS_OBJS += test-wildmatch.o
742 TEST_BUILTINS_OBJS += test-write-cache.o
743
744 TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
744 -TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
745 TEST_PROGRAMS_NEED_X += test-fake-ssh
746 TEST_PROGRAMS_NEED_X += test-line-buffer
747 TEST_PROGRAMS_NEED_X += test-parse-options
t/helper/test-dump-untracked-cache.c
+2 -1
@@ -1,3 +1,4 @@
1 +#include "test-tool.h"
2 #include "cache.h"
3 #include "dir.h"
4
@@ -38,7 +39,7 @@ static void dump(struct untracked_cache_dir *ucd, struct strbuf *base)
39 strbuf_setlen(base, len);
40 }
41
41 -int cmd_main(int ac, const char **av)
42 +int cmd__dump_untracked_cache(int ac, const char **av)
43 {
44 struct untracked_cache *uc;
45 struct strbuf base = STRBUF_INIT;
t/helper/test-tool.c
+1
@@ -15,6 +15,7 @@ static struct test_cmd cmds[] = {
15 { "drop-caches", cmd__drop_caches },
16 { "dump-cache-tree", cmd__dump_cache_tree },
17 { "dump-split-index", cmd__dump_split_index },
18 + { "dump-untracked-cache", cmd__dump_untracked_cache },
19 { "example-decorate", cmd__example_decorate },
20 { "genrandom", cmd__genrandom },
21 { "hashmap", cmd__hashmap },
t/helper/test-tool.h
+1
@@ -11,6 +11,7 @@ int cmd__delta(int argc, const char **argv);
11 int cmd__drop_caches(int argc, const char **argv);
12 int cmd__dump_cache_tree(int argc, const char **argv);
13 int cmd__dump_split_index(int argc, const char **argv);
14 +int cmd__dump_untracked_cache(int argc, const char **argv);
15 int cmd__example_decorate(int argc, const char **argv);
16 int cmd__genrandom(int argc, const char **argv);
17 int cmd__hashmap(int argc, const char **argv);
t/t7063-status-untracked-cache.sh
+34 -34
@@ -55,7 +55,7 @@ test_expect_success 'setup' '
55 '
56
57 test_expect_success 'untracked cache is empty' '
58 - test-dump-untracked-cache >../actual &&
58 + test-tool dump-untracked-cache >../actual &&
59 cat >../expect-empty <<EOF &&
60 info/exclude 0000000000000000000000000000000000000000
61 core.excludesfile 0000000000000000000000000000000000000000
@@ -106,7 +106,7 @@ EOF
106 '
107
108 test_expect_success 'untracked cache after first status' '
109 - test-dump-untracked-cache >../actual &&
109 + test-tool dump-untracked-cache >../actual &&
110 test_cmp ../dump.expect ../actual
111 '
112
@@ -126,7 +126,7 @@ EOF
126 '
127
128 test_expect_success 'untracked cache after second status' '
129 - test-dump-untracked-cache >../actual &&
129 + test-tool dump-untracked-cache >../actual &&
130 test_cmp ../dump.expect ../actual
131 '
132
@@ -157,7 +157,7 @@ EOF
157 '
158
159 test_expect_success 'verify untracked cache dump' '
160 - test-dump-untracked-cache >../actual &&
160 + test-tool dump-untracked-cache >../actual &&
161 cat >../expect <<EOF &&
162 info/exclude $EMPTY_BLOB
163 core.excludesfile 0000000000000000000000000000000000000000
@@ -204,7 +204,7 @@ EOF
204 '
205
206 test_expect_success 'verify untracked cache dump' '
207 - test-dump-untracked-cache >../actual &&
207 + test-tool dump-untracked-cache >../actual &&
208 cat >../expect <<EOF &&
209 info/exclude $EMPTY_BLOB
210 core.excludesfile 0000000000000000000000000000000000000000
@@ -248,7 +248,7 @@ EOF
248 '
249
250 test_expect_success 'verify untracked cache dump' '
251 - test-dump-untracked-cache >../actual &&
251 + test-tool dump-untracked-cache >../actual &&
252 cat >../expect <<EOF &&
253 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
254 core.excludesfile 0000000000000000000000000000000000000000
@@ -267,7 +267,7 @@ EOF
267
268 test_expect_success 'move two from tracked to untracked' '
269 git rm --cached two &&
270 - test-dump-untracked-cache >../actual &&
270 + test-tool dump-untracked-cache >../actual &&
271 cat >../expect <<EOF &&
272 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
273 core.excludesfile 0000000000000000000000000000000000000000
@@ -304,7 +304,7 @@ EOF
304 '
305
306 test_expect_success 'verify untracked cache dump' '
307 - test-dump-untracked-cache >../actual &&
307 + test-tool dump-untracked-cache >../actual &&
308 cat >../expect <<EOF &&
309 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
310 core.excludesfile 0000000000000000000000000000000000000000
@@ -324,7 +324,7 @@ EOF
324
325 test_expect_success 'move two from untracked to tracked' '
326 git add two &&
327 - test-dump-untracked-cache >../actual &&
327 + test-tool dump-untracked-cache >../actual &&
328 cat >../expect <<EOF &&
329 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
330 core.excludesfile 0000000000000000000000000000000000000000
@@ -361,7 +361,7 @@ EOF
361 '
362
363 test_expect_success 'verify untracked cache dump' '
364 - test-dump-untracked-cache >../actual &&
364 + test-tool dump-untracked-cache >../actual &&
365 cat >../expect <<EOF &&
366 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
367 core.excludesfile 0000000000000000000000000000000000000000
@@ -405,7 +405,7 @@ EOF
405 '
406
407 test_expect_success 'untracked cache correct after commit' '
408 - test-dump-untracked-cache >../actual &&
408 + test-tool dump-untracked-cache >../actual &&
409 cat >../expect <<EOF &&
410 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
411 core.excludesfile 0000000000000000000000000000000000000000
@@ -464,7 +464,7 @@ EOF
464 '
465
466 test_expect_success 'untracked cache correct after status' '
467 - test-dump-untracked-cache >../actual &&
467 + test-tool dump-untracked-cache >../actual &&
468 cat >../expect <<EOF &&
469 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
470 core.excludesfile 0000000000000000000000000000000000000000
@@ -532,7 +532,7 @@ EOF
532 '
533
534 test_expect_success 'verify untracked cache dump (sparse/subdirs)' '
535 - test-dump-untracked-cache >../actual &&
535 + test-tool dump-untracked-cache >../actual &&
536 cat >../expect-from-test-dump <<EOF &&
537 info/exclude 13263c0978fb9fad16b2d580fb800b6d811c3ff0
538 core.excludesfile 0000000000000000000000000000000000000000
@@ -598,66 +598,66 @@ EOF
598
599 test_expect_success '--no-untracked-cache removes the cache' '
600 git update-index --no-untracked-cache &&
601 - test-dump-untracked-cache >../actual &&
601 + test-tool dump-untracked-cache >../actual &&
602 echo "no untracked cache" >../expect-no-uc &&
603 test_cmp ../expect-no-uc ../actual
604 '
605
606 test_expect_success 'git status does not change anything' '
607 git status &&
608 - test-dump-untracked-cache >../actual &&
608 + test-tool dump-untracked-cache >../actual &&
609 test_cmp ../expect-no-uc ../actual
610 '
611
612 test_expect_success 'setting core.untrackedCache to true and using git status creates the cache' '
613 git config core.untrackedCache true &&
614 - test-dump-untracked-cache >../actual &&
614 + test-tool dump-untracked-cache >../actual &&
615 test_cmp ../expect-no-uc ../actual &&
616 git status &&
617 - test-dump-untracked-cache >../actual &&
617 + test-tool dump-untracked-cache >../actual &&
618 test_cmp ../expect-from-test-dump ../actual
619 '
620
621 test_expect_success 'using --no-untracked-cache does not fail when core.untrackedCache is true' '
622 git update-index --no-untracked-cache &&
623 - test-dump-untracked-cache >../actual &&
623 + test-tool dump-untracked-cache >../actual &&
624 test_cmp ../expect-no-uc ../actual &&
625 git update-index --untracked-cache &&
626 - test-dump-untracked-cache >../actual &&
626 + test-tool dump-untracked-cache >../actual &&
627 test_cmp ../expect-empty ../actual
628 '
629
630 test_expect_success 'setting core.untrackedCache to false and using git status removes the cache' '
631 git config core.untrackedCache false &&
632 - test-dump-untracked-cache >../actual &&
632 + test-tool dump-untracked-cache >../actual &&
633 test_cmp ../expect-empty ../actual &&
634 git status &&
635 - test-dump-untracked-cache >../actual &&
635 + test-tool dump-untracked-cache >../actual &&
636 test_cmp ../expect-no-uc ../actual
637 '
638
639 test_expect_success 'using --untracked-cache does not fail when core.untrackedCache is false' '
640 git update-index --untracked-cache &&
641 - test-dump-untracked-cache >../actual &&
641 + test-tool dump-untracked-cache >../actual &&
642 test_cmp ../expect-empty ../actual
643 '
644
645 test_expect_success 'setting core.untrackedCache to keep' '
646 git config core.untrackedCache keep &&
647 git update-index --untracked-cache &&
648 - test-dump-untracked-cache >../actual &&
648 + test-tool dump-untracked-cache >../actual &&
649 test_cmp ../expect-empty ../actual &&
650 git status &&
651 - test-dump-untracked-cache >../actual &&
651 + test-tool dump-untracked-cache >../actual &&
652 test_cmp ../expect-from-test-dump ../actual &&
653 git update-index --no-untracked-cache &&
654 - test-dump-untracked-cache >../actual &&
654 + test-tool dump-untracked-cache >../actual &&
655 test_cmp ../expect-no-uc ../actual &&
656 git update-index --force-untracked-cache &&
657 - test-dump-untracked-cache >../actual &&
657 + test-tool dump-untracked-cache >../actual &&
658 test_cmp ../expect-empty ../actual &&
659 git status &&
660 - test-dump-untracked-cache >../actual &&
660 + test-tool dump-untracked-cache >../actual &&
661 test_cmp ../expect-from-test-dump ../actual
662 '
663
@@ -671,23 +671,23 @@ test_expect_success 'test ident field is working' '
671
672 test_expect_success 'untracked cache survives a checkout' '
673 git commit --allow-empty -m empty &&
674 - test-dump-untracked-cache >../before &&
674 + test-tool dump-untracked-cache >../before &&
675 test_when_finished "git checkout master" &&
676 git checkout -b other_branch &&
677 - test-dump-untracked-cache >../after &&
677 + test-tool dump-untracked-cache >../after &&
678 test_cmp ../before ../after &&
679 test_commit test &&
680 - test-dump-untracked-cache >../before &&
680 + test-tool dump-untracked-cache >../before &&
681 git checkout master &&
682 - test-dump-untracked-cache >../after &&
682 + test-tool dump-untracked-cache >../after &&
683 test_cmp ../before ../after
684 '
685
686 test_expect_success 'untracked cache survives a commit' '
687 - test-dump-untracked-cache >../before &&
687 + test-tool dump-untracked-cache >../before &&
688 git add done/two &&
689 git commit -m commit &&
690 - test-dump-untracked-cache >../after &&
690 + test-tool dump-untracked-cache >../after &&
691 test_cmp ../before ../after
692 '
693
@@ -751,7 +751,7 @@ test_expect_success '"status" after file replacement should be clean with UC=tru
751 git checkout master &&
752 avoid_racy &&
753 status_is_clean &&
754 - test-dump-untracked-cache >../actual &&
754 + test-tool dump-untracked-cache >../actual &&
755 grep -F "recurse valid" ../actual >../actual.grep &&
756 cat >../expect.grep <<EOF &&
757 / 0000000000000000000000000000000000000000 recurse valid
t/t7519-status-fsmonitor.sh
+2 -2
@@ -333,7 +333,7 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR'
333 git update-index --fsmonitor &&
334 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace-before" \
335 git status &&
336 - test-dump-untracked-cache >../before
336 + test-tool dump-untracked-cache >../before
337 ) &&
338 cat >>dot-git/.git/hooks/fsmonitor-test <<-\EOF &&
339 printf ".git\0"
@@ -345,7 +345,7 @@ test_expect_success UNTRACKED_CACHE 'ignore .git changes when invalidating UNTR'
345 cd dot-git &&
346 GIT_TRACE_UNTRACKED_STATS="$TRASH_DIRECTORY/trace-after" \
347 git status &&
348 - test-dump-untracked-cache >../after
348 + test-tool dump-untracked-cache >../after
349 ) &&
350 grep "directory invalidation" trace-before >>before &&
351 grep "directory invalidation" trace-after >>after &&