mirror of
https://github.com/catchorg/Catch2.git
synced 2025-08-01 12:55:40 +02:00
Resolve reporter outside of Config
config now only only holds reporter name
This commit is contained in:
@@ -28,6 +28,18 @@ namespace Catch {
|
||||
|
||||
inline int Main( Config& config ) {
|
||||
|
||||
std::string reporterName = config.data().reporter.empty()
|
||||
? "basic"
|
||||
: config.data().reporter;
|
||||
Ptr<IReporter> reporter = getCurrentContext().getReporterRegistry().create( reporterName, config );
|
||||
|
||||
if( !config.data().stream.empty() ) {
|
||||
if( config.data().stream[0] == '%' )
|
||||
config.useStream( config.data().stream.substr( 1 ) );
|
||||
else
|
||||
config.setFilename( config.data().stream );
|
||||
}
|
||||
|
||||
// Handle list request
|
||||
if( config.listWhat() != List::None )
|
||||
return List( config );
|
||||
@@ -47,7 +59,7 @@ namespace Catch {
|
||||
|
||||
// Scope here for the Runner so it can use the context before it is cleaned-up
|
||||
{
|
||||
Runner runner( config, config.getReporter() );
|
||||
Runner runner( config, reporter );
|
||||
|
||||
// Run test specs specified on the command line - or default to all
|
||||
if( !config.testsSpecified() ) {
|
||||
@@ -107,18 +119,7 @@ namespace Catch {
|
||||
return 0;
|
||||
}
|
||||
|
||||
parseIntoConfig( parser, config.data() );
|
||||
|
||||
// !TBD: wire up (do this lazily?)
|
||||
if( !config.data().reporter.empty() )
|
||||
config.setReporter( config.data().reporter );
|
||||
|
||||
if( !config.data().stream.empty() ) {
|
||||
if( config.data().stream[0] == '%' )
|
||||
config.useStream( config.data().stream.substr( 1 ) );
|
||||
else
|
||||
config.setFilename( config.data().stream );
|
||||
}
|
||||
parseIntoConfig( parser, config.data() );
|
||||
}
|
||||
catch( std::exception& ex ) {
|
||||
std::cerr << ex.what() << + "\n\nUsage: ...\n\n";
|
||||
|
@@ -82,12 +82,6 @@ namespace Catch {
|
||||
delete m_streambuf;
|
||||
}
|
||||
|
||||
void setReporter( const std::string& reporterName ) {
|
||||
if( m_reporter.get() )
|
||||
throw std::domain_error( "Only one reporter may be specified" );
|
||||
setReporter( getCurrentContext().getReporterRegistry().create( reporterName, *this ) );
|
||||
}
|
||||
|
||||
void setFilename( const std::string& filename ) {
|
||||
m_data.outputFilename = filename;
|
||||
}
|
||||
@@ -108,16 +102,6 @@ namespace Catch {
|
||||
return m_data.outputFilename ;
|
||||
}
|
||||
|
||||
void setReporter( IReporter* reporter ) {
|
||||
m_reporter = reporter;
|
||||
}
|
||||
|
||||
Ptr<IReporter> getReporter() {
|
||||
if( !m_reporter.get() )
|
||||
const_cast<Config*>( this )->setReporter( getCurrentContext().getReporterRegistry().create( "basic", *this ) );
|
||||
return m_reporter;
|
||||
}
|
||||
|
||||
List::What listWhat() const {
|
||||
return static_cast<List::What>( m_data.listSpec & List::WhatMask );
|
||||
}
|
||||
@@ -169,7 +153,6 @@ namespace Catch {
|
||||
ConfigData m_data;
|
||||
|
||||
// !TBD Move these out of here
|
||||
Ptr<IReporter> m_reporter;
|
||||
std::streambuf* m_streambuf;
|
||||
mutable std::ostream m_os;
|
||||
};
|
||||
|
@@ -42,10 +42,6 @@ namespace Catch {
|
||||
return (std::numeric_limits<int>::max)();
|
||||
}
|
||||
|
||||
if( config.getReporter().get() )
|
||||
std::cerr << "Reporters ignored when listing" << std::endl;
|
||||
if( !config.testsSpecified() )
|
||||
std::cerr << "Test specs ignored when listing" << std::endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user