Skip to content

Commit 27f2584

Browse files
committed
Merge branch 'nd/combined-test-helper'
Small test-helper programs have been consolidated into a single binary. * nd/combined-test-helper: (36 commits) t/helper: merge test-write-cache into test-tool t/helper: merge test-wildmatch into test-tool t/helper: merge test-urlmatch-normalization into test-tool t/helper: merge test-subprocess into test-tool t/helper: merge test-submodule-config into test-tool t/helper: merge test-string-list into test-tool t/helper: merge test-strcmp-offset into test-tool t/helper: merge test-sigchain into test-tool t/helper: merge test-sha1-array into test-tool t/helper: merge test-scrap-cache-tree into test-tool t/helper: merge test-run-command into test-tool t/helper: merge test-revision-walking into test-tool t/helper: merge test-regex into test-tool t/helper: merge test-ref-store into test-tool t/helper: merge test-read-cache into test-tool t/helper: merge test-prio-queue into test-tool t/helper: merge test-path-utils into test-tool t/helper: merge test-online-cpus into test-tool t/helper: merge test-mktemp into test-tool t/helper: merge (unused) test-mergesort into test-tool ...
2 parents 3a1ec60 + c81f843 commit 27f2584

File tree

121 files changed

+684
-542
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

121 files changed

+684
-542
lines changed

Documentation/howto/recover-corrupted-object-harder.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ valid pack like:
8080
# now add our object data
8181
cat object >>tmp.pack
8282
# 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
8484
cat trailer >>tmp.pack
8585
------------
8686

Makefile

Lines changed: 42 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,7 @@ SCRIPT_PERL =
554554
SCRIPT_PYTHON =
555555
SCRIPT_SH =
556556
SCRIPT_LIB =
557+
TEST_BUILTINS_OBJS =
557558
TEST_PROGRAMS_NEED_X =
558559

559560
# Having this variable in your environment would break pipelines because
@@ -659,47 +660,49 @@ X =
659660

660661
PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
661662

662-
TEST_PROGRAMS_NEED_X += test-chmtime
663-
TEST_PROGRAMS_NEED_X += test-ctype
664-
TEST_PROGRAMS_NEED_X += test-config
665-
TEST_PROGRAMS_NEED_X += test-date
666-
TEST_PROGRAMS_NEED_X += test-delta
667-
TEST_PROGRAMS_NEED_X += test-drop-caches
668-
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
663+
TEST_BUILTINS_OBJS += test-chmtime.o
664+
TEST_BUILTINS_OBJS += test-config.o
665+
TEST_BUILTINS_OBJS += test-ctype.o
666+
TEST_BUILTINS_OBJS += test-date.o
667+
TEST_BUILTINS_OBJS += test-delta.o
668+
TEST_BUILTINS_OBJS += test-drop-caches.o
669+
TEST_BUILTINS_OBJS += test-dump-cache-tree.o
670+
TEST_BUILTINS_OBJS += test-dump-split-index.o
671+
TEST_BUILTINS_OBJS += test-example-decorate.o
672+
TEST_BUILTINS_OBJS += test-genrandom.o
673+
TEST_BUILTINS_OBJS += test-hashmap.o
674+
TEST_BUILTINS_OBJS += test-index-version.o
675+
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
676+
TEST_BUILTINS_OBJS += test-match-trees.o
677+
TEST_BUILTINS_OBJS += test-mergesort.o
678+
TEST_BUILTINS_OBJS += test-mktemp.o
679+
TEST_BUILTINS_OBJS += test-online-cpus.o
680+
TEST_BUILTINS_OBJS += test-path-utils.o
681+
TEST_BUILTINS_OBJS += test-prio-queue.o
682+
TEST_BUILTINS_OBJS += test-read-cache.o
683+
TEST_BUILTINS_OBJS += test-ref-store.o
684+
TEST_BUILTINS_OBJS += test-regex.o
685+
TEST_BUILTINS_OBJS += test-revision-walking.o
686+
TEST_BUILTINS_OBJS += test-run-command.o
687+
TEST_BUILTINS_OBJS += test-scrap-cache-tree.o
688+
TEST_BUILTINS_OBJS += test-sha1-array.o
689+
TEST_BUILTINS_OBJS += test-sha1.o
690+
TEST_BUILTINS_OBJS += test-sigchain.o
691+
TEST_BUILTINS_OBJS += test-strcmp-offset.o
692+
TEST_BUILTINS_OBJS += test-string-list.o
693+
TEST_BUILTINS_OBJS += test-submodule-config.o
694+
TEST_BUILTINS_OBJS += test-subprocess.o
695+
TEST_BUILTINS_OBJS += test-urlmatch-normalization.o
696+
TEST_BUILTINS_OBJS += test-wildmatch.o
697+
TEST_BUILTINS_OBJS += test-write-cache.o
698+
669699
TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
670-
TEST_PROGRAMS_NEED_X += test-dump-split-index
671700
TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
672-
TEST_PROGRAMS_NEED_X += test-example-decorate
673701
TEST_PROGRAMS_NEED_X += test-fake-ssh
674-
TEST_PROGRAMS_NEED_X += test-genrandom
675-
TEST_PROGRAMS_NEED_X += test-hashmap
676-
TEST_PROGRAMS_NEED_X += test-index-version
677-
TEST_PROGRAMS_NEED_X += test-lazy-init-name-hash
678702
TEST_PROGRAMS_NEED_X += test-line-buffer
679-
TEST_PROGRAMS_NEED_X += test-match-trees
680-
TEST_PROGRAMS_NEED_X += test-mergesort
681-
TEST_PROGRAMS_NEED_X += test-mktemp
682-
TEST_PROGRAMS_NEED_X += test-online-cpus
683703
TEST_PROGRAMS_NEED_X += test-parse-options
684-
TEST_PROGRAMS_NEED_X += test-path-utils
685-
TEST_PROGRAMS_NEED_X += test-prio-queue
686-
TEST_PROGRAMS_NEED_X += test-read-cache
687-
TEST_PROGRAMS_NEED_X += test-write-cache
688-
TEST_PROGRAMS_NEED_X += test-ref-store
689-
TEST_PROGRAMS_NEED_X += test-regex
690-
TEST_PROGRAMS_NEED_X += test-revision-walking
691-
TEST_PROGRAMS_NEED_X += test-run-command
692-
TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
693-
TEST_PROGRAMS_NEED_X += test-sha1
694-
TEST_PROGRAMS_NEED_X += test-sha1-array
695-
TEST_PROGRAMS_NEED_X += test-sigchain
696-
TEST_PROGRAMS_NEED_X += test-strcmp-offset
697-
TEST_PROGRAMS_NEED_X += test-string-list
698-
TEST_PROGRAMS_NEED_X += test-submodule-config
699-
TEST_PROGRAMS_NEED_X += test-subprocess
700704
TEST_PROGRAMS_NEED_X += test-svn-fe
701-
TEST_PROGRAMS_NEED_X += test-urlmatch-normalization
702-
TEST_PROGRAMS_NEED_X += test-wildmatch
705+
TEST_PROGRAMS_NEED_X += test-tool
703706

