Skip to content

Commit efd71f8

Browse files
pcloudsgitster
authored andcommitted
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>
1 parent 90bbd50 commit efd71f8

File tree

3 files changed

+36
-1
lines changed

3 files changed

+36
-1
lines changed

Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,6 +546,7 @@ SCRIPT_PERL =
546546
SCRIPT_PYTHON =
547547
SCRIPT_SH =
548548
SCRIPT_LIB =
549+
TEST_BUILTINS_OBJS =
549550
TEST_PROGRAMS_NEED_X =
550551

551552
# Having this variable in your environment would break pipelines because
@@ -690,6 +691,7 @@ TEST_PROGRAMS_NEED_X += test-string-list
690691
TEST_PROGRAMS_NEED_X += test-submodule-config
691692
TEST_PROGRAMS_NEED_X += test-subprocess
692693
TEST_PROGRAMS_NEED_X += test-svn-fe
694+
TEST_PROGRAMS_NEED_X += test-tool
693695
TEST_PROGRAMS_NEED_X += test-urlmatch-normalization
694696
TEST_PROGRAMS_NEED_X += test-wildmatch
695697

@@ -2083,7 +2085,7 @@ VCSSVN_OBJS += vcs-svn/fast_export.o
20832085
VCSSVN_OBJS += vcs-svn/svndiff.o
20842086
VCSSVN_OBJS += vcs-svn/svndump.o
20852087

2086-
TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS))
2088+
TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
20872089
OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
20882090
$(XDIFF_OBJS) \
20892091
$(VCSSVN_OBJS) \
@@ -2494,6 +2496,8 @@ t/helper/test-svn-fe$X: $(VCSSVN_LIB)
24942496

24952497
.PRECIOUS: $(TEST_OBJS)
24962498

2499+
t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
2500+
24972501
t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
24982502
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
24992503

t/helper/test-tool.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#ifndef __TEST_TOOL_H__
2+
#define __TEST_TOOL_H__
3+
4+
#endif

0 commit comments

Comments
 (0)