t/helper: merge test-sha1 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 dae2ff9bb6112bbac0a9bee1e524ae0b3ad316fb
8 files changed +11 -8
Documentation/howto/recover-corrupted-object-harder.txt
+1 -1
@@ -80,7 +80,7 @@ valid pack like:
80 # now add our object data
81 cat object >>tmp.pack
82 # and then append the pack trailer
83 - /path/to/git.git/test-sha1 -b <tmp.pack >trailer
83 + /path/to/git.git/t/helper/test-tool sha1 -b <tmp.pack >trailer
84 cat trailer >>tmp.pack
85 ------------
86
Makefile
+2 -2
@@ -653,6 +653,7 @@ X =
653 PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
654
655 TEST_BUILTINS_OBJS += test-chmtime.o
656 +TEST_BUILTINS_OBJS += test-sha1.o
657
658 TEST_PROGRAMS_NEED_X += test-ctype
659 TEST_PROGRAMS_NEED_X += test-config
@@ -684,7 +685,6 @@ TEST_PROGRAMS_NEED_X += test-regex
685 TEST_PROGRAMS_NEED_X += test-revision-walking
686 TEST_PROGRAMS_NEED_X += test-run-command
687 TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
687 -TEST_PROGRAMS_NEED_X += test-sha1
688 TEST_PROGRAMS_NEED_X += test-sha1-array
689 TEST_PROGRAMS_NEED_X += test-sigchain
690 TEST_PROGRAMS_NEED_X += test-strcmp-offset
@@ -2502,7 +2502,7 @@ t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
2502 t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
2503 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
2504
2505 -check-sha1:: t/helper/test-sha1$X
2505 +check-sha1:: t/helper/test-tool$X
2506 t/helper/test-sha1.sh
2507
2508 SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))
t/helper/test-sha1.c
+2 -1
@@ -1,6 +1,7 @@
1 +#include "test-tool.h"
2 #include "cache.h"
3
3 -int cmd_main(int ac, const char **av)
4 +int cmd__sha1(int ac, const char **av)
5 {
6 git_SHA_CTX ctx;
7 unsigned char sha1[20];
t/helper/test-sha1.sh
+2 -2
@@ -1,7 +1,7 @@
1 #!/bin/sh
2
3 dd if=/dev/zero bs=1048576 count=100 2>/dev/null |
4 -/usr/bin/time t/helper/test-sha1 >/dev/null
4 +/usr/bin/time t/helper/test-tool sha1 >/dev/null
5
6 while read expect cnt pfx
7 do
@@ -11,7 +11,7 @@ do
11 test -z "$pfx" || echo "$pfx"
12 dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
13 perl -pe 'y/\000/g/'
14 - } | ./t/helper/test-sha1 $cnt
14 + } | ./t/helper/test-tool sha1 $cnt
15 )
16 if test "$expect" = "$actual"
17 then
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 + { "sha1", cmd__sha1 },
12 };
13
14 int cmd_main(int argc, const char **argv)
t/helper/test-tool.h
+1
@@ -2,5 +2,6 @@
2 #define __TEST_TOOL_H__
3
4 int cmd__chmtime(int argc, const char **argv);
5 +int cmd__sha1(int argc, const char **argv);
6
7 #endif
t/lib-pack.sh
+1 -1
@@ -85,7 +85,7 @@ pack_obj () {
85
86 # Compute and append pack trailer to "$1"
87 pack_trailer () {
88 - test-sha1 -b <"$1" >trailer.tmp &&
88 + test-tool sha1 -b <"$1" >trailer.tmp &&
89 cat trailer.tmp >>"$1" &&
90 rm -f trailer.tmp
91 }
t/t0013-sha1dc.sh
+1 -1
@@ -11,7 +11,7 @@ then
11 fi
12
13 test_expect_success 'test-sha1 detects shattered pdf' '
14 - test_must_fail test-sha1 <"$TEST_DATA/shattered-1.pdf" 2>err &&
14 + test_must_fail test-tool sha1 <"$TEST_DATA/shattered-1.pdf" 2>err &&
15 test_i18ngrep collision err &&
16 grep 38762cf7f55934b34d179ae6a4c80cadccbb7f0a err
17 '