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

thetic / mu.tiny / 24941405756

25 Apr 2026 09:45PM UTC coverage: 98.927% (+0.001%) from 98.926%
24941405756

Pull #91

github

web-flow
Merge 640495165 into 150ab4b90
Pull Request #91: replace multi-char single-dash flags with -- long options

92 of 92 new or added lines in 2 files covered. (100.0%)

2 existing lines in 2 files now uncovered.

5348 of 5406 relevant lines covered (98.93%)

3333.65 hits per line

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

99.22
/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
namespace {
18
String basename_from_path(const char* path)
74✔
19
{
20
  if ((path == nullptr) || (*path == 0)) {
74✔
21
    return "";
1✔
22
  }
23
  const char* base = path;
73✔
24
  for (const char* p = path; *p != 0; ++p) {
3,181✔
25
    if (*p == '/' || *p == '\\') {
3,108✔
26
      base = p + 1;
387✔
27
    }
28
  }
29
  return base;
73✔
30
}
31
} // namespace
32

33
int CommandLineRunner::run_all_tests(int argc, char** argv)
43✔
34
{
35
  return run_all_tests(argc, reinterpret_cast<const char* const*>(argv));
43✔
36
}
37

38
void CommandLineRunner::install_plugin(Plugin& plugin)
1✔
39
{
40
  Registry::get_current_registry()->install_plugin(&plugin);
1✔
41
}
1✔
42

43
int CommandLineRunner::run_all_tests(int argc, const char* const* argv)
43✔
44
{
45
  CommandLineRunner runner(argc, argv, Registry::get_current_registry());
43✔
46
  return runner.run_all_tests_main();
86✔
47
}
43✔
48

49
CommandLineRunner::CommandLineRunner(
74✔
50
    int argc,
51
    const char* const* argv,
52
    Registry* registry
53
)
74✔
54
  : registry_(registry)
74✔
55
  , program_name_(argc > 0 ? basename_from_path(argv[0]) : "")
74✔
56
{
57
  arguments_ = new CommandLineArguments(argc, argv);
74✔
58
}
74✔
59

60
CommandLineRunner::~CommandLineRunner()
74✔
61
{
62
  delete arguments_;
74✔
63
  delete output_;
74✔
64
}
74✔
65

66
int CommandLineRunner::run_all_tests_main()
74✔
67
{
68
  int test_result = 1;
74✔
69

70
  Plugin* const user_plugins = registry_->get_first_plugin();
74✔
71

72
  SetPointerPlugin set_pointer_plugin;
74✔
73
  JUnitOutputPlugin junit_plugin(program_name_);
74✔
74
  TapOutputPlugin tap_plugin;
74✔
75
  registry_->install_plugin(&set_pointer_plugin);
74✔
76
  registry_->install_plugin(&junit_plugin);
74✔
77
  registry_->install_plugin(&tap_plugin);
74✔
78

79
  if (parse_arguments(registry_->get_first_plugin())) {
74✔
80
    if (arguments_->need_help()) {
71✔
81
      output_->print(arguments_->help().c_str());
1✔
82
      test_result = 0;
1✔
83
    } else {
84
      test_result = run_all_tests();
70✔
85
    }
86
  }
87

88
  registry_->restore_plugins(user_plugins);
74✔
89
  return test_result;
74✔
90
}
74✔
91

92
void CommandLineRunner::initialize_test_run()
70✔
93
{
94
  registry_->set_group_filters(arguments_->get_group_filters());
70✔
95
  registry_->set_name_filters(arguments_->get_name_filters());
70✔
96

97
  if (arguments_->is_verbose()) {
70✔
98
    output_->verbose(Output::MutinyVerbosityLevel::verbose);
45✔
99
  }
100
  if (arguments_->is_very_verbose()) {
70✔
101
    output_->verbose(Output::MutinyVerbosityLevel::very_verbose);
12✔
102
  }
103
  if (arguments_->is_color()) {
70✔
104
    output_->color();
11✔
105
  }
106
  if (arguments_->is_run_skipped()) {
70✔
107
    registry_->set_run_skipped();
1✔
108
  }
109
  if (arguments_->is_crashing_on_fail()) {
70✔
UNCOV
110
    Shell::set_crash_on_fail();
×
111
  }
112

113
  Shell::set_rethrow_exceptions(arguments_->is_rethrowing_exceptions());
70✔
114
}
70✔
115

