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