mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Folded ReporterConfig into RunnerConfig
This commit is contained in:
parent
aca80a171b
commit
50712a34c3
@ -70,7 +70,7 @@ namespace Catch
|
|||||||
std::cerr << "Unable to open file: '" << config.getFilename() << "'" << std::endl;
|
std::cerr << "Unable to open file: '" << config.getFilename() << "'" << std::endl;
|
||||||
return std::numeric_limits<int>::max();
|
return std::numeric_limits<int>::max();
|
||||||
}
|
}
|
||||||
config.getReporterConfig().setStreamBuf( ofs.rdbuf() );
|
config.setStreamBuf( ofs.rdbuf() );
|
||||||
}
|
}
|
||||||
|
|
||||||
Runner runner( config );
|
Runner runner( config );
|
||||||
|
@ -157,7 +157,7 @@ namespace Catch
|
|||||||
case modeSuccess:
|
case modeSuccess:
|
||||||
if( m_args.size() != 0 )
|
if( m_args.size() != 0 )
|
||||||
return setErrorMode( m_command + " does not accept arguments" );
|
return setErrorMode( m_command + " does not accept arguments" );
|
||||||
m_config.setIncludeAll( true );
|
m_config.setIncludeWhat( RunnerConfig::Include::SuccessfulResults );
|
||||||
break;
|
break;
|
||||||
case modeBreak:
|
case modeBreak:
|
||||||
if( m_args.size() != 0 )
|
if( m_args.size() != 0 )
|
||||||
|
@ -13,11 +13,11 @@
|
|||||||
#define TWOBLUECUBES_CATCH_HUB_H_INCLUDED
|
#define TWOBLUECUBES_CATCH_HUB_H_INCLUDED
|
||||||
|
|
||||||
#include <memory>
|
#include <memory>
|
||||||
|
#include "catch_interfaces_reporter.h"
|
||||||
|
|
||||||
namespace Catch
|
namespace Catch
|
||||||
{
|
{
|
||||||
struct IResultListener;
|
struct IResultListener;
|
||||||
struct IReporterRegistry;
|
|
||||||
struct ITestCaseRegistry;
|
struct ITestCaseRegistry;
|
||||||
|
|
||||||
class Hub
|
class Hub
|
||||||
|
@ -21,63 +21,19 @@
|
|||||||
|
|
||||||
namespace Catch
|
namespace Catch
|
||||||
{
|
{
|
||||||
class ReporterConfig : public IReporterConfig
|
class RunnerConfig : public IReporterConfig
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
ReporterConfig( const ReporterConfig& other );
|
RunnerConfig( const RunnerConfig& other );
|
||||||
ReporterConfig& operator = ( const ReporterConfig& other );
|
RunnerConfig& operator = ( const RunnerConfig& other );
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
||||||
struct Include { enum What
|
struct Include { enum What
|
||||||
{
|
|
||||||
FailedOnly,
|
|
||||||
SuccessfulResults
|
|
||||||
}; };
|
|
||||||
|
|
||||||
public:
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
explicit ReporterConfig( Include::What includeWhat = Include::FailedOnly )
|
|
||||||
: m_includeWhat( includeWhat ),
|
|
||||||
m_os( std::cout.rdbuf() )
|
|
||||||
{
|
{
|
||||||
}
|
FailedOnly,
|
||||||
|
SuccessfulResults
|
||||||
///////////////////////////////////////////////////////////////////////////
|
}; };
|
||||||
virtual bool includeSuccessfulResults() const
|
|
||||||
{
|
|
||||||
return m_includeWhat == Include::SuccessfulResults;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
void setIncludeWhat(Include::What includeWhat )
|
|
||||||
{
|
|
||||||
m_includeWhat = includeWhat;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
virtual std::ostream& stream() const
|
|
||||||
{
|
|
||||||
return m_os;
|
|
||||||
}
|
|
||||||
|
|
||||||
///////////////////////////////////////////////////////////////////////////
|
|
||||||
void setStreamBuf( std::streambuf* buf )
|
|
||||||
{
|
|
||||||
m_os.rdbuf( buf );
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
Include::What m_includeWhat;
|
|
||||||
|
|
||||||
mutable std::ostream m_os;
|
|
||||||
};
|
|
||||||
|
|
||||||
class RunnerConfig
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
|
|
||||||
enum ListInfo
|
enum ListInfo
|
||||||
{
|
{
|
||||||
listNone = 0,
|
listNone = 0,
|
||||||
@ -99,14 +55,16 @@ namespace Catch
|
|||||||
: m_reporter( NULL ),
|
: m_reporter( NULL ),
|
||||||
m_listSpec( listNone ),
|
m_listSpec( listNone ),
|
||||||
m_shouldDebugBreak( false ),
|
m_shouldDebugBreak( false ),
|
||||||
m_showHelp( false )
|
m_showHelp( false ),
|
||||||
|
m_os( std::cout.rdbuf() ),
|
||||||
|
m_includeWhat( Include::FailedOnly )
|
||||||
{}
|
{}
|
||||||
|
|
||||||
void setReporterInfo( const std::string& reporterName )
|
void setReporterInfo( const std::string& reporterName )
|
||||||
{
|
{
|
||||||
if( m_reporter.get() )
|
if( m_reporter.get() )
|
||||||
return setError( "Only one reporter may be specified" );
|
return setError( "Only one reporter may be specified" );
|
||||||
setReporter( Hub::getReporterRegistry().create( reporterName, m_reporterConfig ) );
|
setReporter( Hub::getReporterRegistry().create( reporterName, *this ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
void addTestSpec( const std::string& testSpec )
|
void addTestSpec( const std::string& testSpec )
|
||||||
@ -141,7 +99,7 @@ namespace Catch
|
|||||||
IReporter* getReporter()
|
IReporter* getReporter()
|
||||||
{
|
{
|
||||||
if( !m_reporter.get() )
|
if( !m_reporter.get() )
|
||||||
setReporter( Hub::getReporterRegistry().create( "basic", m_reporterConfig ) );
|
setReporter( Hub::getReporterRegistry().create( "basic", *this ) );
|
||||||
return m_reporter.get();
|
return m_reporter.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -160,13 +118,9 @@ namespace Catch
|
|||||||
return (ListInfo)( m_listSpec & listAsMask );
|
return (ListInfo)( m_listSpec & listAsMask );
|
||||||
}
|
}
|
||||||
|
|
||||||
ReporterConfig& getReporterConfig()
|
void setIncludeWhat( Include::What includeWhat )
|
||||||
{
|
{
|
||||||
return m_reporterConfig;
|
m_includeWhat = includeWhat;
|
||||||
}
|
|
||||||
void setIncludeAll( bool includeAll )
|
|
||||||
{
|
|
||||||
m_reporterConfig.setIncludeWhat( includeAll ? ReporterConfig::Include::SuccessfulResults : ReporterConfig::Include::FailedOnly );
|
|
||||||
}
|
}
|
||||||
void setShouldDebugBreak( bool shouldDebugBreak )
|
void setShouldDebugBreak( bool shouldDebugBreak )
|
||||||
{
|
{
|
||||||
@ -184,16 +138,36 @@ namespace Catch
|
|||||||
{
|
{
|
||||||
return m_showHelp;
|
return m_showHelp;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
virtual std::ostream& stream() const
|
||||||
|
{
|
||||||
|
return m_os;
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
void setStreamBuf( std::streambuf* buf )
|
||||||
|
{
|
||||||
|
m_os.rdbuf( buf );
|
||||||
|
}
|
||||||
|
|
||||||
|
///////////////////////////////////////////////////////////////////////////
|
||||||
|
virtual bool includeSuccessfulResults() const
|
||||||
|
{
|
||||||
|
return m_includeWhat == Include::SuccessfulResults;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
std::auto_ptr<IReporter> m_reporter;
|
std::auto_ptr<IReporter> m_reporter;
|
||||||
std::string m_filename;
|
std::string m_filename;
|
||||||
ReporterConfig m_reporterConfig;
|
|
||||||
std::string m_message;
|
std::string m_message;
|
||||||
ListInfo m_listSpec;
|
ListInfo m_listSpec;
|
||||||
std::vector<std::string> m_testSpecs;
|
std::vector<std::string> m_testSpecs;
|
||||||
bool m_shouldDebugBreak;
|
bool m_shouldDebugBreak;
|
||||||
bool m_showHelp;
|
bool m_showHelp;
|
||||||
|
mutable std::ostream m_os;
|
||||||
|
Include::What m_includeWhat;
|
||||||
};
|
};
|
||||||
|
|
||||||
} // end namespace Catch
|
} // end namespace Catch
|
||||||
|
Loading…
Reference in New Issue
Block a user