mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 04:07:10 +01:00 
			
		
		
		
	Runner -> RunContext, Runner2 -> Runner and fixed issue with processName
This commit is contained in:
		| @@ -21,10 +21,10 @@ | ||||
|  | ||||
| namespace Catch { | ||||
|  | ||||
|     class Runner2 { // This will become Runner when Runner becomes Context | ||||
|     class Runner { | ||||
|  | ||||
|     public: | ||||
|         Runner2( Ptr<Config> const& config ) | ||||
|         Runner( Ptr<Config> const& config ) | ||||
|         :   m_config( config ) | ||||
|         { | ||||
|             openStream(); | ||||
| @@ -39,7 +39,8 @@ namespace Catch { | ||||
|                 filterGroups.push_back( filterGroup ); | ||||
|             } | ||||
|  | ||||
|             Runner context( m_config.get(), m_reporter ); // This Runner will be renamed Context | ||||
|             RunContext context( m_config.get(), m_reporter ); | ||||
|  | ||||
|             Totals totals; | ||||
|  | ||||
|             for( std::size_t i=0; i < filterGroups.size() && !context.aborting(); ++i ) { | ||||
| @@ -50,7 +51,7 @@ namespace Catch { | ||||
|             return totals; | ||||
|         } | ||||
|  | ||||
|         Totals runTestsForGroup( Runner& context, const TestCaseFilters& filterGroup ) { | ||||
|         Totals runTestsForGroup( RunContext& context, const TestCaseFilters& filterGroup ) { | ||||
|             Totals totals; | ||||
|             std::vector<TestCase>::const_iterator it = getRegistryHub().getTestCaseRegistry().getAllTests().begin(); | ||||
|             std::vector<TestCase>::const_iterator itEnd = getRegistryHub().getTestCaseRegistry().getAllTests().end(); | ||||
| @@ -111,7 +112,7 @@ namespace Catch { | ||||
|         int result = 0; | ||||
|         try | ||||
|         { | ||||
|             Runner2 runner( config ); | ||||
|             Runner runner( config ); | ||||
|  | ||||
|             // Handle list request | ||||
|             if( list( config ) ) { | ||||
| @@ -144,7 +145,7 @@ namespace Catch { | ||||
|         cli.usage( std::cout, processName ); | ||||
|         std::cout << "\nFor more detail usage please see: https://github.com/philsquared/Catch/wiki/Command-line\n" << std::endl; | ||||
|     } | ||||
|     inline Ptr<Config> processConfig( int argc, char* const argv[], ConfigData configData = ConfigData() ) { | ||||
|     inline Ptr<Config> processConfig( int argc, char* const argv[], ConfigData& configData ) { | ||||
|         Clara::CommandLine<ConfigData> cli = makeCommandLineParser(); | ||||
|         std::vector<Clara::Parser::Token> unused = cli.parseInto( argc, argv, configData ); | ||||
|         if( !unused.empty() ) { | ||||
| @@ -159,6 +160,10 @@ namespace Catch { | ||||
|         Ptr<Config> config = new Config( configData ); | ||||
|         return config;         | ||||
|     } | ||||
|     inline Ptr<Config> processConfig( int argc, char* const argv[] ) { | ||||
|         ConfigData configData; | ||||
|         return processConfig( argc, argv, configData ); | ||||
|     } | ||||
|  | ||||
|     inline int Main( int argc, char* const argv[], ConfigData configData = ConfigData() ) { | ||||
|  | ||||
| @@ -167,7 +172,7 @@ namespace Catch { | ||||
|         try { | ||||
|             config = processConfig( argc, argv, configData ); | ||||
|             if( config->showHelp() ) { | ||||
|                 showHelp( argv[0] ); | ||||
|                 showHelp( config->getProcessName() ); | ||||
|                 Catch::cleanUp();         | ||||
|                 return 0; | ||||
|             } | ||||
| @@ -175,7 +180,7 @@ namespace Catch { | ||||
|         catch( std::exception& ex ) { | ||||
|             std::cerr   << "\nError in input:\n" | ||||
|                         << "  " << ex.what() << "\n\n"; | ||||
|             makeCommandLineParser().usage( std::cout, argv[0] ); | ||||
|             makeCommandLineParser().usage( std::cout, configData.processName ); | ||||
|             Catch::cleanUp(); | ||||
|             return (std::numeric_limits<int>::max)(); | ||||
|         } | ||||
|   | ||||
| @@ -122,10 +122,10 @@ namespace Catch { | ||||
|         bool listTags() const { return m_data.listTags; } | ||||
|         bool listReporters() const { return m_data.listReporters; } | ||||
|          | ||||
|         std::string getName() const { | ||||
|             return m_data.name; | ||||
|         std::string getProcessName() const { | ||||
|             return m_data.processName; | ||||
|         } | ||||
|          | ||||
|  | ||||
|         bool shouldDebugBreak() const { | ||||
|             return m_data.shouldDebugBreak; | ||||
|         } | ||||
| @@ -162,7 +162,7 @@ namespace Catch { | ||||
|         // IConfig interface | ||||
|         virtual bool allowThrows() const        { return !m_data.noThrow; } | ||||
|         virtual std::ostream& stream() const    { return m_os; } | ||||
|         virtual std::string name() const        { return m_data.name; } | ||||
|         virtual std::string name() const        { return m_data.name.empty() ? m_data.processName : m_data.name; } | ||||
|         virtual bool includeSuccessfulResults() const   { return m_data.showSuccessfulTests; } | ||||
|         virtual bool warnAboutMissingAssertions() const { return m_data.warnings & ConfigData::WarnAbout::NoAssertions; } | ||||
|  | ||||
|   | ||||
| @@ -49,14 +49,14 @@ namespace Catch { | ||||
|  | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
|     class Runner : public IResultCapture, public IRunner { | ||||
|     class RunContext : public IResultCapture, public IRunner { | ||||
|      | ||||
|         Runner( Runner const& ); | ||||
|         void operator =( Runner const& ); | ||||
|         RunContext( RunContext const& ); | ||||
|         void operator =( RunContext const& ); | ||||
|          | ||||
|     public: | ||||
|  | ||||
|         explicit Runner( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter ) | ||||
|         explicit RunContext( Ptr<IConfig const> const& config, Ptr<IStreamingReporter> const& reporter ) | ||||
|         :   m_runInfo( config->name() ), | ||||
|             m_context( getCurrentMutableContext() ), | ||||
|             m_runningTest( NULL ), | ||||
| @@ -72,7 +72,7 @@ namespace Catch { | ||||
|             m_reporter->testRunStarting( m_runInfo ); | ||||
|         } | ||||
|          | ||||
|         virtual ~Runner() { | ||||
|         virtual ~RunContext() { | ||||
|             m_reporter->testRunEnded( TestRunStats( m_runInfo, m_totals, aborting() ) ); | ||||
|             m_context.setRunner( m_prevRunner ); | ||||
|             m_context.setConfig( NULL ); | ||||
|   | ||||
| @@ -458,7 +458,11 @@ namespace Clara { | ||||
|         }         | ||||
|          | ||||
|         std::vector<Parser::Token> parseInto( int argc, char const * const * argv, ConfigT& config ) const { | ||||
|             m_boundProcessName.set( config, argv[0] ); | ||||
|             std::string processName = argv[0]; | ||||
|             std::size_t lastSlash = processName.find_last_of( "/\\" ); | ||||
|             if( lastSlash != std::string::npos ) | ||||
|                 processName = processName.substr( lastSlash+1 ); | ||||
|             m_boundProcessName.set( config, processName ); | ||||
|             std::vector<Parser::Token> tokens; | ||||
|             Parser parser; | ||||
|             parser.parseIntoTokens( argc, argv, tokens ); | ||||
|   | ||||
| @@ -243,7 +243,7 @@ namespace Catch { | ||||
|             stream  << "\n" << getTildes() << "\n"; | ||||
|             Colour colour( Colour::SecondaryText ); | ||||
|             stream  << testRunInfo->name | ||||
|                     << " is a CATCH v"  << libraryVersion.majorVersion << "." | ||||
|                     << " is a Catch v"  << libraryVersion.majorVersion << "." | ||||
|                     << libraryVersion.minorVersion << " b" | ||||
|                     << libraryVersion.buildNumber; | ||||
|             if( libraryVersion.branchName != "master" ) | ||||
|   | ||||
| @@ -20,9 +20,9 @@ namespace Catch{ | ||||
|          | ||||
|         Totals totals; | ||||
|  | ||||
|         // Scoped because Runner doesn't report EndTesting until its destructor | ||||
|         // Scoped because RunContext doesn't report EndTesting until its destructor | ||||
|         { | ||||
|             Runner runner( config.get(), m_reporter.get() ); | ||||
|             RunContext runner( config.get(), m_reporter.get() ); | ||||
|             totals = runner.runMatching( rawTestSpec, groupIndex, groupsCount ); | ||||
|         } | ||||
|         return totals; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Phil Nash
					Phil Nash