mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-04 05:59:32 +01:00 
			
		
		
		
	Allow name to be provided for overall test run
This commit is contained in:
		@@ -266,7 +266,10 @@ namespace Catch
 | 
			
		||||
        {
 | 
			
		||||
            if( !m_testingSpan.emitted )
 | 
			
		||||
            {
 | 
			
		||||
                if( m_config.getName().empty() )
 | 
			
		||||
                    m_config.stream() << "[Started testing]" << std::endl;
 | 
			
		||||
                else
 | 
			
		||||
                    m_config.stream() << "[Started testing: " << m_config.getName() << "]" << std::endl;
 | 
			
		||||
                m_testingSpan.emitted = true;
 | 
			
		||||
            }
 | 
			
		||||
            
 | 
			
		||||
 
 | 
			
		||||
@@ -46,6 +46,8 @@ namespace Catch
 | 
			
		||||
        {
 | 
			
		||||
            m_xml = XmlWriter( m_config.stream() );
 | 
			
		||||
            m_xml.startElement( "Catch" );
 | 
			
		||||
            if( !m_config.getName().empty() )
 | 
			
		||||
                m_xml.writeAttribute( "name", m_config.getName() );
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        ///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
 
 | 
			
		||||
@@ -30,6 +30,7 @@ namespace Catch
 | 
			
		||||
    // -o, --out filename to write to
 | 
			
		||||
    // -s, --success report successful cases too
 | 
			
		||||
    // -b, --break breaks into debugger on test failure
 | 
			
		||||
    // -n, --name specifies an optional name for the test run
 | 
			
		||||
	class ArgParser : NonCopyable
 | 
			
		||||
    {
 | 
			
		||||
        enum Mode
 | 
			
		||||
@@ -41,6 +42,7 @@ namespace Catch
 | 
			
		||||
            modeOutput,
 | 
			
		||||
            modeSuccess,
 | 
			
		||||
            modeBreak,
 | 
			
		||||
            modeName,
 | 
			
		||||
            modeHelp,
 | 
			
		||||
 | 
			
		||||
            modeError
 | 
			
		||||
@@ -74,6 +76,8 @@ namespace Catch
 | 
			
		||||
                        changeMode( cmd, modeSuccess );
 | 
			
		||||
                    else if( cmd == "-b" || cmd == "--break" )
 | 
			
		||||
                        changeMode( cmd, modeBreak );
 | 
			
		||||
                    else if( cmd == "-n" || cmd == "--name" )
 | 
			
		||||
                        changeMode( cmd, modeName );
 | 
			
		||||
                    else if( cmd == "-h" || cmd == "-?" || cmd == "--help" )
 | 
			
		||||
                        changeMode( cmd, modeHelp );
 | 
			
		||||
                }
 | 
			
		||||
@@ -179,6 +183,10 @@ namespace Catch
 | 
			
		||||
                    if( m_args.size() != 0 )
 | 
			
		||||
                        return setErrorMode( m_command + " does not accept arguments" );
 | 
			
		||||
                    m_config.setShouldDebugBreak( true );
 | 
			
		||||
                case modeName:
 | 
			
		||||
                    if( m_args.size() != 1 )
 | 
			
		||||
                        return setErrorMode( m_command + " requires exactly one argument (a name)" );
 | 
			
		||||
                    m_config.setName( m_args[0] );
 | 
			
		||||
                    break;
 | 
			
		||||
                case modeHelp:
 | 
			
		||||
                    if( m_args.size() != 0 )
 | 
			
		||||
 
 | 
			
		||||
@@ -171,6 +171,18 @@ namespace Catch
 | 
			
		||||
            m_shouldDebugBreak = shouldDebugBreakFlag;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        void setName( const std::string& name )
 | 
			
		||||
        {
 | 
			
		||||
            m_name = name;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        ///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        std::string getName() const
 | 
			
		||||
        {
 | 
			
		||||
            return m_name;
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
        ///////////////////////////////////////////////////////////////////////////
 | 
			
		||||
        bool shouldDebugBreak() const
 | 
			
		||||
        {
 | 
			
		||||
@@ -229,6 +241,8 @@ namespace Catch
 | 
			
		||||
        std::streambuf* m_streambuf;
 | 
			
		||||
        mutable std::ostream m_os;
 | 
			
		||||
        Include::What m_includeWhat;
 | 
			
		||||
        std::string m_name;
 | 
			
		||||
        
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
} // end namespace Catch
 | 
			
		||||
 
 | 
			
		||||
@@ -33,6 +33,9 @@ namespace Catch
 | 
			
		||||
        
 | 
			
		||||
        virtual bool includeSuccessfulResults
 | 
			
		||||
            () const = 0;
 | 
			
		||||
 | 
			
		||||
        virtual std::string getName
 | 
			
		||||
            () const = 0;
 | 
			
		||||
    };
 | 
			
		||||
    
 | 
			
		||||
    class TestCaseInfo;
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user