Do not share ownership of Config in RunContext

This commit is contained in:
Martin Hořeňovský 2020-05-19 17:37:09 +02:00
parent 458241cc90
commit 668454b36b
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
3 changed files with 6 additions and 7 deletions

View File

@ -61,7 +61,7 @@ namespace Catch {
class TestGroup { class TestGroup {
public: public:
explicit TestGroup(IStreamingReporterPtr&& reporter, std::shared_ptr<Config> const& config): explicit TestGroup(IStreamingReporterPtr&& reporter, Config const* config):
m_reporter(reporter.get()), m_reporter(reporter.get()),
m_config{config}, m_config{config},
m_context{config, std::move(reporter)} { m_context{config, std::move(reporter)} {
@ -111,7 +111,7 @@ namespace Catch {
using Tests = std::set<TestCaseHandle const*>; using Tests = std::set<TestCaseHandle const*>;
IStreamingReporter* m_reporter; IStreamingReporter* m_reporter;
std::shared_ptr<Config> m_config; Config const* m_config;
RunContext m_context; RunContext m_context;
Tests m_tests; Tests m_tests;
TestSpec::Matches m_matches; TestSpec::Matches m_matches;
@ -284,7 +284,7 @@ namespace Catch {
return 0; return 0;
} }
TestGroup tests { std::move(reporter), m_config }; TestGroup tests { std::move(reporter), m_config.get() };
auto const totals = tests.execute(); auto const totals = tests.execute();
if( m_config->warnAboutNoTests() && totals.error == -1 ) if( m_config->warnAboutNoTests() && totals.error == -1 )

View File

@ -69,7 +69,7 @@ namespace Catch {
GeneratorTracker::~GeneratorTracker() {} GeneratorTracker::~GeneratorTracker() {}
} }
RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter) RunContext::RunContext(IConfig const* _config, IStreamingReporterPtr&& reporter)
: m_runInfo(_config->name()), : m_runInfo(_config->name()),
m_context(getCurrentMutableContext()), m_context(getCurrentMutableContext()),
m_config(_config), m_config(_config),
@ -78,7 +78,6 @@ namespace Catch {
m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions )
{ {
m_context.setRunner(this); m_context.setRunner(this);
m_context.setConfig(m_config);
m_context.setResultCapture(this); m_context.setResultCapture(this);
m_reporter->testRunStarting(m_runInfo); m_reporter->testRunStarting(m_runInfo);
} }

View File

@ -36,7 +36,7 @@ namespace Catch {
RunContext( RunContext const& ) = delete; RunContext( RunContext const& ) = delete;
RunContext& operator =( RunContext const& ) = delete; RunContext& operator =( RunContext const& ) = delete;
explicit RunContext( IConfigPtr const& _config, IStreamingReporterPtr&& reporter ); explicit RunContext( IConfig const* _config, IStreamingReporterPtr&& reporter );
~RunContext() override; ~RunContext() override;
@ -131,7 +131,7 @@ namespace Catch {
ITracker* m_testCaseTracker = nullptr; ITracker* m_testCaseTracker = nullptr;
Option<AssertionResult> m_lastResult; Option<AssertionResult> m_lastResult;
IConfigPtr m_config; IConfig const* m_config;
Totals m_totals; Totals m_totals;
IStreamingReporterPtr m_reporter; IStreamingReporterPtr m_reporter;
std::vector<MessageInfo> m_messages; std::vector<MessageInfo> m_messages;