mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-22 21:36:11 +01:00
Session now holds Config in unique_ptr instead of shared_ptr
This commit is contained in:
parent
668454b36b
commit
21d284df34
@ -137,7 +137,7 @@ namespace Catch {
|
|||||||
const auto& exceptions = getRegistryHub().getStartupExceptionRegistry().getExceptions();
|
const auto& exceptions = getRegistryHub().getStartupExceptionRegistry().getExceptions();
|
||||||
if ( !exceptions.empty() ) {
|
if ( !exceptions.empty() ) {
|
||||||
config();
|
config();
|
||||||
getCurrentMutableContext().setConfig(m_config);
|
getCurrentMutableContext().setConfig(m_config.get());
|
||||||
|
|
||||||
m_startupExceptions = true;
|
m_startupExceptions = true;
|
||||||
Colour colourGuard( Colour::Red );
|
Colour colourGuard( Colour::Red );
|
||||||
@ -181,7 +181,7 @@ namespace Catch {
|
|||||||
auto result = m_cli.parse( clara::Args( argc, argv ) );
|
auto result = m_cli.parse( clara::Args( argc, argv ) );
|
||||||
if( !result ) {
|
if( !result ) {
|
||||||
config();
|
config();
|
||||||
getCurrentMutableContext().setConfig(m_config);
|
getCurrentMutableContext().setConfig(m_config.get());
|
||||||
Catch::cerr()
|
Catch::cerr()
|
||||||
<< Colour( Colour::Red )
|
<< Colour( Colour::Red )
|
||||||
<< "\nError(s) in input:\n"
|
<< "\nError(s) in input:\n"
|
||||||
@ -252,7 +252,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
Config& Session::config() {
|
Config& Session::config() {
|
||||||
if( !m_config )
|
if( !m_config )
|
||||||
m_config = std::make_shared<Config>( m_configData );
|
m_config = std::make_unique<Config>( m_configData );
|
||||||
return *m_config;
|
return *m_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -274,7 +274,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set up global config instance before we start calling into other functions
|
// Set up global config instance before we start calling into other functions
|
||||||
getCurrentMutableContext().setConfig(m_config);
|
getCurrentMutableContext().setConfig(m_config.get());
|
||||||
|
|
||||||
// Create reporter(s) so we can route listings through them
|
// Create reporter(s) so we can route listings through them
|
||||||
auto reporter = makeReporter(m_config.get());
|
auto reporter = makeReporter(m_config.get());
|
||||||
|
@ -53,7 +53,7 @@ namespace Catch {
|
|||||||
|
|
||||||
clara::Parser m_cli;
|
clara::Parser m_cli;
|
||||||
ConfigData m_configData;
|
ConfigData m_configData;
|
||||||
std::shared_ptr<Config> m_config;
|
std::unique_ptr<Config> m_config;
|
||||||
bool m_startupExceptions = false;
|
bool m_startupExceptions = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ namespace Catch {
|
|||||||
}
|
}
|
||||||
|
|
||||||
IConfig const* getConfig() const override {
|
IConfig const* getConfig() const override {
|
||||||
return m_config.get();
|
return m_config;
|
||||||
}
|
}
|
||||||
|
|
||||||
~Context() override;
|
~Context() override;
|
||||||
@ -34,14 +34,14 @@ namespace Catch {
|
|||||||
void setRunner( IRunner* runner ) override {
|
void setRunner( IRunner* runner ) override {
|
||||||
m_runner = runner;
|
m_runner = runner;
|
||||||
}
|
}
|
||||||
void setConfig( IConfigPtr const& config ) override {
|
void setConfig( IConfig const* config ) override {
|
||||||
m_config = config;
|
m_config = config;
|
||||||
}
|
}
|
||||||
|
|
||||||
friend IMutableContext& getCurrentMutableContext();
|
friend IMutableContext& getCurrentMutableContext();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
IConfigPtr m_config;
|
IConfig const* m_config = nullptr;
|
||||||
IRunner* m_runner = nullptr;
|
IRunner* m_runner = nullptr;
|
||||||
IResultCapture* m_resultCapture = nullptr;
|
IResultCapture* m_resultCapture = nullptr;
|
||||||
};
|
};
|
||||||
|
@ -33,7 +33,7 @@ namespace Catch {
|
|||||||
virtual ~IMutableContext();
|
virtual ~IMutableContext();
|
||||||
virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
|
virtual void setResultCapture( IResultCapture* resultCapture ) = 0;
|
||||||
virtual void setRunner( IRunner* runner ) = 0;
|
virtual void setRunner( IRunner* runner ) = 0;
|
||||||
virtual void setConfig( IConfigPtr const& config ) = 0;
|
virtual void setConfig( IConfig const* config ) = 0;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
static IMutableContext *currentContext;
|
static IMutableContext *currentContext;
|
||||||
|
Loading…
Reference in New Issue
Block a user