MCPcopy Create free account
hub / github.com/RenderKit/oidn / makeCommandLineParser

Function makeCommandLineParser

external/catch.hpp:9693–9900  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9691namespace Catch {
9692
9693 clara::Parser makeCommandLineParser( ConfigData& config ) {
9694
9695 using namespace clara;
9696
9697 auto const setWarning = [&]( std::string const& warning ) {
9698 auto warningSet = [&]() {
9699 if( warning == "NoAssertions" )
9700 return WarnAbout::NoAssertions;
9701
9702 if ( warning == "NoTests" )
9703 return WarnAbout::NoTests;
9704
9705 return WarnAbout::Nothing;
9706 }();
9707
9708 if (warningSet == WarnAbout::Nothing)
9709 return ParserResult::runtimeError( "Unrecognised warning: '" + warning + "'" );
9710 config.warnings = static_cast<WarnAbout::What>( config.warnings | warningSet );
9711 return ParserResult::ok( ParseResultType::Matched );
9712 };
9713 auto const loadTestNamesFromFile = [&]( std::string const& filename ) {
9714 std::ifstream f( filename.c_str() );
9715 if( !f.is_open() )
9716 return ParserResult::runtimeError( "Unable to load input file: '" + filename + "'" );
9717
9718 std::string line;
9719 while( std::getline( f, line ) ) {
9720 line = trim(line);
9721 if( !line.empty() && !startsWith( line, '#' ) ) {
9722 if( !startsWith( line, '"' ) )
9723 line = '"' + line + '"';
9724 config.testsOrTags.push_back( line );
9725 config.testsOrTags.emplace_back( "," );
9726 }
9727 }
9728 //Remove comma in the end
9729 if(!config.testsOrTags.empty())
9730 config.testsOrTags.erase( config.testsOrTags.end()-1 );
9731
9732 return ParserResult::ok( ParseResultType::Matched );
9733 };
9734 auto const setTestOrder = [&]( std::string const& order ) {
9735 if( startsWith( "declared", order ) )
9736 config.runOrder = RunTests::InDeclarationOrder;
9737 else if( startsWith( "lexical", order ) )
9738 config.runOrder = RunTests::InLexicographicalOrder;
9739 else if( startsWith( "random", order ) )
9740 config.runOrder = RunTests::InRandomOrder;
9741 else
9742 return clara::ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" );
9743 return ParserResult::ok( ParseResultType::Matched );
9744 };
9745 auto const setRngSeed = [&]( std::string const& seed ) {
9746 if( seed != "time" )
9747 return clara::detail::convertInto( seed, config.rngSeed );
9748 config.rngSeed = static_cast<unsigned int>( std::time(nullptr) );
9749 return ParserResult::ok( ParseResultType::Matched );
9750 };

Callers 1

catch.hppFile · 0.85

Calls 12

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

Tested by

no test coverage detected