C++ source file with implementations for the µTest++ test runner member functions. More...
Namespaces Index
Variables Index
| constexpr const char * | help_options = ... |
|
The text displayed by --help, after the usage line. More...
|
|
Description
C++ source file with implementations for the µTest++ test runner member functions.
This source file contains the core implementations for the test runner facilities of the µTest++ framework. It provides the logic for initialising the test environment, registering and managing test suites, handling command-line arguments, orchestrating test execution, and determining the overall test result. The registered suites and the suites declared at namespace scope are executed together, in a single order, sorted by name. A mechanism for aborting test execution in critical scenarios is also provided.
All definitions reside within the micro_os_plus::micro_test_plus namespace.
This file must be included when building the µTest++ library.
Variables
help_options
| const char* micro_os_plus::micro_test_plus::anonymous{runner.cpp}::help_options |
|
constexpr
|
The text displayed by --help, after the usage line.
- Initialiser
-
= "Options:\n"
" --help, -h\n"
" --verbose | --quiet | --silent\n"
" --list-tests, --list\n"
" --reporter=human|tap\n"
" --output-file=<path>\n"
" --colour[=always|never|auto], --color[=...]\n"
" --use-colour=yes|no|auto, --use-color=...\n"
" --filter=<pattern>\n"
" Run only the matching names; repeat the option for each\n"
" nesting level: the first pattern applies to the suite\n"
" names, the second to the test case names, and each\n"
" further one to the nested test cases. The patterns use\n"
" '*' and '?', and '|' separates alternatives.\n"
Lists the options recognised by runner_options, one per line, with the description of the --filter levels.
Definition at line 95 of file runner.cpp.
File Listing
The file content with the documentation metadata removed is:
42#if __has_include("micro-os-plus/diag/trace.h")
43#include "micro-os-plus/diag/trace.h"
53#pragma GCC diagnostic ignored "-Waggregate-return"
55#pragma clang diagnostic ignored "-Wunknown-warning-option"
56#pragma clang diagnostic ignored "-Wc++98-compat"
57#pragma clang diagnostic ignored "-Wc++98-c++11-c++14-compat"
58#pragma clang diagnostic ignored "-Wpre-c++17-compat"
59#pragma clang diagnostic ignored "-Wc++20-compat"
60#pragma clang diagnostic ignored "-Wunsafe-buffer-usage-in-libc-call"
66#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_ENABLED)
98 " --verbose | --quiet | --silent\n"
99 " --list-tests, --list\n"
100 " --reporter=human|tap\n"
101 " --output-file=<path>\n"
102 " --colour[=always|never|auto], --color[=...]\n"
103 " --use-colour=yes|no|auto, --use-color=...\n"
104 " --filter=<pattern>\n"
105 " Run only the matching names; repeat the option for each\n"
106 " nesting level: the first pattern applies to the suite\n"
107 " names, the second to the test case names, and each\n"
108 " further one to the nested test cases. The patterns use\n"
109 " '*' and '?', and '|' separates alternatives.\n";
122#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
123 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, top_suite_.name ());
127#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
138#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
139 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, top_suite_.name ());
151#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_CONSTRUCTORS_ENABLED)
152 trace::printf ("%s\n", __PRETTY_FUNCTION__);
169#pragma GCC diagnostic push
171#if defined(__clang__)
172#pragma clang diagnostic ignored "-Wunsafe-buffer-usage"
176#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
198 return add_top_suite (top_suite_name != nullptr ? top_suite_name : "");
218#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
219 trace::printf ("%s\n", __PRETTY_FUNCTION__);
221#if !(defined(MICRO_OS_PLUS_STARTUP_ENABLED) \
222 && defined(MICRO_OS_PLUS_DIAG_TRACE_ENABLED))
223#if defined(MICRO_OS_PLUS_DEBUG_ENABLED)
224 trace::printf ("argv[");
225 for (int i = 0; i < argc; ++i)
229 trace::printf (", ");
231 trace::printf ("'%s'", argv[i]);
275#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
276 trace::printf ("%s\n", __PRETTY_FUNCTION__);
281 fprintf (stderr, "error: test execution aborted\n");
313 = std::make_unique<detail::reporter_human> (console_options);
318 = std::make_unique<detail::reporter_tap> (console_options);
323 fprintf (stderr, "error: %s\n", error.c_str ());
326 reporter_->error_prefix (), error.c_str ());
332 "%sUse --help to list the options.\n",
343 "Usage: %s [options] [--] "
345 program, help_options);
369 "%sfailed to open output file '%s'\n",
387 ? "All available test cases:"
388 : "Matching test cases:");
422 const std::string_view requested_name{ top_suite_name.name () };
424#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
425 trace::printf ("%s\n", __PRETTY_FUNCTION__);
430 fprintf (stderr, "error: test execution aborted\n");
450 if (!requested_name.empty ())
467 const auto dot_pos = top_suite_name_view.rfind ('.');
468 if (dot_pos != std::string_view::npos)
470 top_suite_name_view = top_suite_name_view.substr (0, dot_pos);
520#pragma GCC diagnostic pop
540 const size_t separator = alternatives.find ('|');
545 if (separator == std::string_view::npos)
549 alternatives.remove_prefix (separator + 1);
601#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
602 trace::printf ("%s '%s'\n", __PRETTY_FUNCTION__, suite->name ());
631 std::string message{ "suite '" };
632 message.append (name);
633 message.append ("' added after run_suites() started, rejected");
663 fprintf (stderr, "error: %s\n", message.c_str ());
675 "%serror: %s\n", reporter_->comment_prefix (),
684 message, location != nullptr
699 "%serror: %s\n", reporter_->comment_prefix (),
732 started = started->started_next_)
734 if (started == &test_runner)
736 test_runner.reject_suite (suite.name (),
737 suite.located_name_.location ());
783 suite_ptr != nullptr; suite_ptr = suite_ptr->next_)
786 if (&suite_ptr->test_runner () != this)
791 suite_ptr->own_index_ = ++own_index;
808 totals_ += suite_ptr->totals ();
842#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
843 trace::printf ("%s\n", __PRETTY_FUNCTION__);
848 fprintf (stderr, "error: test execution aborted\n");
861 fprintf (stderr, "error: test runner already running\n");
888 test_cases, (test_cases == 1) ? "" : "s", suites,
889 (suites == 1) ? "" : "s");
897 fprintf (stderr, "error: the filters selected no test case\n");
900 "%serror: the filters selected no test case\n",
930 fprintf (stderr, "error: no test suites\n");
932 "%serror: no test suites\n",
937 const bool selected_nothing = !has_no_suites
940 if (selected_nothing)
942 fprintf (stderr, "error: the filters selected no test case\n");
944 "%serror: the filters selected no test case\n",
964#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
965 trace::printf ("%s -> %d\n", __PRETTY_FUNCTION__, exit_code_);
971#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
1031#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_TRACE_ENABLED)
1032 trace::printf ("%s\n", __PRETTY_FUNCTION__);
1042 reporter_->abort_session (sl, is_requirement);
1050 const unsigned long line = sl.line ();
1051 fprintf (stderr, "error: test execution aborted at %s:%lu\n",
1078#if defined(MICRO_OS_PLUS_MICRO_TEST_PLUS_DEPRECATED_ENABLED)
1115 suite_ptr != nullptr; suite_ptr = suite_ptr->next_)
1117 if (&suite_ptr->test_runner () == this)
Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.