| 11 | }; |
| 12 | |
| 13 | int cmd_main(int argc, const char **argv) |
| 14 | { |
| 15 | struct string_list run_args = STRING_LIST_INIT_NODUP; |
| 16 | struct string_list exclude_args = STRING_LIST_INIT_NODUP; |
| 17 | int immediate = 0; |
| 18 | struct option options[] = { |
| 19 | OPT_BOOL('i', "immediate", &immediate, |
| 20 | N_("immediately exit upon the first failed test")), |
| 21 | OPT_STRING_LIST('r', "run", &run_args, N_("suite[::test]"), |
| 22 | N_("run only test suite or individual test <suite[::test]>")), |
| 23 | OPT_STRING_LIST(0, "exclude", &exclude_args, N_("suite"), |
| 24 | N_("exclude test suite <suite>")), |
| 25 | /* |
| 26 | * Compatibility wrappers so that we don't have to filter |
| 27 | * options understood by integration tests. |
| 28 | */ |
| 29 | OPT_NOOP_NOARG('d', "debug"), |
| 30 | OPT_NOOP_NOARG(0, "github-workflow-markup"), |
| 31 | OPT_NOOP_NOARG(0, "no-bin-wrappers"), |
| 32 | OPT_NOOP_ARG(0, "no-chain-lint"), |
| 33 | OPT_NOOP_ARG(0, "root"), |
| 34 | OPT_NOOP_ARG(0, "stress"), |
| 35 | OPT_NOOP_NOARG(0, "tee"), |
| 36 | OPT_NOOP_NOARG(0, "with-dashes"), |
| 37 | OPT_NOOP_ARG(0, "valgrind"), |
| 38 | OPT_NOOP_ARG(0, "valgrind-only"), |
| 39 | OPT_NOOP_NOARG('v', "verbose"), |
| 40 | OPT_NOOP_NOARG('V', "verbose-log"), |
| 41 | OPT_NOOP_ARG(0, "verbose-only"), |
| 42 | OPT_NOOP_NOARG('x', NULL), |
| 43 | OPT_END(), |
| 44 | }; |
| 45 | struct strvec args = STRVEC_INIT; |
| 46 | int ret; |
| 47 | |
| 48 | argc = parse_options(argc, argv, NULL, options, |
| 49 | unit_test_usage, PARSE_OPT_KEEP_ARGV0); |
| 50 | if (argc > 1) |
| 51 | usagef(_("extra command line parameter '%s'"), argv[0]); |
| 52 | |
| 53 | strvec_push(&args, argv[0]); |
| 54 | strvec_push(&args, "-t"); |
| 55 | if (immediate) |
| 56 | strvec_push(&args, "-Q"); |
| 57 | for (size_t i = 0; i < run_args.nr; i++) |
| 58 | strvec_pushf(&args, "-s%s", run_args.items[i].string); |
| 59 | for (size_t i = 0; i < exclude_args.nr; i++) |
| 60 | strvec_pushf(&args, "-x%s", exclude_args.items[i].string); |
| 61 | |
| 62 | ret = clar_test(args.nr, (char **) args.v); |
| 63 | |
| 64 | string_list_clear(&run_args, 0); |
| 65 | strvec_clear(&args); |
| 66 | return ret; |
| 67 | } |
nothing calls this directly
no test coverage detected