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

Function makeCommandLineParser

test/expected/catch.hpp:9636–9836  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9634namespace Catch {
9635
9636 clara::Parser makeCommandLineParser( ConfigData& config ) {
9637
9638 using namespace clara;
9639
9640 auto const setWarning = [&]( std::string const& warning ) {
9641 auto warningSet = [&]() {
9642 if( warning == "NoAssertions" )
9643 return WarnAbout::NoAssertions;
9644
9645 if ( warning == "NoTests" )
9646 return WarnAbout::NoTests;
9647
9648 return WarnAbout::Nothing;
9649 }();
9650
9651 if (warningSet == WarnAbout::Nothing)
9652 return ParserResult::runtimeError( "Unrecognised warning: '" + warning + "'" );
9653 config.warnings = static_cast<WarnAbout::What>( config.warnings | warningSet );
9654 return ParserResult::ok( ParseResultType::Matched );
9655 };
9656 auto const loadTestNamesFromFile = [&]( std::string const& filename ) {
9657 std::ifstream f( filename.c_str() );
9658 if( !f.is_open() )
9659 return ParserResult::runtimeError( "Unable to load input file: '" + filename + "'" );
9660
9661 std::string line;
9662 while( std::getline( f, line ) ) {
9663 line = trim(line);
9664 if( !line.empty() && !startsWith( line, '#' ) ) {
9665 if( !startsWith( line, '"' ) )
9666 line = '"' + line + '"';
9667 config.testsOrTags.push_back( line );
9668 config.testsOrTags.push_back( "," );
9669
9670 }
9671 }
9672 //Remove comma in the end
9673 if(!config.testsOrTags.empty())
9674 config.testsOrTags.erase( config.testsOrTags.end()-1 );
9675
9676 return ParserResult::ok( ParseResultType::Matched );
9677 };
9678 auto const setTestOrder = [&]( std::string const& order ) {
9679 if( startsWith( "declared", order ) )
9680 config.runOrder = RunTests::InDeclarationOrder;
9681 else if( startsWith( "lexical", order ) )
9682 config.runOrder = RunTests::InLexicographicalOrder;
9683 else if( startsWith( "random", order ) )
9684 config.runOrder = RunTests::InRandomOrder;
9685 else
9686 return clara::ParserResult::runtimeError( "Unrecognised ordering: '" + order + "'" );
9687 return ParserResult::ok( ParseResultType::Matched );
9688 };
9689 auto const setRngSeed = [&]( std::string const& seed ) {
9690 if( seed != "time" )
9691 return clara::detail::convertInto( seed, config.rngSeed );
9692 config.rngSeed = static_cast<unsigned int>( std::time(nullptr) );
9693 return ParserResult::ok( ParseResultType::Matched );

Callers 1

catch.hppFile · 0.85

Calls 14

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

Tested by

no test coverage detected