From a9f80a8195b737beebfe1daba50f77ae0db9ab42 Mon Sep 17 00:00:00 2001 From: Pauli Virtanen Date: Tue, 14 May 2024 23:41:48 +0300 Subject: [PATCH] shared/tester: add ability to skip tests unless explicitly selected Make it possible to skip running a test, and skip running if the test was not explicitly selected on command line. --- src/shared/tester.c | 32 ++++++++++++++++++++++++++++++++ src/shared/tester.h | 2 ++ 2 files changed, 34 insertions(+) diff --git a/src/shared/tester.c b/src/shared/tester.c index a1ee5b687..56c8cba6f 100644 --- a/src/shared/tester.c +++ b/src/shared/tester.c @@ -563,6 +563,38 @@ void tester_pre_setup_failed(void) g_idle_add(done_callback, test); } +void tester_pre_setup_abort(void) +{ + struct test_case *test; + + if (!test_current) + return; + + test = test_current->data; + + if (test->stage != TEST_STAGE_PRE_SETUP) + return; + + if (test->timeout_id > 0) { + timeout_remove(test->timeout_id); + test->timeout_id = 0; + } + + print_progress(test->name, COLOR_YELLOW, "not run"); + + g_idle_add(done_callback, test); +} + +bool tester_pre_setup_skip_by_default(void) +{ + if (!option_prefix && !option_string) { + tester_pre_setup_abort(); + return true; + } + + return false; +} + void tester_setup_complete(void) { struct test_case *test; diff --git a/src/shared/tester.h b/src/shared/tester.h index 16f41022d..1f8138434 100644 --- a/src/shared/tester.h +++ b/src/shared/tester.h @@ -59,6 +59,8 @@ void *tester_get_data(void); void tester_pre_setup_complete(void); void tester_pre_setup_failed(void); +void tester_pre_setup_abort(void); +bool tester_pre_setup_skip_by_default(void); void tester_setup_complete(void); void tester_setup_failed(void); -- 2.47.3