mirror of
https://gitlab.freedesktop.org/libinput/libinput.git
synced 2025-12-25 01:10:08 +01:00
test: add --exit-first to the litest test suite runner
Exits upon the first failed test. Part-of: <https://gitlab.freedesktop.org/libinput/libinput/-/merge_requests/1067>
This commit is contained in:
parent
7b69fb2d63
commit
d84efcb4b6
3 changed files with 39 additions and 1 deletions
|
|
@ -80,6 +80,7 @@ struct litest_runner {
|
|||
size_t max_forks;
|
||||
unsigned int timeout;
|
||||
bool verbose;
|
||||
bool exit_on_fail;
|
||||
|
||||
int terminating;
|
||||
|
||||
|
|
@ -684,6 +685,12 @@ litest_runner_set_verbose(struct litest_runner *runner,
|
|||
runner->verbose = verbose;
|
||||
}
|
||||
|
||||
void
|
||||
litest_runner_set_exit_on_fail(struct litest_runner *runner, bool do_exit)
|
||||
{
|
||||
runner->exit_on_fail = do_exit;
|
||||
}
|
||||
|
||||
void
|
||||
litest_runner_add_test(struct litest_runner *runner,
|
||||
const struct litest_runner_test_description *desc)
|
||||
|
|
@ -801,6 +808,26 @@ litest_runner_run_tests(struct litest_runner *runner)
|
|||
if (runner->terminating) {
|
||||
break;
|
||||
}
|
||||
|
||||
if (runner->exit_on_fail) {
|
||||
bool do_exit = false;
|
||||
struct litest_runner_test *complete;
|
||||
list_for_each(complete, &runner->tests_complete, node) {
|
||||
switch (complete->result) {
|
||||
case LITEST_FAIL:
|
||||
case LITEST_SYSTEM_ERROR:
|
||||
case LITEST_TIMEOUT:
|
||||
do_exit = true;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (do_exit)
|
||||
break;
|
||||
}
|
||||
if (do_exit)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (!runner->terminating && !list_empty(&runner->tests_running)) {
|
||||
|
|
|
|||
|
|
@ -77,6 +77,7 @@ struct litest_runner *litest_runner_new(void);
|
|||
void litest_runner_set_num_parallel(struct litest_runner *runner, size_t num_jobs);
|
||||
void litest_runner_set_timeout(struct litest_runner *runner, unsigned int timeout);
|
||||
void litest_runner_set_verbose(struct litest_runner *runner, bool verbose);
|
||||
void litest_runner_set_exit_on_fail(struct litest_runner *runner, bool do_exit);
|
||||
void litest_runner_add_test(struct litest_runner *runner,
|
||||
const struct litest_runner_test_description *t);
|
||||
enum litest_runner_result litest_runner_run_tests(struct litest_runner *runner);
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ static bool in_debugger = false;
|
|||
static bool verbose = false;
|
||||
static bool run_deviceless = false;
|
||||
static bool use_system_rules_quirks = false;
|
||||
static bool exit_first = false;
|
||||
static const char *filter_test = NULL;
|
||||
static const char *filter_device = NULL;
|
||||
static const char *filter_group = NULL;
|
||||
|
|
@ -997,6 +998,7 @@ litest_run_suite(struct list *suites, int njobs)
|
|||
litest_runner_set_num_parallel(runner, jobs > 0 ? jobs : 0);
|
||||
litest_runner_set_verbose(runner, verbose);
|
||||
litest_runner_set_timeout(runner, 30);
|
||||
litest_runner_set_exit_on_fail(runner, exit_first);
|
||||
|
||||
list_for_each(s, suites, node) {
|
||||
struct test *t;
|
||||
|
|
@ -4518,6 +4520,7 @@ static inline enum litest_mode
|
|||
litest_parse_argv(int argc, char **argv)
|
||||
{
|
||||
enum {
|
||||
OPT_EXIT_FIRST,
|
||||
OPT_FILTER_TEST,
|
||||
OPT_FILTER_DEVICE,
|
||||
OPT_FILTER_GROUP,
|
||||
|
|
@ -4532,6 +4535,7 @@ litest_parse_argv(int argc, char **argv)
|
|||
{ "filter-device", 1, 0, OPT_FILTER_DEVICE },
|
||||
{ "filter-group", 1, 0, OPT_FILTER_GROUP },
|
||||
{ "filter-deviceless", 0, 0, OPT_FILTER_DEVICELESS },
|
||||
{ "exitfirst", 0, 0, OPT_EXIT_FIRST },
|
||||
{ "xml-output", 1, 0, OPT_XML_PREFIX },
|
||||
{ "jobs", 1, 0, OPT_JOBS },
|
||||
{ "list", 0, 0, OPT_LIST },
|
||||
|
|
@ -4568,7 +4572,7 @@ litest_parse_argv(int argc, char **argv)
|
|||
int c;
|
||||
int option_index = 0;
|
||||
|
||||
c = getopt_long(argc, argv, "j:", opts, &option_index);
|
||||
c = getopt_long(argc, argv, "j:x", opts, &option_index);
|
||||
if (c == -1)
|
||||
break;
|
||||
switch(c) {
|
||||
|
|
@ -4577,6 +4581,8 @@ litest_parse_argv(int argc, char **argv)
|
|||
printf("Usage: %s [--verbose] [--jobs] [--filter-...]\n"
|
||||
"\n"
|
||||
"Options:\n"
|
||||
" -x | --exitfirst\n"
|
||||
" Exit instantly on first failed test\n"
|
||||
" --filter-test=.... \n"
|
||||
" Glob to filter on test names\n"
|
||||
" --filter-device=.... \n"
|
||||
|
|
@ -4630,6 +4636,10 @@ litest_parse_argv(int argc, char **argv)
|
|||
case OPT_FILTER_DEVICELESS:
|
||||
run_deviceless = true;
|
||||
break;
|
||||
case 'x':
|
||||
case OPT_EXIT_FIRST:
|
||||
exit_first = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue