41 lines
1.4 KiB
C++
41 lines
1.4 KiB
C++
#include <Void/Testing/Runner.hpp>
|
|
|
|
#include <algorithm>
|
|
#include <array>
|
|
#include <iostream>
|
|
#include <string_view>
|
|
|
|
int main(int argc, char** argv) {
|
|
// Void parses its own options but ignores stray positional arguments.
|
|
constexpr std::array<std::string_view, 10> options_with_values{
|
|
"--filter", "--suite", "--reporter", "--output", "--tag",
|
|
"--log-file", "--selftest-child", "--seed", "--repeat", "--parallel",
|
|
};
|
|
for (int i = 1; i < argc; ++i) {
|
|
const std::string_view argument = argv[i];
|
|
if (!argument.starts_with('-')) {
|
|
std::cerr << "error: Unexpected positional argument '" << argument << "'\n";
|
|
return 2;
|
|
}
|
|
if (argument == "--tag" && (i + 1 == argc || argv[i + 1][0] == '\0')) {
|
|
std::cerr << "error: --tag requires a non-empty value\n";
|
|
return 2;
|
|
}
|
|
if (i + 1 < argc && std::ranges::contains(options_with_values, argument)) {
|
|
++i;
|
|
}
|
|
}
|
|
|
|
auto& runner = Void::Testing::Runner::instance();
|
|
auto config = runner.parse_args(argc, argv);
|
|
// An explicit match-all filter makes an empty registry fail on a default run.
|
|
if (config.filter_pattern.empty()) {
|
|
config.filter_pattern = ".*";
|
|
}
|
|
const auto result = runner.run(config);
|
|
if (!result.config_error.empty()) {
|
|
return 2;
|
|
}
|
|
return result.failed > 0 || result.crashed > 0 ? 1 : 0;
|
|
}
|