Skip to main content

runner-options.h File

C++ header file with declarations for the µTest++ runner options. More...

Included Headers​

#include <span> #include <string> #include <string_view> #include <utility> #include <vector> #include "inlines/runner-options-inlines.h"

Namespaces Index​

namespacemicro_os_plus

The primary namespace for the µOS++ framework. More...

namespacemicro_test_plus

Primary namespace for the µTest++ testing framework. More...

Classes Index​

classrunner_options

The configuration of a test session, and its command-line parser. More...

Enumerations Index​

enum classcolour_mode { ... }

The use of colours in the console output. More...

enum classreporter_kind { ... }

The built-in reporters. More...

enum classverbosity { ... }

The verbosity levels for test reporting. More...

Description​

C++ header file with declarations for the µTest++ runner options.

This header provides the runner_options class, which holds the configuration of a test session (the reporter, the verbosity, the output file, the use of colours, the filter, and the listing of the test cases) and parses it from the command line, together with the reporter_kind, verbosity, and colour_mode enumerations used by its members.

The options are usually parsed from the command line by the constructor taking the main() arguments, called by runner::initialise (argc, argv); the applications without a command line, such as the embedded ones without semihosting arguments, can set them directly and pass them to runner::initialise (options).

All definitions reside within the micro_os_plus::micro_test_plus namespace.

This file is included by micro-os-plus/micro-test-plus.h, which is the header that the applications include.

File Listing​

The file content with the documentation metadata removed is:

1/*
2 * This file is part of the µOS++ project (https://micro-os-plus.github.io/).
3 * Copyright (c) 2021-2026 Liviu Ionescu. All rights reserved.
4 *
5 * Permission to use, copy, modify, and/or distribute this software for any
6 * purpose is hereby granted, under the terms of the MIT license.
7 *
8 * If a copy of the license was not distributed with this file, it can be
9 * obtained from https://opensource.org/licenses/mit.
10 */
11
12// ----------------------------------------------------------------------------
13
39
40#ifndef MICRO_OS_PLUS_MICRO_TEST_PLUS_RUNNER_OPTIONS_H_
41#define MICRO_OS_PLUS_MICRO_TEST_PLUS_RUNNER_OPTIONS_H_
42
43// ----------------------------------------------------------------------------
44
45#if defined(__cplusplus)
46
47// ----------------------------------------------------------------------------
48
49#if __has_include("micro-os-plus/project-config.h")
50#include "micro-os-plus/project-config.h"
51#endif // __has_include("micro-os-plus/project-config.h")
52
53#if __has_include("micro-os-plus/micro-test-plus-defines.h")
54#include "micro-os-plus/micro-test-plus-defines.h"
55#endif // __has_include("micro-os-plus/micro-test-plus-defines.h")
56
57#include <span>
58#include <string>
59#include <string_view>
60#include <utility>
61#include <vector>
62
63// ----------------------------------------------------------------------------
64
65#if defined(__GNUC__)
66#pragma GCC diagnostic push
67
68#pragma GCC diagnostic ignored "-Wpadded"
69#if defined(__clang__)
70#pragma clang diagnostic ignored "-Wc++98-compat"
71#endif // defined(__clang__)
72#endif // defined(__GNUC__)
73
74// ============================================================================
75
77{
78 // --------------------------------------------------------------------------
79
100 enum class verbosity
101 {
102 silent = 0,
103 quiet = 1,
107 normal = 2,
113 };
114
127 enum class reporter_kind
128 {
131 };
132
152 enum class colour_mode
153 {
162 };
163
164 // ==========================================================================
165
218 {
219 public:
228 runner_options (void) = default;
229
266 explicit runner_options (int argc, char* argv[]);
267
280 runner_options (const runner_options& other) = default;
281
293 runner_options (runner_options&& other) = default;
294
313 operator=(const runner_options& other);
314
328 = default;
329
336 ~runner_options () = default;
337
346
356 };
357
368 std::string output_file_path{};
369
390
418 std::vector<std::string> filter_patterns{};
419
455 bool list_tests{ false };
456
471 bool help{ false };
472
488 [[nodiscard]] bool
489 has_errors (void) const noexcept;
490
505 [[nodiscard]] bool
506 has_unknown_option (void) const noexcept;
507
523 [[nodiscard]] const std::vector<std::string>&
524 errors (void) const noexcept;
525
549 [[nodiscard]] const std::vector<std::string>&
550 arguments (void) const noexcept;
551
571 [[nodiscard]] std::span<const std::string>
572 application_arguments (void) const noexcept;
573
574 private:
589 void
590 add_error (std::string_view before, std::string_view value = {},
591 std::string_view after = {});
592
600 std::vector<std::string> errors_{};
601
609 bool unknown_option_{ false };
610
619 std::vector<std::string> arguments_{};
620
629 std::size_t application_begin_{ 0 };
630 };
631
632 // --------------------------------------------------------------------------
633} // namespace micro_os_plus::micro_test_plus
634
635#if defined(__GNUC__)
636#pragma GCC diagnostic pop
637#endif // defined(__GNUC__)
638
639// ----------------------------------------------------------------------------
640
641#endif // defined(__cplusplus)
642
643// ============================================================================
644// Templates, inlines & constexpr implementations.
645
647
648// ----------------------------------------------------------------------------
649
650#endif // MICRO_OS_PLUS_MICRO_TEST_PLUS_RUNNER_OPTIONS_H_
651
652// ----------------------------------------------------------------------------

Generated via doxygen2docusaurus 2.2.8 by Doxygen 1.18.0.