t / helper / test-tool.con commit t/helper: merge test-date into test-tool (a801a7c)
   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        { "lazy-init-name-hash", cmd__lazy_init_name_hash },
  15        { "sha1", cmd__sha1 },
  16};
  17
  18int cmd_main(int argc, const char **argv)
  19{
  20        int i;
  21
  22        if (argc < 2)
  23                die("I need a test name!");
  24
  25        for (i = 0; i < ARRAY_SIZE(cmds); i++) {
  26                if (!strcmp(cmds[i].name, argv[1])) {
  27                        argv++;
  28                        argc--;
  29                        return cmds[i].fn(argc, argv);
  30                }
  31        }
  32        die("There is no test named '%s'", argv[1]);
  33}