t/helper: add an empty test-tool program
This will become an umbrella program that absorbs most [1] t/helper programs in. By having a single executable binary we reduce disk usage (libgit.a is replicated by every t/helper program) and shorten link time a bit. Running "make --jobs=1; du -sh t/helper" with ccache fully populated, it takes 27 seconds and 277MB at the beginning of this series, 17 seconds and 42MB at the end. [1] There are a couple programs that will not become part of test-tool: test-line-buffer and test-svn-fe have extra dependencies and test-fake-ssh's program name has to be a single word for some ssh tests. 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
efd71f8913a876a0c333fa29382530d6abbc6164
3 files changed
+36
-1
Makefile
+5
-1
@@ -546,6 +546,7 @@ SCRIPT_PERL =
546
SCRIPT_PYTHON =
547
SCRIPT_SH =
548
SCRIPT_LIB =
549
+TEST_BUILTINS_OBJS =
550
TEST_PROGRAMS_NEED_X =
551
552
# Having this variable in your environment would break pipelines because
@@ -690,6 +691,7 @@ TEST_PROGRAMS_NEED_X += test-string-list
691
TEST_PROGRAMS_NEED_X += test-submodule-config
692
TEST_PROGRAMS_NEED_X += test-subprocess
693
TEST_PROGRAMS_NEED_X += test-svn-fe
694
+TEST_PROGRAMS_NEED_X += test-tool
695
TEST_PROGRAMS_NEED_X += test-urlmatch-normalization
696
TEST_PROGRAMS_NEED_X += test-wildmatch
697
@@ -2083,7 +2085,7 @@ VCSSVN_OBJS += vcs-svn/fast_export.o
2085
VCSSVN_OBJS += vcs-svn/svndiff.o
2086
VCSSVN_OBJS += vcs-svn/svndump.o
2087
2086
-TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS))
2088
+TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
2089
OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
2090
$(XDIFF_OBJS) \
2091
$(VCSSVN_OBJS) \
@@ -2494,6 +2496,8 @@ t/helper/test-svn-fe$X: $(VCSSVN_LIB)
2496
2497
.PRECIOUS: $(TEST_OBJS)
2498
2499
+t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
2500
+
2501
t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
2502
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
2503
t/helper/test-tool.c
new
+27
@@ -0,0 +1,27 @@
1
+#include "git-compat-util.h"
2
+#include "test-tool.h"
3
+
4
+struct test_cmd {
5
+ const char *name;
6
+ int (*fn)(int argc, const char **argv);
7
+};
8
+
9
+static struct test_cmd cmds[] = {
10
+};
11
+
12
+int cmd_main(int argc, const char **argv)
13
+{
14
+ int i;
15
+
16
+ if (argc < 2)
17
+ die("I need a test name!");
18
+
19
+ for (i = 0; i < ARRAY_SIZE(cmds); i++) {
20
+ if (!strcmp(cmds[i].name, argv[1])) {
21
+ argv++;
22
+ argc--;
23
+ return cmds[i].fn(argc, argv);
24
+ }
25
+ }
26
+ die("There is no test named '%s'", argv[1]);
27
+}
t/helper/test-tool.h
new
+4
@@ -0,0 +1,4 @@
1
+#ifndef __TEST_TOOL_H__
2
+#define __TEST_TOOL_H__
3
+
4
+#endif