704707
TEST_PROGRAMS = $(patsubst %,t/helper/%$X,$(TEST_PROGRAMS_NEED_X))
705708

@@ -2092,7 +2095,7 @@ VCSSVN_OBJS += vcs-svn/fast_export.o
20922095
VCSSVN_OBJS += vcs-svn/svndiff.o
20932096
VCSSVN_OBJS += vcs-svn/svndump.o
20942097

2095-
TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS))
2098+
TEST_OBJS := $(patsubst %$X,%.o,$(TEST_PROGRAMS)) $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
20962099
OBJECTS := $(LIB_OBJS) $(BUILTIN_OBJS) $(PROGRAM_OBJS) $(TEST_OBJS) \
20972100
$(XDIFF_OBJS) \
20982101
$(VCSSVN_OBJS) \
@@ -2503,10 +2506,12 @@ t/helper/test-svn-fe$X: $(VCSSVN_LIB)
25032506

25042507
.PRECIOUS: $(TEST_OBJS)
25052508

2509+
t/helper/test-tool$X: $(patsubst %,t/helper/%,$(TEST_BUILTINS_OBJS))
2510+
25062511
t/helper/test-%$X: t/helper/test-%.o GIT-LDFLAGS $(GITLIBS)
25072512
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(filter %.a,$^) $(LIBS)
25082513

2509-
check-sha1:: t/helper/test-sha1$X
2514+
check-sha1:: t/helper/test-tool$X
25102515
t/helper/test-sha1.sh
25112516

25122517
SP_OBJ = $(patsubst %.o,%.sp,$(C_OBJ))

