• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

thetic / mu.tiny / 24642649742

20 Apr 2026 12:16AM UTC coverage: 98.89% (+0.01%) from 98.879%
24642649742

Pull #84

github

web-flow
Merge 7551eb0f3 into a2dfbd6ba
Pull Request #84: apply clang-tidy fixes

625 of 626 new or added lines in 45 files covered. (99.84%)

2 existing lines in 2 files now uncovered.

5254 of 5313 relevant lines covered (98.89%)

3352.89 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

99.14
/src/test/CommandLineRunner.cpp
1
#include "mu/tiny/test/CommandLineRunner.hpp"
2

3
#include "mu/tiny/test/CompositeOutput.hpp"
4
#include "mu/tiny/test/ConsoleOutput.hpp"
5
#include "mu/tiny/test/JUnitOutputPlugin.hpp"
6
#include "mu/tiny/test/Output.hpp"
7
#include "mu/tiny/test/Registry.hpp"
8
#include "mu/tiny/test/Result.hpp"
9
#include "mu/tiny/test/SetPointerPlugin.hpp"
10
#include "mu/tiny/test/Shell.hpp"
11
#include "mu/tiny/test/TapOutputPlugin.hpp"
12

13
namespace mu {
14
namespace tiny {
15
namespace test {
16

17
int CommandLineRunner::run_all_tests(int argc, char** argv)
43✔
18
{
19
  return run_all_tests(argc, reinterpret_cast<const char* const*>(argv));
43✔
20
}
21

22
int CommandLineRunner::run_all_tests(int argc, const char* const* argv)
43✔
23
{
24
  CommandLineRunner runner(argc, argv, Registry::get_current_registry());
43✔
25
  return runner.run_all_tests_main();
86✔
26
}
43✔
27

28
CommandLineRunner::CommandLineRunner(
72✔
29
    int argc,
30
    const char* const* argv,
31
    Registry* registry
32
)
72✔
33
  : registry_(registry)
72✔
34
{
35
  arguments_ = new CommandLineArguments(argc, argv);
72✔
36
}
72✔
37

38
CommandLineRunner::~CommandLineRunner()
72✔
39
{
40
  delete arguments_;
72✔
41
  delete output_;
72✔
42
}
72✔
43

44
int CommandLineRunner::run_all_tests_main()
72✔
45
{
46
  int test_result = 1;
72✔
47

48
  SetPointerPlugin set_pointer_plugin;
72✔
49
  JUnitOutputPlugin junit_plugin;
72✔
50
  TapOutputPlugin tap_plugin;
72✔
51
  registry_->install_plugin(&set_pointer_plugin);
72✔
52
  registry_->install_plugin(&junit_plugin);
72✔
53
  registry_->install_plugin(&tap_plugin);
72✔
54

55
  if (parse_arguments(registry_->get_first_plugin())) {
72✔
56
    if (arguments_->need_help()) {
69✔
57
      output_->print(arguments_->help().c_str());
1✔
58
      test_result = 0;
1✔
59
    } else {
60
      test_result = run_all_tests();
68✔
61
    }
62
  }
63

64
  registry_->remove_plugin_by_name(tap_plugin.name);
72✔
65
  registry_->remove_plugin_by_name(junit_plugin.name);
72✔
66
  registry_->remove_plugin_by_name(set_pointer_plugin.name);
72✔
67
  return test_result;
72✔
68
}
72✔
69

70
void CommandLineRunner::initialize_test_run()
68✔
71
{
72
  registry_->set_group_filters(arguments_->get_group_filters());
68✔
73
  registry_->set_name_filters(arguments_->get_name_filters());
68✔
74

75
  if (arguments_->is_verbose()) {
68✔
76
    output_->verbose(Output::MutinyVerbosityLevel::verbose);
45✔
77
  }
78
  if (arguments_->is_very_verbose()) {
68✔
79
    output_->verbose(Output::MutinyVerbosityLevel::very_verbose);
11✔
80
  }
81
  if (arguments_->is_color()) {
68✔
82
    output_->color();
10✔
83
  }
84
  if (arguments_->is_run_ignored()) {
68✔
85
    registry_->set_run_ignored();
1✔
86
  }
87
  if (arguments_->is_crashing_on_fail()) {
68✔
UNCOV
88
    Shell::set_crash_on_fail();
×
89
  }
90

91
  Shell::set_rethrow_exceptions(arguments_->is_rethrowing_exceptions());
68✔
92
}
68✔
93

94
int CommandLineRunner::run_all_tests()
68✔
95
{
96
  initialize_test_run();
68✔
97
  size_t loop_count = 0;
68✔
98
  size_t failed_test_count = 0;
68✔
99
  size_t failed_execution_count = 0;
68✔
100
  size_t repeat_count = arguments_->get_repeat_count();
68✔
101

102
  if (arguments_->is_listing_test_group_names()) {
68✔
103
    Result tr(*output_);
1✔
104
    registry_->list_test_group_names(tr);
1✔
105
    return 0;
1✔
106
  }
1✔
107

108
  if (arguments_->is_listing_test_group_and_case_names()) {
67✔
109
    Result tr(*output_);
1✔
110
    registry_->list_test_group_and_case_names(tr);
1✔
111
    return 0;
1✔
112
  }
1✔
113

114
  if (arguments_->is_listing_test_locations()) {
66✔
115
    Result tr(*output_);
2✔
116
    registry_->list_test_locations(tr);
2✔
117
    return 0;
2✔
118
  }
2✔
119

120
  if (arguments_->is_listing_ordered_test_locations()) {
64✔
121
    Result tr(*output_);
1✔
122
    registry_->list_ordered_test_locations(tr);
1✔
123
    return 0;
1✔
124
  }
1✔
125

126
  if (arguments_->is_listing_test_group_locations()) {
63✔
127
    Result tr(*output_);
1✔
128
    registry_->list_test_group_locations(tr);
1✔
129
    return 0;
1✔
130
  }
1✔
131

132
  if (arguments_->is_reversing()) {
62✔
133
    registry_->reverse_tests();
1✔
134
  }
135

136
  if (arguments_->is_shuffling()) {
62✔
137
    output_->print("Test order shuffling enabled with seed: ");
2✔
138
    output_->print(arguments_->get_shuffle_seed());
2✔
139
    output_->print("\n");
2✔
140
  }
141
  while (loop_count++ < repeat_count) {
124✔
142

143
    if (arguments_->is_shuffling()) {
62✔
144
      registry_->shuffle_tests(arguments_->get_shuffle_seed());
2✔
145
    }
146

147
    output_->print_test_run(loop_count, repeat_count);
62✔
148
    Result tr(*output_);
62✔
149
    registry_->run_all_tests(tr);
62✔
150
    failed_test_count += tr.get_failure_count();
62✔
151
    if (tr.is_failure()) {
62✔
152
      failed_execution_count++;
1✔
153
    }
154
  }
62✔
155
  return static_cast<int>(
156
      failed_test_count != 0 ? failed_test_count : failed_execution_count
157
  );
62✔
158
}
159

160
Output* CommandLineRunner::create_console_output()
44✔
161
{
162
  return new ConsoleOutput;
44✔
163
}
164

165
Output* CommandLineRunner::create_composite_output(
11✔
166
    Output* output_one,
167
    Output* output_two
168
)
169
{
170
  auto* composite = new CompositeOutput;
11✔
171
  composite->set_output_one(output_one);
11✔
172
  composite->set_output_two(output_two);
11✔
173
  return composite;
11✔
174
}
175

176
bool CommandLineRunner::parse_arguments(Plugin* plugin)
72✔
177
{
178
  if (!arguments_->parse(plugin)) {
72✔
179
    output_ = create_console_output();
3✔
180
    output_->print(arguments_->help().c_str());
3✔
181
    return false;
3✔
182
  }
183

184
  Output* plugin_output = registry_->get_first_plugin()->create_all_outputs();
69✔
185
  if (plugin_output != nullptr) {
69✔
186
    output_ = plugin_output;
11✔
187
    if ((arguments_->is_verbose() || arguments_->is_very_verbose()) &&
22✔
188
        plugin_output->needs_console_companion()) {
11✔
189
      output_ = create_composite_output(output_, create_console_output());
11✔
190
    }
191
  } else {
192
    output_ = create_console_output();
58✔
193
  }
194
  return true;
69✔
195
}
196

197
} // namespace test
198
} // namespace tiny
199
} // namespace mu
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc