micro-test-plus 6.0.0
µTest++ Testing Framework
Loading...
Searching...
No Matches
runner-options.h
Go to the documentation of this file.
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
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
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// ----------------------------------------------------------------------------
runner_options(const runner_options &other)=default
Copy constructor.
std::size_t application_begin_
The index in arguments_ of the first argument left to the application.
bool has_unknown_option(void) const noexcept
Checks whether an unknown option was found while parsing the command line.
runner_options(runner_options &&other)=default
Move constructor.
runner_options(void)=default
Constructs the default options.
bool help
Whether to display the usage and the list of the options, instead of running the tests.
std::vector< std::string > errors_
The errors found while parsing the command line.
colour_mode colour
Whether the console output uses colours.
const std::vector< std::string > & errors(void) const noexcept
Returns the errors found while parsing the command line.
bool has_errors(void) const noexcept
Checks whether errors were found while parsing the command line.
std::vector< std::string > filter_patterns
The patterns that select the suites and the test cases to run, one per nesting level.
bool unknown_option_
Whether an unknown option was found.
runner_options & operator=(const runner_options &other)
Copy assignment operator.
std::string output_file_path
Path of the optional output file.
const std::vector< std::string > & arguments(void) const noexcept
Returns the complete command line, including argv[0], if any.
std::span< const std::string > application_arguments(void) const noexcept
Returns the arguments left to the application.
void add_error(std::string_view before, std::string_view value={}, std::string_view after={})
Records a command-line error.
bool list_tests
Whether the test cases are listed instead of run.
reporter_kind selected_reporter
The reporter that displays the results.
std::vector< std::string > arguments_
The complete command line, including argv[0], if any.
micro_test_plus::verbosity verbosity_level
The level of detail of the console output.
colour_mode
The use of colours in the console output.
verbosity
The verbosity levels for test reporting.
reporter_kind
The built-in reporters.
Primary namespace for the µTest++ testing framework.
C++ header file with inline implementations for the µTest++ runner options.