t/helper/test-chmtime.c

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,28 +5,29 @@
55
*
66
* The mtime can be changed to an absolute value:
77
*
8-
* test-chmtime =<seconds> file...
8+
* test-tool chmtime =<seconds> file...
99
*
1010
* Relative to the current time as returned by time(3):
1111
*
12-
* test-chmtime =+<seconds> (or =-<seconds>) file...
12+
* test-tool chmtime =+<seconds> (or =-<seconds>) file...
1313
*
1414
* Or relative to the current mtime of the file:
1515
*
16-
* test-chmtime <seconds> file...
17-
* test-chmtime +<seconds> (or -<seconds>) file...
16+
* test-tool chmtime <seconds> file...
17+
* test-tool chmtime +<seconds> (or -<seconds>) file...
1818
*
1919
* Examples:
2020
*
2121
* To just print the mtime use --verbose and set the file mtime offset to 0:
2222
*
23-
* test-chmtime -v +0 file
23+
* test-tool chmtime -v +0 file
2424
*
2525
* To set the mtime to current time:
2626
*
27-
* test-chmtime =+0 file
27+
* test-tool chmtime =+0 file
2828
*
2929
*/
30+
#include "test-tool.h"
3031
#include "git-compat-util.h"
3132
#include <utime.h>
3233

@@ -56,7 +57,7 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
5657
return 1;
5758
}
5859

59-
int cmd_main(int argc, const char **argv)
60+
int cmd__chmtime(int argc, const char **argv)
6061
{
6162
static int verbose;
6263

t/helper/test-config.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "test-tool.h"
12
#include "cache.h"
23
#include "config.h"
34
#include "string-list.h"
@@ -32,7 +33,7 @@
3233
* Examples:
3334
*
3435
* To print the value with highest priority for key "foo.bAr Baz.rock":
35-
* test-config get_value "foo.bAr Baz.rock"
36+
* test-tool config get_value "foo.bAr Baz.rock"
3637
*
3738
*/
3839

@@ -77,7 +78,7 @@ static int early_config_cb(const char *var, const char *value, void *vdata)
7778
return 0;
7879
}
7980

