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 ...
This commit is contained in:
@ -5,28 +5,29 @@
|
||||
*
|
||||
* The mtime can be changed to an absolute value:
|
||||
*
|
||||
* test-chmtime =<seconds> file...
|
||||
* test-tool chmtime =<seconds> file...
|
||||
*
|
||||
* Relative to the current time as returned by time(3):
|
||||
*
|
||||
* test-chmtime =+<seconds> (or =-<seconds>) file...
|
||||
* test-tool chmtime =+<seconds> (or =-<seconds>) file...
|
||||
*
|
||||
* Or relative to the current mtime of the file:
|
||||
*
|
||||
* test-chmtime <seconds> file...
|
||||
* test-chmtime +<seconds> (or -<seconds>) file...
|
||||
* test-tool chmtime <seconds> file...
|
||||
* test-tool chmtime +<seconds> (or -<seconds>) file...
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* To just print the mtime use --verbose and set the file mtime offset to 0:
|
||||
*
|
||||
* test-chmtime -v +0 file
|
||||
* test-tool chmtime -v +0 file
|
||||
*
|
||||
* To set the mtime to current time:
|
||||
*
|
||||
* test-chmtime =+0 file
|
||||
* test-tool chmtime =+0 file
|
||||
*
|
||||
*/
|
||||
#include "test-tool.h"
|
||||
#include "git-compat-util.h"
|
||||
#include <utime.h>
|
||||
|
||||
@ -56,7 +57,7 @@ static int timespec_arg(const char *arg, long int *set_time, int *set_eq)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__chmtime(int argc, const char **argv)
|
||||
{
|
||||
static int verbose;
|
||||
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "string-list.h"
|
||||
@ -32,7 +33,7 @@
|
||||
* Examples:
|
||||
*
|
||||
* To print the value with highest priority for key "foo.bAr Baz.rock":
|
||||
* test-config get_value "foo.bAr Baz.rock"
|
||||
* test-tool config get_value "foo.bAr Baz.rock"
|
||||
*
|
||||
*/
|
||||
|
||||
@ -77,7 +78,7 @@ static int early_config_cb(const char *var, const char *value, void *vdata)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__config(int argc, const char **argv)
|
||||
{
|
||||
int i, val;
|
||||
const char *v;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
|
||||
static int rc;
|
||||
@ -28,7 +29,7 @@ static int is_in(const char *s, int ch)
|
||||
#define LOWER "abcdefghijklmnopqrstuvwxyz"
|
||||
#define UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__ctype(int argc, const char **argv)
|
||||
{
|
||||
TEST_CLASS(isdigit, DIGIT);
|
||||
TEST_CLASS(isspace, " \n\r\t");
|
||||
|
||||
@ -1,13 +1,14 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
|
||||
static const char *usage_msg = "\n"
|
||||
" test-date relative [time_t]...\n"
|
||||
" test-date show:<format> [time_t]...\n"
|
||||
" test-date parse [date]...\n"
|
||||
" test-date approxidate [date]...\n"
|
||||
" test-date timestamp [date]...\n"
|
||||
" test-date is64bit\n"
|
||||
" test-date time_t-is64bit\n";
|
||||
" test-tool date relative [time_t]...\n"
|
||||
" test-tool date show:<format> [time_t]...\n"
|
||||
" test-tool date parse [date]...\n"
|
||||
" test-tool date approxidate [date]...\n"
|
||||
" test-tool date timestamp [date]...\n"
|
||||
" test-tool date is64bit\n"
|
||||
" test-tool date time_t-is64bit\n";
|
||||
|
||||
static void show_relative_dates(const char **argv, struct timeval *now)
|
||||
{
|
||||
@ -81,7 +82,7 @@ static void parse_approx_timestamp(const char **argv, struct timeval *now)
|
||||
}
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__date(int argc, const char **argv)
|
||||
{
|
||||
struct timeval now;
|
||||
const char *x;
|
||||
|
||||
@ -8,14 +8,15 @@
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include "test-tool.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "delta.h"
|
||||
#include "cache.h"
|
||||
|
||||
static const char usage_str[] =
|
||||
"test-delta (-d|-p) <from_file> <data_file> <out_file>";
|
||||
"test-tool delta (-d|-p) <from_file> <data_file> <out_file>";
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__delta(int argc, const char **argv)
|
||||
{
|
||||
int fd;
|
||||
struct stat st;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "git-compat-util.h"
|
||||
|
||||
#if defined(GIT_WINDOWS_NATIVE)
|
||||
@ -157,7 +158,7 @@ static int cmd_dropcaches(void)
|
||||
|
||||
#endif
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__drop_caches(int argc, const char **argv)
|
||||
{
|
||||
cmd_sync();
|
||||
return cmd_dropcaches();
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "tree.h"
|
||||
#include "cache-tree.h"
|
||||
@ -54,7 +55,7 @@ static int dump_cache_tree(struct cache_tree *it,
|
||||
return errs;
|
||||
}
|
||||
|
||||
int cmd_main(int ac, const char **av)
|
||||
int cmd__dump_cache_tree(int ac, const char **av)
|
||||
{
|
||||
struct index_state istate;
|
||||
struct cache_tree *another = cache_tree();
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "split-index.h"
|
||||
#include "ewah/ewok.h"
|
||||
@ -7,7 +8,7 @@ static void show_bit(size_t pos, void *data)
|
||||
printf(" %d", (int)pos);
|
||||
}
|
||||
|
||||
int cmd_main(int ac, const char **av)
|
||||
int cmd__dump_split_index(int ac, const char **av)
|
||||
{
|
||||
struct split_index *si;
|
||||
int i;
|
||||
|
||||
@ -1,8 +1,9 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "object.h"
|
||||
#include "decorate.h"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__example_decorate(int argc, const char **argv)
|
||||
{
|
||||
struct decoration n;
|
||||
struct object_id one_oid = { {1} };
|
||||
|
||||
@ -4,9 +4,10 @@
|
||||
* Copyright (C) 2007 by Nicolas Pitre, licensed under the GPL version 2.
|
||||
*/
|
||||
|
||||
#include "test-tool.h"
|
||||
#include "git-compat-util.h"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__genrandom(int argc, const char **argv)
|
||||
{
|
||||
unsigned long count, next = 0;
|
||||
unsigned char *c;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "hashmap.h"
|
||||
#include "strbuf.h"
|
||||
@ -77,7 +78,7 @@ static unsigned int hash(unsigned int method, unsigned int i, const char *key)
|
||||
|
||||
/*
|
||||
* Test performance of hashmap.[ch]
|
||||
* Usage: time echo "perfhashmap method rounds" | test-hashmap
|
||||
* Usage: time echo "perfhashmap method rounds" | test-tool hashmap
|
||||
*/
|
||||
static void perf_hashmap(unsigned int method, unsigned int rounds)
|
||||
{
|
||||
@ -144,7 +145,7 @@ static void perf_hashmap(unsigned int method, unsigned int rounds)
|
||||
*
|
||||
* perfhashmap method rounds -> test hashmap.[ch] performance
|
||||
*/
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__hashmap(int argc, const char **argv)
|
||||
{
|
||||
struct strbuf line = STRBUF_INIT;
|
||||
struct hashmap map;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__index_version(int argc, const char **argv)
|
||||
{
|
||||
struct cache_header hdr;
|
||||
int version;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "parse-options.h"
|
||||
|
||||
@ -184,14 +185,14 @@ static void analyze_run(void)
|
||||
}
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__lazy_init_name_hash(int argc, const char **argv)
|
||||
{
|
||||
const char *usage[] = {
|
||||
"test-lazy-init-name-hash -d (-s | -m)",
|
||||
"test-lazy-init-name-hash -p [-c c]",
|
||||
"test-lazy-init-name-hash -a a [--step s] [-c c]",
|
||||
"test-lazy-init-name-hash (-s | -m) [-c c]",
|
||||
"test-lazy-init-name-hash -s -m [-c c]",
|
||||
"test-tool lazy-init-name-hash -d (-s | -m)",
|
||||
"test-tool lazy-init-name-hash -p [-c c]",
|
||||
"test-tool lazy-init-name-hash -a a [--step s] [-c c]",
|
||||
"test-tool lazy-init-name-hash (-s | -m) [-c c]",
|
||||
"test-tool lazy-init-name-hash -s -m [-c c]",
|
||||
NULL
|
||||
};
|
||||
struct option options[] = {
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "tree.h"
|
||||
|
||||
int cmd_main(int ac, const char **av)
|
||||
int cmd__match_trees(int ac, const char **av)
|
||||
{
|
||||
struct object_id hash1, hash2, shifted;
|
||||
struct tree *one, *two;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "mergesort.h"
|
||||
|
||||
@ -22,7 +23,7 @@ static int compare_strings(const void *a, const void *b)
|
||||
return strcmp(x->text, y->text);
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__mergesort(int argc, const char **argv)
|
||||
{
|
||||
struct line *line, *p = NULL, *lines = NULL;
|
||||
struct strbuf sb = STRBUF_INIT;
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
/*
|
||||
* test-mktemp.c: code to exercise the creation of temporary files
|
||||
*/
|
||||
#include "test-tool.h"
|
||||
#include "git-compat-util.h"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__mktemp(int argc, const char **argv)
|
||||
{
|
||||
if (argc != 2)
|
||||
usage("Expected 1 parameter defining the temporary file template");
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#include "test-tool.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "thread-utils.h"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__online_cpus(int argc, const char **argv)
|
||||
{
|
||||
printf("%d\n", online_cpus());
|
||||
return 0;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "string-list.h"
|
||||
|
||||
@ -170,7 +171,7 @@ static struct test_data dirname_data[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__path_utils(int argc, const char **argv)
|
||||
{
|
||||
if (argc == 3 && !strcmp(argv[1], "normalize_path_copy")) {
|
||||
char *buf = xmallocz(strlen(argv[2]));
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "prio-queue.h"
|
||||
|
||||
@ -16,7 +17,7 @@ static void show(int *v)
|
||||
free(v);
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__prio_queue(int argc, const char **argv)
|
||||
{
|
||||
struct prio_queue pq = { intcmp };
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__read_cache(int argc, const char **argv)
|
||||
{
|
||||
int i, cnt = 1;
|
||||
if (argc == 2)
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "refs.h"
|
||||
#include "worktree.h"
|
||||
@ -275,7 +276,7 @@ static struct command commands[] = {
|
||||
{ NULL, NULL }
|
||||
};
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__ref_store(int argc, const char **argv)
|
||||
{
|
||||
struct ref_store *refs;
|
||||
const char *func;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "gettext.h"
|
||||
|
||||
@ -36,7 +37,7 @@ static int test_regex_bug(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__regex(int argc, const char **argv)
|
||||
{
|
||||
const char *pat;
|
||||
const char *str;
|
||||
@ -47,8 +48,8 @@ int cmd_main(int argc, const char **argv)
|
||||
if (argc == 2 && !strcmp(argv[1], "--bug"))
|
||||
return test_regex_bug();
|
||||
else if (argc < 3)
|
||||
usage("test-regex --bug\n"
|
||||
"test-regex <pattern> <string> [<options>]");
|
||||
usage("test-tool regex --bug\n"
|
||||
"test-tool regex <pattern> <string> [<options>]");
|
||||
|
||||
argv++;
|
||||
pat = *argv++;
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "commit.h"
|
||||
#include "diff.h"
|
||||
@ -45,7 +46,7 @@ static int run_revision_walk(void)
|
||||
return got_revision;
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__revision_walking(int argc, const char **argv)
|
||||
{
|
||||
if (argc < 2)
|
||||
return 1;
|
||||
|
||||
@ -8,6 +8,7 @@
|
||||
* published by the Free Software Foundation.
|
||||
*/
|
||||
|
||||
#include "test-tool.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "run-command.h"
|
||||
#include "argv-array.h"
|
||||
@ -49,7 +50,7 @@ static int task_finished(int result,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__run_command(int argc, const char **argv)
|
||||
{
|
||||
struct child_process proc = CHILD_PROCESS_INIT;
|
||||
int jobs;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "lockfile.h"
|
||||
#include "tree.h"
|
||||
@ -5,7 +6,7 @@
|
||||
|
||||
static struct lock_file index_lock;
|
||||
|
||||
int cmd_main(int ac, const char **av)
|
||||
int cmd__scrap_cache_tree(int ac, const char **av)
|
||||
{
|
||||
setup_git_directory();
|
||||
hold_locked_index(&index_lock, LOCK_DIE_ON_ERROR);
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "sha1-array.h"
|
||||
|
||||
@ -7,7 +8,7 @@ static int print_oid(const struct object_id *oid, void *data)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__sha1_array(int argc, const char **argv)
|
||||
{
|
||||
struct oid_array array = OID_ARRAY_INIT;
|
||||
struct strbuf line = STRBUF_INIT;
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
|
||||
int cmd_main(int ac, const char **av)
|
||||
int cmd__sha1(int ac, const char **av)
|
||||
{
|
||||
git_SHA_CTX ctx;
|
||||
unsigned char sha1[20];
|
||||
|
||||
@ -1,7 +1,7 @@
|
||||
#!/bin/sh
|
||||
|
||||
dd if=/dev/zero bs=1048576 count=100 2>/dev/null |
|
||||
/usr/bin/time t/helper/test-sha1 >/dev/null
|
||||
/usr/bin/time t/helper/test-tool sha1 >/dev/null
|
||||
|
||||
while read expect cnt pfx
|
||||
do
|
||||
@ -11,7 +11,7 @@ do
|
||||
test -z "$pfx" || echo "$pfx"
|
||||
dd if=/dev/zero bs=1048576 count=$cnt 2>/dev/null |
|
||||
perl -pe 'y/\000/g/'
|
||||
} | ./t/helper/test-sha1 $cnt
|
||||
} | ./t/helper/test-tool sha1 $cnt
|
||||
)
|
||||
if test "$expect" = "$actual"
|
||||
then
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "sigchain.h"
|
||||
|
||||
@ -13,7 +14,7 @@ X(two)
|
||||
X(three)
|
||||
#undef X
|
||||
|
||||
int cmd_main(int argc, const char **argv) {
|
||||
int cmd__sigchain(int argc, const char **argv) {
|
||||
sigchain_push(SIGTERM, one);
|
||||
sigchain_push(SIGTERM, two);
|
||||
sigchain_push(SIGTERM, three);
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__strcmp_offset(int argc, const char **argv)
|
||||
{
|
||||
int result;
|
||||
size_t offset;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "string-list.h"
|
||||
|
||||
@ -41,7 +42,7 @@ static int prefix_cb(struct string_list_item *item, void *cb_data)
|
||||
return starts_with(item->string, prefix);
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__string_list(int argc, const char **argv)
|
||||
{
|
||||
if (argc == 5 && !strcmp(argv[1], "split")) {
|
||||
struct string_list list = STRING_LIST_INIT_DUP;
|
||||
|
||||
@ -1,3 +1,4 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "submodule-config.h"
|
||||
@ -10,7 +11,7 @@ static void die_usage(int argc, const char **argv, const char *msg)
|
||||
exit(1);
|
||||
}
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__submodule_config(int argc, const char **argv)
|
||||
{
|
||||
const char **arg = argv;
|
||||
int my_argc = argc;
|
||||
|
||||
@ -1,7 +1,8 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "run-command.h"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__subprocess(int argc, const char **argv)
|
||||
{
|
||||
struct child_process cp = CHILD_PROCESS_INIT;
|
||||
int nogit = 0;
|
||||
|
||||
62
t/helper/test-tool.c
Normal file
62
t/helper/test-tool.c
Normal file
@ -0,0 +1,62 @@
|
||||
#include "git-compat-util.h"
|
||||
#include "test-tool.h"
|
||||
|
||||
struct test_cmd {
|
||||
const char *name;
|
||||
int (*fn)(int argc, const char **argv);
|
||||
};
|
||||
|
||||
static struct test_cmd cmds[] = {
|
||||
{ "chmtime", cmd__chmtime },
|
||||
{ "config", cmd__config },
|
||||
{ "ctype", cmd__ctype },
|
||||
{ "date", cmd__date },
|
||||
{ "delta", cmd__delta },
|
||||
{ "drop-caches", cmd__drop_caches },
|
||||
{ "dump-cache-tree", cmd__dump_cache_tree },
|
||||
{ "dump-split-index", cmd__dump_split_index },
|
||||
{ "example-decorate", cmd__example_decorate },
|
||||
{ "genrandom", cmd__genrandom },
|
||||
{ "hashmap", cmd__hashmap },
|
||||
{ "index-version", cmd__index_version },
|
||||
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
|
||||
{ "match-trees", cmd__match_trees },
|
||||
{ "mergesort", cmd__mergesort },
|
||||
{ "mktemp", cmd__mktemp },
|
||||
{ "online-cpus", cmd__online_cpus },
|
||||
{ "path-utils", cmd__path_utils },
|
||||
{ "prio-queue", cmd__prio_queue },
|
||||
{ "read-cache", cmd__read_cache },
|
||||
{ "ref-store", cmd__ref_store },
|
||||
{ "regex", cmd__regex },
|
||||
{ "revision-walking", cmd__revision_walking },
|
||||
{ "run-command", cmd__run_command },
|
||||
{ "scrap-cache-tree", cmd__scrap_cache_tree },
|
||||
{ "sha1-array", cmd__sha1_array },
|
||||
{ "sha1", cmd__sha1 },
|
||||
{ "sigchain", cmd__sigchain },
|
||||
{ "strcmp-offset", cmd__strcmp_offset },
|
||||
{ "string-list", cmd__string_list },
|
||||
{ "submodule-config", cmd__submodule_config },
|
||||
{ "subprocess", cmd__subprocess },
|
||||
{ "urlmatch-normalization", cmd__urlmatch_normalization },
|
||||
{ "wildmatch", cmd__wildmatch },
|
||||
{ "write-cache", cmd__write_cache },
|
||||
};
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc < 2)
|
||||
die("I need a test name!");
|
||||
|
||||
for (i = 0; i < ARRAY_SIZE(cmds); i++) {
|
||||
if (!strcmp(cmds[i].name, argv[1])) {
|
||||
argv++;
|
||||
argc--;
|
||||
return cmds[i].fn(argc, argv);
|
||||
}
|
||||
}
|
||||
die("There is no test named '%s'", argv[1]);
|
||||
}
|
||||
40
t/helper/test-tool.h
Normal file
40
t/helper/test-tool.h
Normal file
@ -0,0 +1,40 @@
|
||||
#ifndef __TEST_TOOL_H__
|
||||
#define __TEST_TOOL_H__
|
||||
|
||||
int cmd__chmtime(int argc, const char **argv);
|
||||
int cmd__config(int argc, const char **argv);
|
||||
int cmd__ctype(int argc, const char **argv);
|
||||
int cmd__date(int argc, const char **argv);
|
||||
int cmd__delta(int argc, const char **argv);
|
||||
int cmd__drop_caches(int argc, const char **argv);
|
||||
int cmd__dump_cache_tree(int argc, const char **argv);
|
||||
int cmd__dump_split_index(int argc, const char **argv);
|
||||
int cmd__example_decorate(int argc, const char **argv);
|
||||
int cmd__genrandom(int argc, const char **argv);
|
||||
int cmd__hashmap(int argc, const char **argv);
|
||||
int cmd__index_version(int argc, const char **argv);
|
||||
int cmd__lazy_init_name_hash(int argc, const char **argv);
|
||||
int cmd__match_trees(int argc, const char **argv);
|
||||
int cmd__mergesort(int argc, const char **argv);
|
||||
int cmd__mktemp(int argc, const char **argv);
|
||||
int cmd__online_cpus(int argc, const char **argv);
|
||||
int cmd__path_utils(int argc, const char **argv);
|
||||
int cmd__prio_queue(int argc, const char **argv);
|
||||
int cmd__read_cache(int argc, const char **argv);
|
||||
int cmd__ref_store(int argc, const char **argv);
|
||||
int cmd__regex(int argc, const char **argv);
|
||||
int cmd__revision_walking(int argc, const char **argv);
|
||||
int cmd__run_command(int argc, const char **argv);
|
||||
int cmd__scrap_cache_tree(int argc, const char **argv);
|
||||
int cmd__sha1_array(int argc, const char **argv);
|
||||
int cmd__sha1(int argc, const char **argv);
|
||||
int cmd__sigchain(int argc, const char **argv);
|
||||
int cmd__strcmp_offset(int argc, const char **argv);
|
||||
int cmd__string_list(int argc, const char **argv);
|
||||
int cmd__submodule_config(int argc, const char **argv);
|
||||
int cmd__subprocess(int argc, const char **argv);
|
||||
int cmd__urlmatch_normalization(int argc, const char **argv);
|
||||
int cmd__wildmatch(int argc, const char **argv);
|
||||
int cmd__write_cache(int argc, const char **argv);
|
||||
|
||||
#endif
|
||||
@ -1,9 +1,10 @@
|
||||
#include "test-tool.h"
|
||||
#include "git-compat-util.h"
|
||||
#include "urlmatch.h"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__urlmatch_normalization(int argc, const char **argv)
|
||||
{
|
||||
const char usage[] = "test-urlmatch-normalization [-p | -l] <url1> | <url1> <url2>";
|
||||
const char usage[] = "test-tool urlmatch-normalization [-p | -l] <url1> | <url1> <url2>";
|
||||
char *url1, *url2;
|
||||
int opt_p = 0, opt_l = 0;
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__wildmatch(int argc, const char **argv)
|
||||
{
|
||||
int i;
|
||||
for (i = 2; i < argc; i++) {
|
||||
|
||||
@ -1,9 +1,10 @@
|
||||
#include "test-tool.h"
|
||||
#include "cache.h"
|
||||
#include "lockfile.h"
|
||||
|
||||
static struct lock_file index_lock;
|
||||
|
||||
int cmd_main(int argc, const char **argv)
|
||||
int cmd__write_cache(int argc, const char **argv)
|
||||
{
|
||||
int i, cnt = 1, lockfd;
|
||||
if (argc == 2)
|
||||
|
||||
Reference in New Issue
Block a user