Testing: add --fail-fast for sequential runs
This commit is contained in:
1 parent
28e253b49c
commit
4c0ebc76be
2 files changed
+15
-1
No files matched your search
@@ -96,6 +96,7 @@ namespace Void::Testing
|
|||||||
bool shuffle{false};
|
bool shuffle{false};
|
||||||
bool show_help{false};
|
bool show_help{false};
|
||||||
bool allow_empty{false};
|
bool allow_empty{false};
|
||||||
|
bool fail_fast{false};
|
||||||
unsigned repeat{1};
|
unsigned repeat{1};
|
||||||
unsigned random_seed{0};
|
unsigned random_seed{0};
|
||||||
unsigned parallel_threads{0}; // 0 = sequential
|
unsigned parallel_threads{0}; // 0 = sequential
|
||||||
|
|||||||
+14
-1
@@ -199,6 +199,8 @@ namespace Void::Testing
|
|||||||
config.no_color = true;
|
config.no_color = true;
|
||||||
} else if (arg == "--allow-empty") {
|
} else if (arg == "--allow-empty") {
|
||||||
config.allow_empty = true;
|
config.allow_empty = true;
|
||||||
|
} else if (arg == "--fail-fast") {
|
||||||
|
config.fail_fast = true;
|
||||||
} else if (arg == "--shuffle") {
|
} else if (arg == "--shuffle") {
|
||||||
config.shuffle = true;
|
config.shuffle = true;
|
||||||
std::random_device rd;
|
std::random_device rd;
|
||||||
@@ -546,6 +548,8 @@ namespace Void::Testing
|
|||||||
<< Void::Testing::Detail::Color::apply(dim, "Disable colored console output") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Disable colored console output") << "\n"
|
||||||
<< " " << opt("--allow-empty")
|
<< " " << opt("--allow-empty")
|
||||||
<< Void::Testing::Detail::Color::apply(dim, "Do not fail when selection matches zero tests") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Do not fail when selection matches zero tests") << "\n"
|
||||||
|
<< " " << opt("--fail-fast")
|
||||||
|
<< Void::Testing::Detail::Color::apply(dim, "Stop after the first failing test (sequential runs)") << "\n"
|
||||||
<< " " << opt("--help")
|
<< " " << opt("--help")
|
||||||
<< Void::Testing::Detail::Color::apply(dim, "Show this help message") << "\n"
|
<< Void::Testing::Detail::Color::apply(dim, "Show this help message") << "\n"
|
||||||
<< "\n"
|
<< "\n"
|
||||||
@@ -811,9 +815,13 @@ namespace Void::Testing
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
for (unsigned rep = 0; rep < config.repeat; ++rep) {
|
bool stop_run = false;
|
||||||
|
for (unsigned rep = 0; rep < config.repeat && !stop_run; ++rep) {
|
||||||
std::string current_suite;
|
std::string current_suite;
|
||||||
for (auto& test : tests) {
|
for (auto& test : tests) {
|
||||||
|
if (stop_run) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
auto& suite = suite_results[suite_index[test.suite]];
|
auto& suite = suite_results[suite_index[test.suite]];
|
||||||
// Emit suite header only when the suite name changes.
|
// Emit suite header only when the suite name changes.
|
||||||
if (test.suite != current_suite) {
|
if (test.suite != current_suite) {
|
||||||
@@ -834,6 +842,11 @@ namespace Void::Testing
|
|||||||
}
|
}
|
||||||
reporter->on_test_start(test);
|
reporter->on_test_start(test);
|
||||||
auto result = execute_test(test);
|
auto result = execute_test(test);
|
||||||
|
if (config.fail_fast &&
|
||||||
|
(result.state == TestState::Failed ||
|
||||||
|
result.state == TestState::Crashed)) {
|
||||||
|
stop_run = true;
|
||||||
|
}
|
||||||
reporter->on_test_end(result);
|
reporter->on_test_end(result);
|
||||||
log_result(result, std::format("{}.{}", result.suite,
|
log_result(result, std::format("{}.{}", result.suite,
|
||||||
result.name));
|
result.name));
|
||||||
|
|||||||
Reference in new issue
Block a user