Files
spark/src/lib/testing/catch_test_runner.cpp
T

37 lines
1.0 KiB
C++

#define CATCH_CONFIG_RUNNER
#include "catch_test_runner.h"
#include "lib/config/config.h"
#include "lib/config/protos/logging.pb.h"
#include "lib/logging/logging.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/is_unittest_environment.h"
#include <catch2/catch.hpp>
namespace bts {
int run_tests(int argc, char **argv) {
std::vector<std::string> v;
for (int i = 2; i < argc; i++)
v.emplace_back(argv[i]);
return run_tests(v);
}
int run_tests(std::vector<std::string> const &args) {
utils::internal::force_unittest_environment();
auto cfg = config::get<config::Logging>();
cfg.mutable_console()->set_default_level("Fatal");
log::configure_logging(cfg);
bts_assert(args.size() < 100);
char const *argv[100];
argv[0] = "test"; // the cmd processor takes the first arg away
for (size_t i = 0; i < args.size(); i++)
argv[i + 1] = args[i].c_str();
int result = Catch::Session().run(args.size() + 1, argv); // NOLINT
return (result < 0xff ? result : 0xff);
}
} // namespace bts