t / helper / test-tool.con commit Merge branch 'en/combined-all-paths' (c425d36)
   1#include "git-compat-util.h"
   2#include "test-tool.h"
   3
   4struct test_cmd {
   5        const char *name;
   6        int (*fn)(int argc, const char **argv);
   7};
   8
   9static struct test_cmd cmds[] = {
  10        { "chmtime", cmd__chmtime },
  11        { "config", cmd__config },
  12        { "ctype", cmd__ctype },
  13        { "date", cmd__date },
  14        { "delta", cmd__delta },
  15        { "drop-caches", cmd__drop_caches },
  16        { "dump-cache-tree", cmd__dump_cache_tree },
  17        { "dump-fsmonitor", cmd__dump_fsmonitor },
  18        { "dump-split-index", cmd__dump_split_index },
  19        { "dump-untracked-cache", cmd__dump_untracked_cache },
  20        { "example-decorate", cmd__example_decorate },
  21        { "genrandom", cmd__genrandom },
  22        { "genzeros", cmd__genzeros },
  23        { "hashmap", cmd__hashmap },
  24        { "hash-speed", cmd__hash_speed },
  25        { "index-version", cmd__index_version },
  26        { "json-writer", cmd__json_writer },
  27        { "lazy-init-name-hash", cmd__lazy_init_name_hash },
  28        { "match-trees", cmd__match_trees },
  29        { "mergesort", cmd__mergesort },
  30        { "mktemp", cmd__mktemp },
  31        { "online-cpus", cmd__online_cpus },
  32        { "parse-options", cmd__parse_options },
  33        { "path-utils", cmd__path_utils },
  34        { "pkt-line", cmd__pkt_line },
  35        { "prio-queue", cmd__prio_queue },
  36        { "reach", cmd__reach },
  37        { "read-cache", cmd__read_cache },
  38        { "read-midx", cmd__read_midx },
  39        { "ref-store", cmd__ref_store },
  40        { "regex", cmd__regex },
  41        { "repository", cmd__repository },
  42        { "revision-walking", cmd__revision_walking },
  43        { "run-command", cmd__run_command },
  44        { "scrap-cache-tree", cmd__scrap_cache_tree },
  45        { "sha1", cmd__sha1 },
  46        { "sha1-array", cmd__sha1_array },
  47        { "sha256", cmd__sha256 },
  48        { "sigchain", cmd__sigchain },
  49        { "strcmp-offset", cmd__strcmp_offset },
  50        { "string-list", cmd__string_list },
  51        { "submodule-config", cmd__submodule_config },
  52        { "submodule-nested-repo-config", cmd__submodule_nested_repo_config },
  53        { "subprocess", cmd__subprocess },
  54        { "urlmatch-normalization", cmd__urlmatch_normalization },
  55        { "xml-encode", cmd__xml_encode },
  56        { "wildmatch", cmd__wildmatch },
  57#ifdef GIT_WINDOWS_NATIVE
  58        { "windows-named-pipe", cmd__windows_named_pipe },
  59#endif
  60        { "write-cache", cmd__write_cache },
  61};
  62
  63static NORETURN void die_usage(void)
  64{
  65        size_t i;
  66
  67        fprintf(stderr, "usage: test-tool <toolname> [args]\n");
  68        for (i = 0; i < ARRAY_SIZE(cmds); i++)
  69                fprintf(stderr, "  %s\n", cmds[i].name);
  70        exit(128);
  71}
  72
  73int cmd_main(int argc, const char **argv)
  74{
  75        int i;
  76
  77        BUG_exit_code = 99;
  78        if (argc < 2)
  79                die_usage();
  80
  81        for (i = 0; i < ARRAY_SIZE(cmds); i++) {
  82                if (!strcmp(cmds[i].name, argv[1])) {
  83                        argv++;
  84                        argc--;
  85                        return cmds[i].fn(argc, argv);
  86                }
  87        }
  88        error("there is no tool named '%s'", argv[1]);
  89        die_usage();
  90}