116
int CommandLineRunner::run_all_tests()
70✔
117
{
118
  initialize_test_run();
70✔
119
  unsigned int loop_count = 0;
70✔
120
  unsigned int failed_test_count = 0;
70✔
121
  unsigned int failed_execution_count = 0;
70✔
122
  auto repeat_count = arguments_->get_repeat_count();
70✔
123

124
  if (arguments_->is_listing_test_group_names()) {
70✔
125
    Result tr(*output_);
1✔
126
    registry_->list_test_group_names(tr);
1✔
127
    return 0;
1✔
128
  }
1✔
129

130
  if (arguments_->is_listing_test_group_and_case_names()) {
69✔
131
    Result tr(*output_);
1✔
132
    registry_->list_test_group_and_case_names(tr);
1✔
133
    return 0;
1✔
134
  }
1✔
135

136
  if (arguments_->is_listing_test_locations()) {
68✔
137
    Result tr(*output_);
2✔
138
    registry_->list_test_locations(tr);
2✔
139
    return 0;
2✔
140
  }
2✔
141

142
  if (arguments_->is_listing_ordered_test_locations()) {
66✔
143
    Result tr(*output_);
1✔
144
    registry_->list_ordered_test_locations(tr);
1✔
145
    return 0;
1✔
146
  }
1✔
147

148
  if (arguments_->is_listing_test_group_locations()) {
65✔
149
    Result tr(*output_);
1✔
150
    registry_->list_test_group_locations(tr);
1✔
151
    return 0;
1✔
152
  }
1✔
153

154
  if (arguments_->is_reversing()) {
64✔
155
    registry_->reverse_tests();
1✔
156
  }
157

158
  if (arguments_->is_shuffling()) {
64✔
159
    output_->print("Test order shuffling enabled with seed: ");
2✔
160
    output_->print(arguments_->get_shuffle_seed());
2✔
161
    output_->print("\n");
2✔
162
  }
163
  while (loop_count++ < repeat_count) {
128✔
164

165
    if (arguments_->is_shuffling()) {
64✔
166
      registry_->shuffle_tests(arguments_->get_shuffle_seed());
2✔
167
    }
168

169
    output_->print_test_run(loop_count, repeat_count);
64✔
170
    Result tr(*output_);
64✔
171
    registry_->run_all_tests(tr);
64✔
172
    failed_test_count += tr.get_failure_count();
64✔
173
    if (tr.is_failure()) {
64✔
174
      failed_execution_count++;
1✔
175
    }
176
  }
64✔
177
  return static_cast<int>(
64✔
178
      failed_test_count != 0 ? failed_test_count : failed_execution_count
179
  );
64✔
180
}
181

182
Output* CommandLineRunner::create_console_output()
44✔
183
{
184
  return new ConsoleOutput;
44✔
185
}
186

187
Output* CommandLineRunner::create_composite_output(
12✔
188
    Output* output_one,
189
    Output* output_two
190
)
191
{
192
  auto* composite = new CompositeOutput;
12✔
193
  composite->set_output_one(output_one);
12✔
194
  composite->set_output_two(output_two);
12✔
195
  return composite;
12✔
196
}
197

198
bool CommandLineRunner::parse_arguments(Plugin* plugin)
74✔
199
{
200
  if (!arguments_->parse(plugin)) {
74✔
201
    output_ = create_console_output();
3✔
202
    output_->print(arguments_->help().c_str());
3✔
203
    return false;
3✔
204
  }
205

206
  Output* plugin_output = registry_->get_first_plugin()->create_all_outputs();
71✔
207
  if (plugin_output != nullptr) {
71✔
208
    output_ = plugin_output;
13✔
209
    if ((arguments_->is_verbose() || arguments_->is_very_verbose()) &&
25✔
210
        plugin_output->needs_console_companion()) {
12✔
211
      output_ = create_composite_output(output_, create_console_output());
12✔
212
    }
213
  } else {
214
    output_ = create_console_output();
58✔
215
  }
216
  return true;
71✔
217
}
218

219
} // namespace test
220
} // namespace tiny
221
} // 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