80-
int cmd_main(int argc, const char **argv)
81+
int cmd__config(int argc, const char **argv)
8182
{
8283
int i, val;
8384
const char *v;

t/helper/test-ctype.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "test-tool.h"
12
#include "cache.h"
23

34
static int rc;
@@ -28,7 +29,7 @@ static int is_in(const char *s, int ch)
2829
#define LOWER "abcdefghijklmnopqrstuvwxyz"
2930
#define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
3031

31-
int cmd_main(int argc, const char **argv)
32+
int cmd__ctype(int argc, const char **argv)
3233
{
3334
TEST_CLASS(isdigit, DIGIT);
3435
TEST_CLASS(isspace, " \n\r\t");

t/helper/test-date.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1+
#include "test-tool.h"
12
#include "cache.h"
23

34
static const char *usage_msg = "\n"
4-
" test-date relative [time_t]...\n"
5-
" test-date show:<format> [time_t]...\n"
6-
" test-date parse [date]...\n"
7-
" test-date approxidate [date]...\n"
8-
" test-date timestamp [date]...\n"
9-
" test-date is64bit\n"
10-
" test-date time_t-is64bit\n";
5+
" test-tool date relative [time_t]...\n"
6+
" test-tool date show:<format> [time_t]...\n"
7+
" test-tool date parse [date]...\n"
8+
" test-tool date approxidate [date]...\n"
9+
" test-tool date timestamp [date]...\n"
10+
" test-tool date is64bit\n"
11+
" test-tool date time_t-is64bit\n";
1112

1213
static void show_relative_dates(const char **argv, struct timeval *now)
1314
{
@@ -81,7 +82,7 @@ static void parse_approx_timestamp(const char **argv, struct timeval *now)
8182
}
8283
}
8384

84-
int cmd_main(int argc, const char **argv)
85+
int cmd__date(int argc, const char **argv)
8586
{
8687
struct timeval now;
8788
const char *x;

t/helper/test-delta.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,15 @@
88
* published by the Free Software Foundation.
99
*/
1010

11+
#include "test-tool.h"
1112
#include "git-compat-util.h"
1213
#include "delta.h"
1314
#include "cache.h"
1415

1516
static const char usage_str[] =
16-
"test-delta (-d|-p) <from_file> <data_file> <out_file>";
17+
"test-tool delta (-d|-p) <from_file> <data_file> <out_file>";
1718

18-
int cmd_main(int argc, const char **argv)
19+
int cmd__delta(int argc, const char **argv)
1920
{
2021
int fd;
2122
struct stat st;

t/helper/test-drop-caches.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "test-tool.h"
12
#include "git-compat-util.h"
23

34
#if defined(GIT_WINDOWS_NATIVE)
@@ -157,7 +158,7 @@ static int cmd_dropcaches(void)
157158

158159
#endif
159160

160-
int cmd_main(int argc, const char **argv)
161+
int cmd__drop_caches(int argc, const char **argv)
161162
{
162163
cmd_sync();
163164
return cmd_dropcaches();

t/helper/test-dump-cache-tree.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "test-tool.h"
12
#include "cache.h"
23
#include "tree.h"
34
#include "cache-tree.h"
@@ -54,7 +55,7 @@ static int dump_cache_tree(struct cache_tree *it,
5455
return errs;
5556
}
5657

57-
int cmd_main(int ac, const char **av)
58+
int cmd__dump_cache_tree(int ac, const char **av)
5859
{
5960
struct index_state istate;
6061
struct cache_tree *another = cache_tree();

t/helper/test-dump-split-index.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "test-tool.h"
12
#include "cache.h"
23
#include "split-index.h"
34
#include "ewah/ewok.h"
@@ -7,7 +8,7 @@ static void show_bit(size_t pos, void *data)
78
printf(" %d", (int)pos);
89
}
910

10-
int cmd_main(int ac, const char **av)
11+
int cmd__dump_split_index(int ac, const char **av)
1112
{
1213
struct split_index *si;
1314
int i;

t/helper/test-example-decorate.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,9 @@
1+
#include "test-tool.h"
12
#include "cache.h"
23
#include "object.h"
34
#include "decorate.h"
45

5-
int cmd_main(int argc, const char **argv)
6+
int cmd__example_decorate(int argc, const char **argv)
67
{
78
struct decoration n;
89
struct object_id one_oid = { {1} };

t/helper/test-genrandom.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,10 @@
44
* Copyright (C) 2007 by Nicolas Pitre, licensed under the GPL version 2.
55
*/
66

7+
#include "test-tool.h"
78
#include "git-compat-util.h"
89

9-
int cmd_main(int argc, const char **argv)
10+
int cmd__genrandom(int argc, const char **argv)
1011
{
1112
unsigned long count, next = 0;
1213
unsigned char *c;

t/helper/test-hashmap.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "test-tool.h"
12
#include "git-compat-util.h"
23
#include "hashmap.h"
34
#include "strbuf.h"
@@ -77,7 +78,7 @@ static unsigned int hash(unsigned int method, unsigned int i, const char *key)
7778

7879
/*
7980
* Test performance of hashmap.[ch]
80-
* Usage: time echo "perfhashmap method rounds" | test-hashmap
81+
* Usage: time echo "perfhashmap method rounds" | test-tool hashmap
8182
*/
8283
static void perf_hashmap(unsigned int method, unsigned int rounds)
8384
{
@@ -144,7 +145,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
144145
*
145146
* perfhashmap method rounds -> test hashmap.[ch] performance
146147
*/
147-
int cmd_main(int argc, const char **argv)
148+
int cmd__hashmap(int argc, const char **argv)
148149
{
149150
struct strbuf line = STRBUF_INIT;
150151
struct hashmap map;

t/helper/test-index-version.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
1+
#include "test-tool.h"
12
#include "cache.h"
23

3-
int cmd_main(int argc, const char **argv)
4+
int cmd__index_version(int argc, const char **argv)
45
{
56
struct cache_header hdr;
67
int version;

t/helper/test-lazy-init-name-hash.c

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
#include "test-tool.h"
12
#include "cache.h"
23
#include "parse-options.h"
34

@@ -184,14 +185,14 @@ static void analyze_run(void)
184185
}
185186
}
186187

187-
int cmd_main(int argc, const char **argv)
188+
int cmd__lazy_init_name_hash(int argc, const char **argv)
188189
{
189190
const char *usage[] = {
190-
"test-lazy-init-name-hash -d (-s | -m)",
191-
"test-lazy-init-name-hash -p [-c c]",
192-
"test-lazy-init-name-hash -a a [--step s] [-c c]",
193-
"test-lazy-init-name-hash (-s | -m) [-c c]",
194-
"test-lazy-init-name-hash -s -m [-c c]",
191+
"test-tool lazy-init-name-hash -d (-s | -m)",
192+
"test-tool lazy-init-name-hash -p [-c c]",
193+
"test-tool lazy-init-name-hash -a a [--step s] [-c c]",
194+
"test-tool lazy-init-name-hash (-s | -m) [-c c]",
195+
"test-tool lazy-init-name-hash -s -m [-c c]",
195196
NULL
196197
};
197198
struct option options[] = {

t/helper/test-match-trees.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1+
#include "test-tool.h"
12
#include "cache.h"
23
#include "tree.h"
34

4-
int cmd_main(int ac, const char **av)
5+
int cmd__match_trees(int ac, const char **av)
56
{
67
struct object_id hash1, hash2, shifted;
78
struct tree *one, *two;

0 commit comments

Comments
 (0)