From 40748d8624252ffc8193b6ca3121dc53b99d7c83 Mon Sep 17 00:00:00 2001 From: Philipp Kaeser Date: Sun, 26 Apr 2026 09:51:48 +0200 Subject: [PATCH] test: Removes no-longer-needed bs_test(). --- BACKLOG.md | 1 - include/libbase/test.h | 17 -------- src/test.c | 98 ------------------------------------------ 3 files changed, 116 deletions(-) diff --git a/BACKLOG.md b/BACKLOG.md index 46fd0c8..e52b60b 100644 --- a/BACKLOG.md +++ b/BACKLOG.md @@ -17,6 +17,5 @@ * When skipping tests, don't clutter the output with the full skipped test. * Store the failure position for failed tests, include in test summary. -* Eliminate bs_test(). * Make it easy to run a single case, or a single set. * Use bs_test_case_init(), bs_test_case_fini() for the overloaded prepare/report. diff --git a/include/libbase/test.h b/include/libbase/test.h index d11ae3b..5a93195 100644 --- a/include/libbase/test.h +++ b/include/libbase/test.h @@ -137,23 +137,6 @@ bool bs_test_failed(bs_test_t *test_ptr); */ void *bs_test_context(bs_test_t *test_ptr); -/** - * Runs test sets. - * - * @param test_sets - * @param argc - * @param argv - * @param param_ptr Optional, points to a @ref bs_test_param_t and - * specifies parameters for the test environment. - * - * @return 0 on success or the number of failed test sets. - */ -int bs_test( - const bs_test_set_t *test_sets, - int argc, - const char **argv, - const bs_test_param_t *param_ptr); - /** * Runs test sets. * diff --git a/src/test.c b/src/test.c index 19dcc83..6931541 100644 --- a/src/test.c +++ b/src/test.c @@ -186,104 +186,6 @@ static const char *bs_test_report_separator_ptr = /* == Exported Functions =================================================== */ -/* ------------------------------------------------------------------------- */ -int bs_test( - const bs_test_set_t *test_sets, - int argc, - const char **argv, - const bs_test_param_t *param_ptr) -{ - struct bs_test_report report = {}; - int i; - bool run_set; - bs_dllist_t failed_tests = {}; - struct bs_test_env env = {}; - const bs_arg_t bs_test_args[] = { - BS_ARG_STRING( - "test_filter", - "Filter to apply for selecting tests. Uses fnmatch on the full name.", - "*", - &env.filter_ptr), - BS_ARG_STRING( - "test_data_directory", - "Directory to use for test data. Setting this flag takes precedence " - "over the parameter specified through the `bs_test_param_t` arg to " - "bs_test().", - NULL, - &env.data_dir_ptr), - BS_ARG_SENTINEL() - }; - - if (NULL == test_sets) return 0; - if (!bs_arg_parse(bs_test_args, BS_ARG_MODE_NO_EXTRA, &argc, argv)) { - bs_arg_print_usage(stderr, bs_test_args); - return -1; - } - - if (NULL == env.data_dir_ptr && - NULL != param_ptr && - NULL != param_ptr->test_data_dir_ptr) { - env.data_dir_ptr = logged_strdup(param_ptr->test_data_dir_ptr); - if (NULL == env.data_dir_ptr) return -1; - } - - bs_test_tcode_init(); - - /** List of all failed tests. */ - while (NULL != test_sets->name_ptr) { - - /* If any args are given, check if the name matches. */ - run_set = 1 >= argc; - for (i = 1; i < argc; i++) { - if (0 == strcmp(argv[i], test_sets->name_ptr)) { - run_set = true;; - } - } - - if (run_set && test_sets->enabled) { - if (bs_test_set(test_sets, &env, &failed_tests)) { - report.failed++; - } else { - report.succeeded++; - } - } else { - report.skipped++; - } - - report.total++; - test_sets++; - } - - if (report.failed) { - bs_test_attr(BS_TEST_ATTR_FAIL); - bs_test_puts("FAILED: % 66d/% 3d\n", - report.failed, report.total); - - /* Print all failed tests. */ - struct bs_test_fail_node *fnode_ptr; - while (NULL != (fnode_ptr = (struct bs_test_fail_node*) - bs_dllist_pop_front(&failed_tests))) { - bs_test_puts(" %s\n", fnode_ptr->full_name_ptr); - bs_test_case_fail_node_destroy(fnode_ptr); - } - bs_test_attr(BS_TEST_ATTR_RESET); - } else if (report.succeeded) { - bs_test_attr(BS_TEST_ATTR_SUCCESS); - bs_test_puts("SUCCESS: % 65d/% 3d\n", - report.succeeded, report.total); - bs_test_attr(BS_TEST_ATTR_RESET); - } - if (report.skipped) { - bs_test_attr(BS_TEST_ATTR_SKIP); - bs_test_puts("SKIPPED: % 65d/% 3d\n", report.skipped, report.total); - bs_test_attr(BS_TEST_ATTR_RESET); - } - - BS_ASSERT(0 == bs_dllist_size(&failed_tests)); - bs_arg_cleanup(bs_test_args); - return report.failed; -} - /* ------------------------------------------------------------------------- */ int bs_test_sets( const bs_test_set_t** test_set_ptrs,