Skip to content

Commit 9faf396

Browse files
pks-tgitster
authored andcommitted
t: introduce compatibility options to clar-based tests
Our unit tests that don't yet use the clar unit testing framework ignore any option that they do not understand. It is thus fine to just pass test options we set up globally to those unit tests as they are simply ignored. This makes our life easier because we don't have to special case those options with Meson, where test options are set up globally via `meson test --test-args=`. But our clar-based unit testing framework is way stricter here and will fail in case it is passed an unknown option. Stub out these options with no-ops to make our life a bit easier. Note that this also requires us to remove the `-x` short option for `--exclude`. This is because `-x` has another meaning in our integration tests, as it enables shell tracing. I doubt there are a lot of people out there using it as we only got a small hand full of clar tests in the first place. So better change it now so that we can in the long run improve compatibility between the two different test drivers. Signed-off-by: Patrick Steinhardt <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 78ad729 commit 9faf396

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

parse-options.h

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,18 @@ struct option {
353353
.callback = parse_opt_noop_cb, \
354354
}
355355

356+
static char *parse_options_noop_ignored_value MAYBE_UNUSED;
357+
#define OPT_NOOP_ARG(s, l) { \
358+
.type = OPTION_CALLBACK, \
359+
.short_name = (s), \
360+
.long_name = (l), \
361+
.value = &parse_options_noop_ignored_value, \
362+
.argh = "ignored", \
363+
.help = N_("no-op (backward compatibility)"), \
364+
.flags = PARSE_OPT_HIDDEN, \
365+
.callback = parse_opt_noop_cb, \
366+
}
367+
356368
#define OPT_ALIAS(s, l, source_long_name) { \
357369
.type = OPTION_ALIAS, \
358370
.short_name = (s), \

t/unit-tests/unit-test.c

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,25 @@ int cmd_main(int argc, const char **argv)
1818
N_("immediately exit upon the first failed test")),
1919
OPT_STRING_LIST('r', "run", &run_args, N_("suite[::test]"),
2020
N_("run only test suite or individual test <suite[::test]>")),
21-
OPT_STRING_LIST('x', "exclude", &exclude_args, N_("suite"),
21+
OPT_STRING_LIST(0, "exclude", &exclude_args, N_("suite"),
2222
N_("exclude test suite <suite>")),
23+
/*
24+
* Compatibility wrappers so that we don't have to filter
25+
* options understood by integration tests.
26+
*/
27+
OPT_NOOP_NOARG('d', "debug"),
28+
OPT_NOOP_NOARG(0, "github-workflow-markup"),
29+
OPT_NOOP_NOARG(0, "no-bin-wrappers"),
30+
OPT_NOOP_ARG(0, "root"),
31+
OPT_NOOP_ARG(0, "stress"),
32+
OPT_NOOP_NOARG(0, "tee"),
33+
OPT_NOOP_NOARG(0, "with-dashes"),
34+
OPT_NOOP_ARG(0, "valgrind"),
35+
OPT_NOOP_ARG(0, "valgrind-only"),
36+
OPT_NOOP_NOARG('v', "verbose"),
37+
OPT_NOOP_NOARG('V', "verbose-log"),
38+
OPT_NOOP_ARG(0, "verbose-only"),
39+
OPT_NOOP_NOARG('x', NULL),
2340
OPT_END(),
2441
};
2542
struct strvec args = STRVEC_INIT;

0 commit comments

Comments
 (0)