MCPcopy Create free account
hub / github.com/InteractiveComputerGraphics/TriangleMeshDistance / makeCommandLineParser

Function makeCommandLineParser

tests/catch.hpp:7591–7777  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

7589namespace Catch {
7590
7591 clara::Parser makeCommandLineParser( ConfigData& config ) {
7592
7593 using namespace clara;
7594
7595 auto const setWarning = [&]( std::string const& warning ) {
7596 auto warningSet = [&]() {
7597 if( warning == "NoAssertions" )
7598 return WarnAbout::NoAssertions;
7599
7600 if ( warning == "NoTests" )
7601 return WarnAbout::NoTests;
7602
7603 return WarnAbout::Nothing;
7604 }();
7605
7606 if (warningSet == WarnAbout::Nothing)
7607 return ParserResult::runtimeError( "Unrecognised warning: '" + warning + "'" );
7608 config.warnings = static_cast<WarnAbout::What>( config.warnings | warningSet );
7609 return ParserResult::ok( ParseResultType::Matched );
7610 };
7611 auto const loadTestNamesFromFile = [&]( std::string const& filename ) {
7612 std::ifstream f( filename.c_str() );
7613 if( !f.is_open() )
7614 return ParserResult::runtimeError( "Unable to load input file: '" + filename + "'" );
7615
7616 std::string line;
7617 while( std::getline( f, line ) ) {
7618 line = trim(line);
7619 if( !line.empty() && !startsWith( line, '#' ) ) {
7620 if( !startsWith( line, '"' ) )
7621 line = '"' + line + '"';
7622 config.testsOrTags.push_back( line + ',' );
7623 }
7624 }
7625 return ParserResult::ok( ParseResultType::Matched );
7626 };
7627 auto const setTestOrder = [&]( std::string const& order ) {
7628 if( startsWith( "declared", order ) )
7629 config.runOrder = RunTests::InDeclarationOrder;
7630 else if( startsWith( "lexical", order ) )
7631 config.runOrder = RunTests::InLexicographicalOrder;
7632 else if( startsWith( "random", order ) )
7633 config.runOrder = RunTests::InRandomOrder;
7634 else
7635 return clara::ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" );
7636 return ParserResult::ok( ParseResultType::Matched );
7637 };
7638 auto const setRngSeed = [&]( std::string const& seed ) {
7639 if( seed != "time" )
7640 return clara::detail::convertInto( seed, config.rngSeed );
7641 config.rngSeed = static_cast<unsigned int>( std::time(nullptr) );
7642 return ParserResult::ok( ParseResultType::Matched );
7643 };
7644 auto const setColourUsage = [&]( std::string const& useColour ) {
7645 auto mode = toLower( useColour );
7646
7647 if( mode == "yes" )
7648 config.useColour = UseColour::Yes;

Callers 1

catch.hppFile · 0.85

Calls 12

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
findMethod · 0.80
emptyMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected