MCPcopy Create free account
hub / github.com/apache/trafficserver / makeCommandLineParser

Function makeCommandLineParser

lib/catch2/catch.hpp:9704–9911  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 1

catch.hppFile · 0.85

Calls 15

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

Tested by

no test coverage detected