test-lib: whitelist GIT_TR2_* in the environment
[gitweb.git] / t / helper / test-parse-options.c
index 630c76d1275485d2d460896407e645116c997916..cc88fba05752cbf67c2669c219cc0a65d4a354ee 100644 (file)
@@ -1,6 +1,8 @@
+#include "test-tool.h"
 #include "cache.h"
 #include "parse-options.h"
 #include "string-list.h"
+#include "trace2.h"
 
 static int boolean = 0;
 static int integer = 0;
@@ -35,6 +37,7 @@ static int length_callback(const struct option *opt, const char *arg, int unset)
 
 static int number_callback(const struct option *opt, const char *arg, int unset)
 {
+       BUG_ON_OPT_NEG(unset);
        *(int *)opt->value = strtol(arg, NULL, 10);
        return 0;
 }
@@ -94,11 +97,11 @@ static void show(struct string_list *expect, int *status, const char *fmt, ...)
        strbuf_release(&buf);
 }
 
-int cmd_main(int argc, const char **argv)
+int cmd__parse_options(int argc, const char **argv)
 {
        const char *prefix = "prefix/";
        const char *usage[] = {
-               "test-parse-options <options>",
+               "test-tool parse-options <options>",
                "",
                "A helper function for the parse-options API.",
                NULL
@@ -118,7 +121,6 @@ int cmd_main(int argc, const char **argv)
                OPT_INTEGER('j', NULL, &integer, "get a integer, too"),
                OPT_MAGNITUDE('m', "magnitude", &magnitude, "get a magnitude"),
                OPT_SET_INT(0, "set23", &integer, "set integer to 23", 23),
-               OPT_DATE('t', NULL, &timestamp, "get timestamp of <time>"),
                OPT_CALLBACK('L', "length", &integer, "str",
                        "get length of <str>", length_callback),
                OPT_FILENAME('F', "file", &file, "set file to <file>"),
@@ -152,6 +154,8 @@ int cmd_main(int argc, const char **argv)
        int i;
        int ret = 0;
 
+       trace2_cmd_name("_parse_");
+
        argc = parse_options(argc, (const char **)argv, prefix, options, usage, 0);
 
        if (length_cb.called) {