MCPcopy Create free account
hub / github.com/CodingGay/BlackDex / makeCommandLineParser

Function makeCommandLineParser

Bcore/src/main/cpp/Dobby/tests/catch.hpp:6283–6408  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

6281namespace Catch {
6282
6283clara::Parser makeCommandLineParser(ConfigData &config) {
6284
6285 using namespace clara;
6286
6287 auto const setWarning = [&](std::string const &warning) {
6288 auto warningSet = [&]() {
6289 if (warning == "NoAssertions")
6290 return WarnAbout::NoAssertions;
6291
6292 if (warning == "NoTests")
6293 return WarnAbout::NoTests;
6294
6295 return WarnAbout::Nothing;
6296 }();
6297
6298 if (warningSet == WarnAbout::Nothing)
6299 return ParserResult::runtimeError("Unrecognised warning: '" + warning + "'");
6300 config.warnings = static_cast<WarnAbout::What>(config.warnings | warningSet);
6301 return ParserResult::ok(ParseResultType::Matched);
6302 };
6303 auto const loadTestNamesFromFile = [&](std::string const &filename) {
6304 std::ifstream f(filename.c_str());
6305 if (!f.is_open())
6306 return ParserResult::runtimeError("Unable to load input file: '" + filename + "'");
6307
6308 std::string line;
6309 while (std::getline(f, line)) {
6310 line = trim(line);
6311 if (!line.empty() && !startsWith(line, '#')) {
6312 if (!startsWith(line, '"'))
6313 line = '"' + line + '"';
6314 config.testsOrTags.push_back(line + ',');
6315 }
6316 }
6317 return ParserResult::ok(ParseResultType::Matched);
6318 };
6319 auto const setTestOrder = [&](std::string const &order) {
6320 if (startsWith("declared", order))
6321 config.runOrder = RunTests::InDeclarationOrder;
6322 else if (startsWith("lexical", order))
6323 config.runOrder = RunTests::InLexicographicalOrder;
6324 else if (startsWith("random", order))
6325 config.runOrder = RunTests::InRandomOrder;
6326 else
6327 return clara::ParserResult::runtimeError("Unrecognised ordering: '" + order + "'");
6328 return ParserResult::ok(ParseResultType::Matched);
6329 };
6330 auto const setRngSeed = [&](std::string const &seed) {
6331 if (seed != "time")
6332 return clara::detail::convertInto(seed, config.rngSeed);
6333 config.rngSeed = static_cast<unsigned int>(std::time(nullptr));
6334 return ParserResult::ok(ParseResultType::Matched);
6335 };
6336 auto const setColourUsage = [&](std::string const &useColour) {
6337 auto mode = toLower(useColour);
6338
6339 if (mode == "yes")
6340 config.useColour = UseColour::Yes;

Callers 1

SessionMethod · 0.85

Calls 10

trimFunction · 0.85
startsWithFunction · 0.85
convertIntoFunction · 0.85
toLowerFunction · 0.85
ExeNameClass · 0.85
HelpClass · 0.85
OptClass · 0.85
ArgClass · 0.85
c_strMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected