mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-03 21:49:32 +01:00 
			
		
		
		
	Tweaked some option names and added verbosity
This commit is contained in:
		@@ -687,21 +687,26 @@ struct Config {
 | 
				
			|||||||
    Config()
 | 
					    Config()
 | 
				
			||||||
    :   listTests( false ),
 | 
					    :   listTests( false ),
 | 
				
			||||||
        listTags( false ),
 | 
					        listTags( false ),
 | 
				
			||||||
        showPassingTests( false ),
 | 
					        showSuccessfulTests( false ),
 | 
				
			||||||
        breakIntoDebugger( false ),
 | 
					        breakIntoDebugger( false ),
 | 
				
			||||||
        noThrow( false ),
 | 
					        noThrow( false ),
 | 
				
			||||||
        showHelp( false ),
 | 
					        showHelp( false ),
 | 
				
			||||||
        abortAfter( 0 )
 | 
					        abortAfter( 0 ),
 | 
				
			||||||
 | 
					        verbosity( Normal )
 | 
				
			||||||
    {}
 | 
					    {}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    bool listTests;
 | 
					    bool listTests;
 | 
				
			||||||
    bool listTags;
 | 
					    bool listTags;
 | 
				
			||||||
    bool showPassingTests;
 | 
					    bool listReporters;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					    bool showSuccessfulTests;
 | 
				
			||||||
    bool breakIntoDebugger;
 | 
					    bool breakIntoDebugger;
 | 
				
			||||||
    bool noThrow;
 | 
					    bool noThrow;
 | 
				
			||||||
    bool showHelp;
 | 
					    bool showHelp;
 | 
				
			||||||
    
 | 
					
 | 
				
			||||||
    int abortAfter;
 | 
					    int abortAfter;
 | 
				
			||||||
 | 
					    enum Verbosity { NoOutput = 0, Quiet, Normal };
 | 
				
			||||||
 | 
					    Verbosity verbosity;
 | 
				
			||||||
    std::string reporterName;
 | 
					    std::string reporterName;
 | 
				
			||||||
    std::string fileName;
 | 
					    std::string fileName;
 | 
				
			||||||
    std::string suiteName;
 | 
					    std::string suiteName;
 | 
				
			||||||
@@ -714,6 +719,7 @@ inline void abortAfterFirst( Config& config ) { config.abortAfter = 1; }
 | 
				
			|||||||
inline void abortAfterX( Config& config, int x ) { config.abortAfter = x; }
 | 
					inline void abortAfterX( Config& config, int x ) { config.abortAfter = x; }
 | 
				
			||||||
inline void addWarning( Config& config, std::string const& _warning ) { config.warnings.push_back( _warning ); }
 | 
					inline void addWarning( Config& config, std::string const& _warning ) { config.warnings.push_back( _warning ); }
 | 
				
			||||||
inline void addTestOrTags( Config& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); }    
 | 
					inline void addTestOrTags( Config& config, std::string const& _testSpec ) { config.testsOrTags.push_back( _testSpec ); }    
 | 
				
			||||||
 | 
					inline void setVerbosity( Config& config, int level ) { config.verbosity = (Config::Verbosity)level; }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					
 | 
				
			||||||
