From 668454b36b6be8d7f0d4d2ce8122654899052526 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 19 May 2020 17:37:09 +0200 Subject: [PATCH] Do not share ownership of Config in RunContext --- src/catch2/catch_session.cpp | 6 +++--- src/catch2/internal/catch_run_context.cpp | 3 +-- src/catch2/internal/catch_run_context.hpp | 4 ++-- 3 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp index c3bf898b..f82c8ea0 100644 --- a/src/catch2/catch_session.cpp +++ b/src/catch2/catch_session.cpp @@ -61,7 +61,7 @@ namespace Catch { class TestGroup { public: - explicit TestGroup(IStreamingReporterPtr&& reporter, std::shared_ptr const& config): + explicit TestGroup(IStreamingReporterPtr&& reporter, Config const* config): m_reporter(reporter.get()), m_config{config}, m_context{config, std::move(reporter)} { @@ -111,7 +111,7 @@ namespace Catch { using Tests = std::set; IStreamingReporter* m_reporter; - std::shared_ptr m_config; + Config const* m_config; RunContext m_context; Tests m_tests; TestSpec::Matches m_matches; @@ -284,7 +284,7 @@ namespace Catch { return 0; } - TestGroup tests { std::move(reporter), m_config }; + TestGroup tests { std::move(reporter), m_config.get() }; auto const totals = tests.execute(); if( m_config->warnAboutNoTests() && totals.error == -1 ) diff --git a/src/catch2/internal/catch_run_context.cpp b/src/catch2/internal/catch_run_context.cpp index 379eddcc..f59a604c 100644 --- a/src/catch2/internal/catch_run_context.cpp +++ b/src/catch2/internal/catch_run_context.cpp @@ -69,7 +69,7 @@ namespace Catch { GeneratorTracker::~GeneratorTracker() {} } - RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter) + RunContext::RunContext(IConfig const* _config, IStreamingReporterPtr&& reporter) : m_runInfo(_config->name()), m_context(getCurrentMutableContext()), m_config(_config), @@ -78,7 +78,6 @@ namespace Catch { m_includeSuccessfulResults( m_config->includeSuccessfulResults() || m_reporter->getPreferences().shouldReportAllAssertions ) { m_context.setRunner(this); - m_context.setConfig(m_config); m_context.setResultCapture(this); m_reporter->testRunStarting(m_runInfo); } diff --git a/src/catch2/internal/catch_run_context.hpp b/src/catch2/internal/catch_run_context.hpp index 622a083b..e9625717 100644 --- a/src/catch2/internal/catch_run_context.hpp +++ b/src/catch2/internal/catch_run_context.hpp @@ -36,7 +36,7 @@ namespace Catch { RunContext( RunContext const& ) = delete; RunContext& operator =( RunContext const& ) = delete; - explicit RunContext( IConfigPtr const& _config, IStreamingReporterPtr&& reporter ); + explicit RunContext( IConfig const* _config, IStreamingReporterPtr&& reporter ); ~RunContext() override; @@ -131,7 +131,7 @@ namespace Catch { ITracker* m_testCaseTracker = nullptr; Option m_lastResult; - IConfigPtr m_config; + IConfig const* m_config; Totals m_totals; IStreamingReporterPtr m_reporter; std::vector m_messages;