Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

Do not share ownership of Config in RunContext

Commit
668454b36b6be8d7f0d4d2ce8122654899052526
Author
Martin Hořeňovský ·
Parents
458241cc90b7

Files · Download .tar.gz

Changes

 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<Config> 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<TestCaseHandle const*>;
 
             IStreamingReporter* m_reporter;
-            std::shared_ptr<Config> 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<AssertionResult> m_lastResult;
 
-        IConfigPtr m_config;
+        IConfig const* m_config;
         Totals m_totals;
         IStreamingReporterPtr m_reporter;
         std::vector<MessageInfo> m_messages;