SCENARIO( "New Catch commandline interface", "[cli]" ) {
 | 
					SCENARIO( "New Catch commandline interface", "[cli]" ) {
 | 
				
			||||||
@@ -730,17 +736,21 @@ SCENARIO( "New Catch commandline interface", "[cli]" ) {
 | 
				
			|||||||
        cli.bind( &Config::listTests )
 | 
					        cli.bind( &Config::listTests )
 | 
				
			||||||
            .describe( "list all (or matching) test cases" )
 | 
					            .describe( "list all (or matching) test cases" )
 | 
				
			||||||
            .shortOpt( "l")
 | 
					            .shortOpt( "l")
 | 
				
			||||||
            .longOpt( "list" );
 | 
					            .longOpt( "list-tests" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cli.bind( &Config::listTags )
 | 
					        cli.bind( &Config::listTags )
 | 
				
			||||||
            .describe( "list all (or matching) tags" )
 | 
					            .describe( "list all (or matching) tags" )
 | 
				
			||||||
            .shortOpt( "t")
 | 
					            .shortOpt( "t")
 | 
				
			||||||
            .longOpt( "tags" );
 | 
					            .longOpt( "list-tags" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cli.bind( &Config::showPassingTests )
 | 
					        cli.bind( &Config::listTags )
 | 
				
			||||||
            .describe( "show passing test output" )
 | 
					            .describe( "list all reporters" )
 | 
				
			||||||
            .shortOpt( "p")
 | 
					            .longOpt( "list-reporters" );
 | 
				
			||||||
            .longOpt( "passing" );
 | 
					
 | 
				
			||||||
 | 
					        cli.bind( &Config::showSuccessfulTests )
 | 
				
			||||||
 | 
					            .describe( "include successful tests in output" )
 | 
				
			||||||
 | 
					            .shortOpt( "s")
 | 
				
			||||||
 | 
					            .longOpt( "success" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cli.bind( &Config::breakIntoDebugger )
 | 
					        cli.bind( &Config::breakIntoDebugger )
 | 
				
			||||||
            .describe( "break into debugger on failure" )
 | 
					            .describe( "break into debugger on failure" )
 | 
				
			||||||
@@ -782,11 +792,17 @@ SCENARIO( "New Catch commandline interface", "[cli]" ) {
 | 
				
			|||||||
            .argName( "number of failures" );
 | 
					            .argName( "number of failures" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cli.bind( &addWarning )
 | 
					        cli.bind( &addWarning )
 | 
				
			||||||
            .describe( "enables warnings" )
 | 
					            .describe( "enable warnings" )
 | 
				
			||||||
            .shortOpt( "w")
 | 
					            .shortOpt( "w")
 | 
				
			||||||
            .longOpt( "warn" )
 | 
					            .longOpt( "warn" )
 | 
				
			||||||
            .argName( "warning name" );
 | 
					            .argName( "warning name" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					        cli.bind( &setVerbosity )
 | 
				
			||||||
 | 
					            .describe( "level of verbosity (0=no output)" )
 | 
				
			||||||
 | 
					            .shortOpt( "v")
 | 
				
			||||||
 | 
					            .longOpt( "verbosity" )
 | 
				
			||||||
 | 
					            .argName( "level" );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
        cli.bind( &addTestOrTags )
 | 
					        cli.bind( &addTestOrTags )
 | 
				
			||||||
            .describe( "which test or tests to use" )
 | 
					            .describe( "which test or tests to use" )
 | 
				
			||||||
            .argName( "test name, pattern or tags" );
 | 
					            .argName( "test name, pattern or tags" );
 | 
				
			||||||
@@ -799,15 +815,15 @@ SCENARIO( "New Catch commandline interface", "[cli]" ) {
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
        WHEN( "Multiple flags are combined" ) {
 | 
					        WHEN( "Multiple flags are combined" ) {
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            CHECK_FALSE( config.showPassingTests );
 | 
					            CHECK_FALSE( config.showSuccessfulTests );
 | 
				
			||||||
            CHECK_FALSE( config.noThrow );
 | 
					            CHECK_FALSE( config.noThrow );
 | 
				
			||||||
            CHECK_FALSE( config.breakIntoDebugger );
 | 
					            CHECK_FALSE( config.breakIntoDebugger );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
            const char* argv[] = { "test", "-peb" };
 | 
					            const char* argv[] = { "test", "-seb" };
 | 
				
			||||||
            parseInto( cli, argv, config );
 | 
					            parseInto( cli, argv, config );
 | 
				
			||||||
            
 | 
					            
 | 
				
			||||||
            THEN( "All the flags are set" ) {
 | 
					            THEN( "All the flags are set" ) {
 | 
				
			||||||
                CHECK( config.showPassingTests );
 | 
					                CHECK( config.showSuccessfulTests );
 | 
				
			||||||
                CHECK( config.noThrow );
 | 
					                CHECK( config.noThrow );
 | 
				
			||||||
                CHECK( config.breakIntoDebugger );
 | 
					                CHECK( config.breakIntoDebugger );
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
@@ -840,6 +856,15 @@ SCENARIO( "New Catch commandline interface", "[cli]" ) {
 | 
				
			|||||||
                REQUIRE( config.testsOrTags[0] == "[hello]" );
 | 
					                REQUIRE( config.testsOrTags[0] == "[hello]" );
 | 
				
			||||||
            }
 | 
					            }
 | 
				
			||||||
        }
 | 
					        }
 | 
				
			||||||
 | 
					        WHEN( "And enum opt is set by numeric value" ) {
 | 
				
			||||||
 | 
					            CHECK( config.verbosity == Config::Normal );
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					            const char* argv[] = { "test", "-v 0" };
 | 
				
			||||||
 | 
					            parseInto( cli, argv, config );
 | 
				
			||||||
 | 
					            
 | 
				
			||||||
 | 
					            THEN( "The member is set to the enum value" )
 | 
				
			||||||
 | 
					                REQUIRE( config.verbosity == Config::NoOutput );
 | 
				
			||||||
 | 
					        }
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user