MCPcopy Create free account
hub / github.com/ObEngine/ObEngine / makeCommandLineParser

Function makeCommandLineParser

extlibs/catch/include/catch/catch.hpp:9385–9579  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9383namespace Catch {
9384
9385 clara::Parser makeCommandLineParser( ConfigData& config ) {
9386
9387 using namespace clara;
9388
9389 auto const setWarning = [&]( std::string const& warning ) {
9390 auto warningSet = [&]() {
9391 if( warning == "NoAssertions" )
9392 return WarnAbout::NoAssertions;
9393
9394 if ( warning == "NoTests" )
9395 return WarnAbout::NoTests;
9396
9397 return WarnAbout::Nothing;
9398 }();
9399
9400 if (warningSet == WarnAbout::Nothing)
9401 return ParserResult::runtimeError( "Unrecognised warning: '" + warning + "'" );
9402 config.warnings = static_cast<WarnAbout::What>( config.warnings | warningSet );
9403 return ParserResult::ok( ParseResultType::Matched );
9404 };
9405 auto const loadTestNamesFromFile = [&]( std::string const& filename ) {
9406 std::ifstream f( filename.c_str() );
9407 if( !f.is_open() )
9408 return ParserResult::runtimeError( "Unable to load input file: '" + filename + "'" );
9409
9410 std::string line;
9411 while( std::getline( f, line ) ) {
9412 line = trim(line);
9413 if( !line.empty() && !startsWith( line, '#' ) ) {
9414 if( !startsWith( line, '"' ) )
9415 line = '"' + line + '"';
9416 config.testsOrTags.push_back( line + ',' );
9417 }
9418 }
9419 return ParserResult::ok( ParseResultType::Matched );
9420 };
9421 auto const setTestOrder = [&]( std::string const& order ) {
9422 if( startsWith( "declared", order ) )
9423 config.runOrder = RunTests::InDeclarationOrder;
9424 else if( startsWith( "lexical", order ) )
9425 config.runOrder = RunTests::InLexicographicalOrder;
9426 else if( startsWith( "random", order ) )
9427 config.runOrder = RunTests::InRandomOrder;
9428 else
9429 return clara::ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" );
9430 return ParserResult::ok( ParseResultType::Matched );
9431 };
9432 auto const setRngSeed = [&]( std::string const& seed ) {
9433 if( seed != "time" )
9434 return clara::detail::convertInto( seed, config.rngSeed );
9435 config.rngSeed = static_cast<unsigned int>( std::time(nullptr) );
9436 return ParserResult::ok( ParseResultType::Matched );
9437 };
9438 auto const setColourUsage = [&]( std::string const& useColour ) {
9439 auto mode = toLower( useColour );
9440
9441 if( mode == "yes" )
9442 config.useColour = UseColour::Yes;

Callers 1

catch.hppFile · 0.85

Calls 13

trimFunction · 0.85
convertIntoFunction · 0.85
toLowerFunction · 0.85
ExeNameClass · 0.85
HelpClass · 0.85
OptClass · 0.85
ArgClass · 0.85
startsWithFunction · 0.70
c_strMethod · 0.45
emptyMethod · 0.45
push_backMethod · 0.45
findMethod · 0.45

Tested by

no test coverage detected