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

Store IStream instance owning ptrs in reporter instances

This ended up being a surprisingly large refactoring, motivated
by removing a `const_cast` from `Config`'s handling of reporter
streams, forced by previous commit.
Commit
79d1e8238135427a6780a6db2cdb8b9be0b7f086
Author
Martin Hořeňovský ·
Parents
4f09f1120ba0

Files · Download .tar.gz

Changes

 src/catch2/catch_config.cpp                        | 26 ++++++----
 src/catch2/catch_config.hpp                        |  3 --
 src/catch2/catch_session.cpp                       | 17 +++---
 .../interfaces/catch_interfaces_reporter.cpp       | 10 ++--
 .../interfaces/catch_interfaces_reporter.hpp       |  6 +--
 .../catch_interfaces_reporter_factory.hpp          |  2 +-
 .../catch_interfaces_reporter_registry.hpp         |  2 +-
 src/catch2/internal/catch_reporter_registry.cpp    |  4 +-
 src/catch2/internal/catch_reporter_registry.hpp    |  2 +-
 src/catch2/reporters/catch_reporter_automake.hpp   |  1 -
 .../reporters/catch_reporter_common_base.cpp       |  6 +--
 .../reporters/catch_reporter_common_base.hpp       |  4 +-
 src/catch2/reporters/catch_reporter_console.cpp    |  4 +-
 src/catch2/reporters/catch_reporter_console.hpp    |  2 +-
 src/catch2/reporters/catch_reporter_junit.cpp      |  5 +-
 src/catch2/reporters/catch_reporter_junit.hpp      |  2 +-
 src/catch2/reporters/catch_reporter_registrars.hpp |  5 +-
 src/catch2/reporters/catch_reporter_sonarqube.hpp  |  5 +-
 src/catch2/reporters/catch_reporter_tap.hpp        |  5 +-
 src/catch2/reporters/catch_reporter_teamcity.hpp   |  4 +-
 src/catch2/reporters/catch_reporter_xml.cpp        |  5 +-
 src/catch2/reporters/catch_reporter_xml.hpp        |  2 +-
 .../X22-BenchmarksInCumulativeReporter.cpp         |  5 +-
 tests/ExtraTests/X23-CasingInReporterNames.cpp     |  5 +-
 ...rPreferencesForPassingAssertionsIsRespected.cpp |  5 +-
 .../X27-CapturedStdoutInTestCaseEvents.cpp         |  5 +-
 .../X28-ListenersGetEventsBeforeReporters.cpp      |  6 ++-
 .../ExtraTests/X29-CustomArgumentsForReporters.cpp |  4 +-
 tests/SelfTest/Baselines/compact.sw.approved.txt   |  2 +-
 .../Baselines/compact.sw.multi.approved.txt        |  2 +-
 tests/SelfTest/Baselines/console.sw.approved.txt   |  2 +-
 .../Baselines/console.sw.multi.approved.txt        |  2 +-
 tests/SelfTest/Baselines/tap.sw.approved.txt       |  2 +-
 tests/SelfTest/Baselines/tap.sw.multi.approved.txt |  2 +-
 tests/SelfTest/Baselines/xml.sw.approved.txt       |  2 +-
 tests/SelfTest/Baselines/xml.sw.multi.approved.txt |  2 +-
 .../SelfTest/IntrospectiveTests/CmdLine.tests.cpp  |  5 +-
 .../IntrospectiveTests/Reporters.tests.cpp         | 60 +++++++++++-----------
 38 files changed, 124 insertions(+), 109 deletions(-)

diff --git a/src/catch2/catch_config.cpp b/src/catch2/catch_config.cpp
index 9f112bd8..32d40410 100644
--- a/src/catch2/catch_config.cpp
+++ b/src/catch2/catch_config.cpp
@@ -76,20 +76,28 @@ namespace Catch {
         }
 #endif
 
+
+        // We now fixup the reporter specs to handle default output spec,
+        // default colour spec, etc
         bool defaultOutputUsed = false;
-        m_reporterStreams.reserve( m_data.reporterSpecifications.size() );
-        for ( auto const& reporterSpec : m_data.reporterSpecifications ) {
+        for ( auto& reporterSpec : m_data.reporterSpecifications ) {
             if ( reporterSpec.outputFile().none() ) {
                 CATCH_ENFORCE( !defaultOutputUsed,
                                "Internal error: cannot use default output for "
                                "multiple reporters" );
                 defaultOutputUsed = true;
 
-                m_reporterStreams.push_back(
-                    makeStream( data.defaultOutputFilename ) );
-            } else {
-                m_reporterStreams.push_back(
-                    makeStream( *reporterSpec.outputFile() ) );
+                reporterSpec = ReporterSpec{ reporterSpec.name(),
+                                             data.defaultOutputFilename,
+                                             reporterSpec.colourMode(),
+                                             reporterSpec.customOptions() };
+            }
+
+            if ( reporterSpec.colourMode().none() ) {
+                reporterSpec = ReporterSpec{ reporterSpec.name(),
+                                             reporterSpec.outputFile(),
+                                             data.defaultColourMode,
+                                             reporterSpec.customOptions() };
             }
         }
     }
@@ -108,10 +116,6 @@ namespace Catch {
         return m_data.reporterSpecifications;
     }
 
-    IStream* Config::getReporterOutputStream(std::size_t reporterIdx) const {
-        return const_cast<IStream*>(m_reporterStreams.at(reporterIdx).get());
-    }
-
     TestSpec const& Config::testSpec() const { return m_testSpec; }
     bool Config::hasTestFilters() const { return m_hasTestFilters; }
 
diff --git a/src/catch2/catch_config.hpp b/src/catch2/catch_config.hpp
index bed9b088..b7f0c5b0 100644
--- a/src/catch2/catch_config.hpp
+++ b/src/catch2/catch_config.hpp
@@ -81,7 +81,6 @@ namespace Catch {
         bool listReporters() const;
 
         std::vector<ReporterSpec> const& getReporterSpecs() const;
-        IStream* getReporterOutputStream(std::size_t reporterIdx) const;
 
         std::vector<std::string> const& getTestsOrTags() const override;
         std::vector<std::string> const& getSectionsToRun() const override;
@@ -117,8 +116,6 @@ namespace Catch {
 
     private:
         ConfigData m_data;
-
-        std::vector<Detail::unique_ptr<IStream>> m_reporterStreams;
         TestSpec m_testSpec;
         bool m_hasTestFilters = false;
     };
diff --git a/src/catch2/catch_session.cpp b/src/catch2/catch_session.cpp
index 5af8f454..048fd915 100644
--- a/src/catch2/catch_session.cpp
+++ b/src/catch2/catch_session.cpp
@@ -34,8 +34,8 @@ namespace Catch {
     namespace {
         const int MaxExitCode = 255;
 
-        IEventListenerPtr createReporter(std::string const& reporterName, ReporterConfig const& config) {
-            auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, config);
+        IEventListenerPtr createReporter(std::string const& reporterName, ReporterConfig&& config) {
+            auto reporter = Catch::getRegistryHub().getReporterRegistry().create(reporterName, CATCH_MOVE(config));
             CATCH_ENFORCE(reporter, "No reporter registered with name: '" << reporterName << '\'');
 
             return reporter;
@@ -45,13 +45,12 @@ namespace Catch {
             if (Catch::getRegistryHub().getReporterRegistry().getListeners().empty()
                     && config->getReporterSpecs().size() == 1) {
                 auto const& spec = config->getReporterSpecs()[0];
-                auto stream = config->getReporterOutputStream(0);
                 return createReporter(
-                    config->getReporterSpecs()[0].name(),
+                    spec.name(),
                     ReporterConfig(
                         config,
-                        stream,
-                        spec.colourMode().valueOr( config->defaultColourMode() ),
+                        makeStream(*spec.outputFile()),
+                        *spec.colourMode(),
                         spec.customOptions() ) );
             }
 
@@ -64,13 +63,11 @@ namespace Catch {
 
             std::size_t reporterIdx = 0;
             for (auto const& reporterSpec : config->getReporterSpecs()) {
-                auto stream = config->getReporterOutputStream(reporterIdx);
                 multi->addReporter( createReporter(
                     reporterSpec.name(),
                     ReporterConfig( config,
-                                    stream,
-                                    reporterSpec.colourMode().valueOr(
-                                        config->defaultColourMode() ),
+                                    makeStream( *reporterSpec.outputFile() ),
+                                    *reporterSpec.colourMode(),
                                     reporterSpec.customOptions() ) ) );
                 reporterIdx++;
             }
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.cpp b/src/catch2/interfaces/catch_interfaces_reporter.cpp
index 926331e0..9a6cbdc2 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.cpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.cpp
@@ -17,21 +17,25 @@
 #include <catch2/internal/catch_move_and_forward.hpp>
 
 #include <algorithm>
+#include <cassert>
 #include <iomanip>
 
 namespace Catch {
 
     ReporterConfig::ReporterConfig(
         IConfig const* _fullConfig,
-        IStream* _stream,
+        Detail::unique_ptr<IStream> _stream,
         ColourMode colourMode,
         std::map<std::string, std::string> customOptions ):
-        m_stream( _stream ),
+        m_stream( CATCH_MOVE(_stream) ),
         m_fullConfig( _fullConfig ),
         m_colourMode( colourMode ),
         m_customOptions( CATCH_MOVE( customOptions ) ) {}
 
-    IStream* ReporterConfig::stream() const { return m_stream; }
+    Detail::unique_ptr<IStream> ReporterConfig::takeStream() && {
+        assert( m_stream );
+        return CATCH_MOVE( m_stream );
+    }
     IConfig const * ReporterConfig::fullConfig() const { return m_fullConfig; }
     ColourMode ReporterConfig::colourMode() const { return m_colourMode; }
 
diff --git a/src/catch2/interfaces/catch_interfaces_reporter.hpp b/src/catch2/interfaces/catch_interfaces_reporter.hpp
index 21a16cde..1e6c2590 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter.hpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter.hpp
@@ -36,17 +36,17 @@ namespace Catch {
 
     struct ReporterConfig {
         ReporterConfig( IConfig const* _fullConfig,
-                        IStream* _stream,
+                        Detail::unique_ptr<IStream> _stream,
                         ColourMode colourMode,
                         std::map<std::string, std::string> customOptions );
 
-        IStream* stream() const;
+        Detail::unique_ptr<IStream> takeStream() &&;
         IConfig const* fullConfig() const;
         ColourMode colourMode() const;
         std::map<std::string, std::string> const& customOptions() const;
 
     private:
-        IStream* m_stream;
+        Detail::unique_ptr<IStream> m_stream;
         IConfig const* m_fullConfig;
         ColourMode m_colourMode;
         std::map<std::string, std::string> m_customOptions;
diff --git a/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp b/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp
index 7a71a168..76dce504 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter_factory.hpp
@@ -25,7 +25,7 @@ namespace Catch {
         virtual ~IReporterFactory(); // = default
 
         virtual IEventListenerPtr
-        create( ReporterConfig const& config ) const = 0;
+        create( ReporterConfig&& config ) const = 0;
         virtual std::string getDescription() const = 0;
     };
     using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
diff --git a/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp b/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp
index 5645640a..d2f2a159 100644
--- a/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp
+++ b/src/catch2/interfaces/catch_interfaces_reporter_registry.hpp
@@ -32,7 +32,7 @@ namespace Catch {
         using Listeners = std::vector<Detail::unique_ptr<EventListenerFactory>>;
 
         virtual ~IReporterRegistry(); // = default
-        virtual IEventListenerPtr create( std::string const& name, ReporterConfig const& config ) const = 0;
+        virtual IEventListenerPtr create( std::string const& name, ReporterConfig&& config ) const = 0;
         virtual FactoryMap const& getFactories() const = 0;
         virtual Listeners const& getListeners() const = 0;
     };
diff --git a/src/catch2/internal/catch_reporter_registry.cpp b/src/catch2/internal/catch_reporter_registry.cpp
index 56982e27..c4aef822 100644
--- a/src/catch2/internal/catch_reporter_registry.cpp
+++ b/src/catch2/internal/catch_reporter_registry.cpp
@@ -37,11 +37,11 @@ namespace Catch {
     ReporterRegistry::~ReporterRegistry() = default;
 
 
-    IEventListenerPtr ReporterRegistry::create( std::string const& name, ReporterConfig const& config ) const {
+    IEventListenerPtr ReporterRegistry::create( std::string const& name, ReporterConfig&& config ) const {
         auto it =  m_factories.find( name );
         if( it == m_factories.end() )
             return nullptr;
-        return it->second->create( config );
+        return it->second->create( CATCH_MOVE(config) );
     }
 
     void ReporterRegistry::registerReporter( std::string const& name, IReporterFactoryPtr factory ) {
diff --git a/src/catch2/internal/catch_reporter_registry.hpp b/src/catch2/internal/catch_reporter_registry.hpp
index 3466bfd8..b0864265 100644
--- a/src/catch2/internal/catch_reporter_registry.hpp
+++ b/src/catch2/internal/catch_reporter_registry.hpp
@@ -21,7 +21,7 @@ namespace Catch {
         ReporterRegistry();
         ~ReporterRegistry() override; // = default, out of line to allow fwd decl
 
-        IEventListenerPtr create( std::string const& name, ReporterConfig const& config ) const override;
+        IEventListenerPtr create( std::string const& name, ReporterConfig&& config ) const override;
 
         void registerReporter( std::string const& name, IReporterFactoryPtr factory );
         void registerListener( Detail::unique_ptr<EventListenerFactory> factory );
diff --git a/src/catch2/reporters/catch_reporter_automake.hpp b/src/catch2/reporters/catch_reporter_automake.hpp
index f254be68..c544f337 100644
--- a/src/catch2/reporters/catch_reporter_automake.hpp
+++ b/src/catch2/reporters/catch_reporter_automake.hpp
@@ -15,7 +15,6 @@ namespace Catch {
     class AutomakeReporter final : public StreamingReporterBase {
     public:
         using StreamingReporterBase::StreamingReporterBase;
-
         ~AutomakeReporter() override;
 
         static std::string getDescription() {
diff --git a/src/catch2/reporters/catch_reporter_common_base.cpp b/src/catch2/reporters/catch_reporter_common_base.cpp
index aa2ab70a..68a24eef 100644
--- a/src/catch2/reporters/catch_reporter_common_base.cpp
+++ b/src/catch2/reporters/catch_reporter_common_base.cpp
@@ -14,11 +14,11 @@
 
 
 namespace Catch {
-    ReporterBase::ReporterBase( ReporterConfig const& config ):
+    ReporterBase::ReporterBase( ReporterConfig&& config ):
         IEventListener( config.fullConfig() ),
-        m_wrapped_stream( config.stream() ),
+        m_wrapped_stream( CATCH_MOVE(config).takeStream() ),
         m_stream( m_wrapped_stream->stream() ),
-        m_colour( makeColourImpl( config.colourMode(), m_wrapped_stream ) ),
+        m_colour( makeColourImpl( config.colourMode(), m_wrapped_stream.get() ) ),
         m_customOptions( config.customOptions() )
     {}
 
diff --git a/src/catch2/reporters/catch_reporter_common_base.hpp b/src/catch2/reporters/catch_reporter_common_base.hpp
index 8b2e6c08..5d80ca29 100644
--- a/src/catch2/reporters/catch_reporter_common_base.hpp
+++ b/src/catch2/reporters/catch_reporter_common_base.hpp
@@ -29,7 +29,7 @@ namespace Catch {
     class ReporterBase : public IEventListener {
     protected:
         //! The stream wrapper as passed to us by outside code
-        IStream* m_wrapped_stream;
+        Detail::unique_ptr<IStream> m_wrapped_stream;
         //! Cached output stream from `m_wrapped_stream` to reduce
         //! number of indirect calls needed to write output.
         std::ostream& m_stream;
@@ -39,7 +39,7 @@ namespace Catch {
         std::map<std::string, std::string> m_customOptions;
 
     public:
-        ReporterBase( ReporterConfig const& config );
+        ReporterBase( ReporterConfig&& config );
         ~ReporterBase() override; // = default;
 
         /**
diff --git a/src/catch2/reporters/catch_reporter_console.cpp b/src/catch2/reporters/catch_reporter_console.cpp
index 4ad1b990..b8e64fb3 100644
--- a/src/catch2/reporters/catch_reporter_console.cpp
+++ b/src/catch2/reporters/catch_reporter_console.cpp
@@ -354,8 +354,8 @@ public:
     }
 };
 
-ConsoleReporter::ConsoleReporter(ReporterConfig const& config)
-    : StreamingReporterBase(config),
+ConsoleReporter::ConsoleReporter(ReporterConfig&& config):
+    StreamingReporterBase( CATCH_MOVE( config ) ),
     m_tablePrinter(Detail::make_unique<TablePrinter>(m_stream,
         [&config]() -> std::vector<ColumnInfo> {
         if (config.fullConfig()->benchmarkNoAnalysis())
diff --git a/src/catch2/reporters/catch_reporter_console.hpp b/src/catch2/reporters/catch_reporter_console.hpp
index c67a11eb..12bfc0e2 100644
--- a/src/catch2/reporters/catch_reporter_console.hpp
+++ b/src/catch2/reporters/catch_reporter_console.hpp
@@ -20,7 +20,7 @@ namespace Catch {
         Detail::unique_ptr<TablePrinter> m_tablePrinter;
 
     public:
-        ConsoleReporter(ReporterConfig const& config);
+        ConsoleReporter(ReporterConfig&& config);
         ~ConsoleReporter() override;
         static std::string getDescription();
 
diff --git a/src/catch2/reporters/catch_reporter_junit.cpp b/src/catch2/reporters/catch_reporter_junit.cpp
index e12fc3ea..37546cd7 100644
--- a/src/catch2/reporters/catch_reporter_junit.cpp
+++ b/src/catch2/reporters/catch_reporter_junit.cpp
@@ -13,6 +13,7 @@
 #include <catch2/internal/catch_textflow.hpp>
 #include <catch2/interfaces/catch_interfaces_config.hpp>
 #include <catch2/catch_test_case_info.hpp>
+#include <catch2/internal/catch_move_and_forward.hpp>
 
 #include <cassert>
 #include <ctime>
@@ -68,8 +69,8 @@ namespace Catch {
 
     } // anonymous namespace
 
-    JunitReporter::JunitReporter( ReporterConfig const& _config )
-        :   CumulativeReporterBase( _config ),
+    JunitReporter::JunitReporter( ReporterConfig&& _config )
+        :   CumulativeReporterBase( CATCH_MOVE(_config) ),
             xml( m_stream )
         {
             m_preferences.shouldRedirectStdOut = true;
diff --git a/src/catch2/reporters/catch_reporter_junit.hpp b/src/catch2/reporters/catch_reporter_junit.hpp
index 6991c224..a45344de 100644
--- a/src/catch2/reporters/catch_reporter_junit.hpp
+++ b/src/catch2/reporters/catch_reporter_junit.hpp
@@ -17,7 +17,7 @@ namespace Catch {
 
     class JunitReporter final : public CumulativeReporterBase {
     public:
-        JunitReporter(ReporterConfig const& _config);
+        JunitReporter(ReporterConfig&& _config);
 
         ~JunitReporter() override = default;
 
diff --git a/src/catch2/reporters/catch_reporter_registrars.hpp b/src/catch2/reporters/catch_reporter_registrars.hpp
index d4bf8051..31ecb080 100644
--- a/src/catch2/reporters/catch_reporter_registrars.hpp
+++ b/src/catch2/reporters/catch_reporter_registrars.hpp
@@ -13,6 +13,7 @@
 #include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
 #include <catch2/internal/catch_compiler_capabilities.hpp>
 #include <catch2/internal/catch_unique_ptr.hpp>
+#include <catch2/internal/catch_move_and_forward.hpp>
 
 namespace Catch {
 
@@ -22,8 +23,8 @@ namespace Catch {
     template <typename T>
     class ReporterFactory : public IReporterFactory {
 
-        IEventListenerPtr create( ReporterConfig const& config ) const override {
-            return Detail::make_unique<T>( config );
+        IEventListenerPtr create( ReporterConfig&& config ) const override {
+            return Detail::make_unique<T>( CATCH_MOVE(config) );
         }
 
         std::string getDescription() const override {
diff --git a/src/catch2/reporters/catch_reporter_sonarqube.hpp b/src/catch2/reporters/catch_reporter_sonarqube.hpp
index e4c941be..32756b48 100644
--- a/src/catch2/reporters/catch_reporter_sonarqube.hpp
+++ b/src/catch2/reporters/catch_reporter_sonarqube.hpp
@@ -11,13 +11,14 @@
 #include <catch2/reporters/catch_reporter_cumulative_base.hpp>
 
 #include <catch2/internal/catch_xmlwriter.hpp>
+#include <catch2/internal/catch_move_and_forward.hpp>
 
 namespace Catch {
 
     class SonarQubeReporter final : public CumulativeReporterBase {
     public:
-        SonarQubeReporter(ReporterConfig const& config)
-        : CumulativeReporterBase(config)
+        SonarQubeReporter(ReporterConfig&& config)
+        : CumulativeReporterBase(CATCH_MOVE(config))
         , xml(m_stream) {
             m_preferences.shouldRedirectStdOut = true;
             m_preferences.shouldReportAllAssertions = true;
diff --git a/src/catch2/reporters/catch_reporter_tap.hpp b/src/catch2/reporters/catch_reporter_tap.hpp
index 0e11460b..b8c3208f 100644
--- a/src/catch2/reporters/catch_reporter_tap.hpp
+++ b/src/catch2/reporters/catch_reporter_tap.hpp
@@ -9,13 +9,14 @@
 #define CATCH_REPORTER_TAP_HPP_INCLUDED
 
 #include <catch2/reporters/catch_reporter_streaming_base.hpp>
+#include <catch2/internal/catch_move_and_forward.hpp>
 
 namespace Catch {
 
     class TAPReporter final : public StreamingReporterBase {
     public:
-        TAPReporter( ReporterConfig const& config ):
-            StreamingReporterBase( config ) {
+        TAPReporter( ReporterConfig&& config ):
+            StreamingReporterBase( CATCH_MOVE(config) ) {
             m_preferences.shouldReportAllAssertions = true;
         }
         ~TAPReporter() override = default;
diff --git a/src/catch2/reporters/catch_reporter_teamcity.hpp b/src/catch2/reporters/catch_reporter_teamcity.hpp
index 633870f0..5007193b 100644
--- a/src/catch2/reporters/catch_reporter_teamcity.hpp
+++ b/src/catch2/reporters/catch_reporter_teamcity.hpp
@@ -22,8 +22,8 @@ namespace Catch {
 
     class TeamCityReporter final : public StreamingReporterBase {
     public:
-        TeamCityReporter( ReporterConfig const& _config )
-        :   StreamingReporterBase( _config )
+        TeamCityReporter( ReporterConfig&& _config )
+        :   StreamingReporterBase( CATCH_MOVE(_config) )
         {
             m_preferences.shouldRedirectStdOut = true;
         }
diff --git a/src/catch2/reporters/catch_reporter_xml.cpp b/src/catch2/reporters/catch_reporter_xml.cpp
index 78fa8647..b34d7679 100644
--- a/src/catch2/reporters/catch_reporter_xml.cpp
+++ b/src/catch2/reporters/catch_reporter_xml.cpp
@@ -13,6 +13,7 @@
 #include <catch2/internal/catch_string_manip.hpp>
 #include <catch2/internal/catch_list.hpp>
 #include <catch2/catch_test_case_info.hpp>
+#include <catch2/internal/catch_move_and_forward.hpp>
 
 #if defined(_MSC_VER)
 #pragma warning(push)
@@ -22,8 +23,8 @@
 #endif
 
 namespace Catch {
-    XmlReporter::XmlReporter( ReporterConfig const& _config )
-    :   StreamingReporterBase( _config ),
+    XmlReporter::XmlReporter( ReporterConfig&& _config )
+    :   StreamingReporterBase( CATCH_MOVE(_config) ),
         m_xml(m_stream)
     {
         m_preferences.shouldRedirectStdOut = true;
diff --git a/src/catch2/reporters/catch_reporter_xml.hpp b/src/catch2/reporters/catch_reporter_xml.hpp
index 46dd667a..b557bfba 100644
--- a/src/catch2/reporters/catch_reporter_xml.hpp
+++ b/src/catch2/reporters/catch_reporter_xml.hpp
@@ -17,7 +17,7 @@
 namespace Catch {
     class XmlReporter : public StreamingReporterBase {
     public:
-        XmlReporter(ReporterConfig const& _config);
+        XmlReporter(ReporterConfig&& _config);
 
         ~XmlReporter() override;
 
diff --git a/tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp b/tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp
index 2ef629bf..c75d891e 100644
--- a/tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp
+++ b/tests/ExtraTests/X22-BenchmarksInCumulativeReporter.cpp
@@ -20,12 +20,13 @@
 #include <catch2/reporters/catch_reporter_registrars.hpp>
 
 #include <iostream>
+#include <utility>
 
 class CumulativeBenchmarkReporter final : public Catch::CumulativeReporterBase {
 
 public:
-    CumulativeBenchmarkReporter(Catch::ReporterConfig const& _config) :
-        CumulativeReporterBase(_config) {
+    CumulativeBenchmarkReporter(Catch::ReporterConfig&& _config) :
+        CumulativeReporterBase(std::move(_config)) {
         m_preferences.shouldReportAllAssertions = true;
     }
 
diff --git a/tests/ExtraTests/X23-CasingInReporterNames.cpp b/tests/ExtraTests/X23-CasingInReporterNames.cpp
index b5dcb403..0e13f205 100644
--- a/tests/ExtraTests/X23-CasingInReporterNames.cpp
+++ b/tests/ExtraTests/X23-CasingInReporterNames.cpp
@@ -19,11 +19,12 @@
 #include <catch2/reporters/catch_reporter_registrars.hpp>
 
 #include <iostream>
+#include <utility>
 
 class TestReporter : public Catch::StreamingReporterBase {
 public:
-    TestReporter(Catch::ReporterConfig const& _config):
-        StreamingReporterBase(_config) {
+    TestReporter(Catch::ReporterConfig&& _config):
+        StreamingReporterBase(std::move(_config)) {
         std::cout << "TestReporter constructed\n";
     }
 
diff --git a/tests/ExtraTests/X26-ReporterPreferencesForPassingAssertionsIsRespected.cpp b/tests/ExtraTests/X26-ReporterPreferencesForPassingAssertionsIsRespected.cpp
index af3a3202..01aca7c0 100644
--- a/tests/ExtraTests/X26-ReporterPreferencesForPassingAssertionsIsRespected.cpp
+++ b/tests/ExtraTests/X26-ReporterPreferencesForPassingAssertionsIsRespected.cpp
@@ -16,13 +16,14 @@
 #include <catch2/reporters/catch_reporter_registrars.hpp>
 
 #include <iostream>
+#include <utility>
 
 namespace {
 
   class TestReporter : public Catch::StreamingReporterBase {
   public:
-      TestReporter(Catch::ReporterConfig const& _config):
-          StreamingReporterBase(_config) {
+      TestReporter(Catch::ReporterConfig&& _config):
+          StreamingReporterBase(std::move(_config)) {
           m_preferences.shouldReportAllAssertions = false;
           std::cout << "X26 - TestReporter constructed\n";
       }
diff --git a/tests/ExtraTests/X27-CapturedStdoutInTestCaseEvents.cpp b/tests/ExtraTests/X27-CapturedStdoutInTestCaseEvents.cpp
index 871ed53c..cb29be0c 100644
--- a/tests/ExtraTests/X27-CapturedStdoutInTestCaseEvents.cpp
+++ b/tests/ExtraTests/X27-CapturedStdoutInTestCaseEvents.cpp
@@ -26,6 +26,7 @@
 
 #include <iostream>
 #include <string>
+#include <utility>
 
 class TestReporter : public Catch::StreamingReporterBase {
     std::string stdOutString( uint64_t iter ){
@@ -36,8 +37,8 @@ class TestReporter : public Catch::StreamingReporterBase {
     }
 
 public:
-    TestReporter( Catch::ReporterConfig const& _config ):
-        StreamingReporterBase( _config ) {
+    TestReporter( Catch::ReporterConfig&& _config ):
+        StreamingReporterBase( std::move(_config) ) {
         m_preferences.shouldRedirectStdOut = true;
         std::cout << "X27 - TestReporter constructed\n";
     }
diff --git a/tests/ExtraTests/X28-ListenersGetEventsBeforeReporters.cpp b/tests/ExtraTests/X28-ListenersGetEventsBeforeReporters.cpp
index ce2d31eb..c8102edb 100644
--- a/tests/ExtraTests/X28-ListenersGetEventsBeforeReporters.cpp
+++ b/tests/ExtraTests/X28-ListenersGetEventsBeforeReporters.cpp
@@ -19,7 +19,9 @@
 #include <catch2/reporters/catch_reporter_event_listener.hpp>
 #include <catch2/reporters/catch_reporter_registrars.hpp>
 #include <catch2/reporters/catch_reporter_streaming_base.hpp>
+
 #include <iostream>
+#include <utility>
 
 namespace {
 
@@ -54,8 +56,8 @@ namespace {
 
     class TestReporter : public Catch::StreamingReporterBase {
     public:
-        TestReporter( Catch::ReporterConfig const& _config ):
-            StreamingReporterBase( _config ) {
+        TestReporter( Catch::ReporterConfig&& _config ):
+            StreamingReporterBase( std::move(_config) ) {
             std::cout << "X28 - TestReporter constructed\n";
         }
 
diff --git a/tests/ExtraTests/X29-CustomArgumentsForReporters.cpp b/tests/ExtraTests/X29-CustomArgumentsForReporters.cpp
index 9721775d..d3af7dc7 100644
--- a/tests/ExtraTests/X29-CustomArgumentsForReporters.cpp
+++ b/tests/ExtraTests/X29-CustomArgumentsForReporters.cpp
@@ -25,8 +25,8 @@
 
 class TestReporter : public Catch::StreamingReporterBase {
 public:
-    TestReporter( Catch::ReporterConfig const& _config ):
-        StreamingReporterBase( _config ) {
+    TestReporter( Catch::ReporterConfig&& _config ):
+        StreamingReporterBase( std::move(_config) ) {
         std::cout << "X29 - TestReporter constructed\n";
     }
 
diff --git a/tests/SelfTest/Baselines/compact.sw.approved.txt b/tests/SelfTest/Baselines/compact.sw.approved.txt
index 96fb47ce..bac5115f 100644
--- a/tests/SelfTest/Baselines/compact.sw.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.approved.txt
@@ -1317,7 +1317,7 @@ CmdLine.tests.cpp:<line number>: passed: config.noThrow == false for: false == f
 CmdLine.tests.cpp:<line number>: passed: config.reporterSpecifications.empty() for: true
 CmdLine.tests.cpp:<line number>: passed: !(cfg.hasTestFilters()) for: !false
 CmdLine.tests.cpp:<line number>: passed: cfg.getReporterSpecs().size() == 1 for: 1 == 1
-CmdLine.tests.cpp:<line number>: passed: cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, {}, {}, {} } for: {?} == {?}
+CmdLine.tests.cpp:<line number>: passed: cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, std::string{}, Catch::ColourMode::PlatformDefault, {} } for: {?} == {?}
 CmdLine.tests.cpp:<line number>: passed: result for: {?}
 CmdLine.tests.cpp:<line number>: passed: cfg.hasTestFilters() for: true
 CmdLine.tests.cpp:<line number>: passed: cfg.testSpec().matches(*fakeTestCase("notIncluded")) == false for: false == false
diff --git a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
index c1ac5044..88c3dc5a 100644
--- a/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/compact.sw.multi.approved.txt
@@ -1315,7 +1315,7 @@ CmdLine.tests.cpp:<line number>: passed: config.noThrow == false for: false == f
 CmdLine.tests.cpp:<line number>: passed: config.reporterSpecifications.empty() for: true
 CmdLine.tests.cpp:<line number>: passed: !(cfg.hasTestFilters()) for: !false
 CmdLine.tests.cpp:<line number>: passed: cfg.getReporterSpecs().size() == 1 for: 1 == 1
-CmdLine.tests.cpp:<line number>: passed: cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, {}, {}, {} } for: {?} == {?}
+CmdLine.tests.cpp:<line number>: passed: cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, std::string{}, Catch::ColourMode::PlatformDefault, {} } for: {?} == {?}
 CmdLine.tests.cpp:<line number>: passed: result for: {?}
 CmdLine.tests.cpp:<line number>: passed: cfg.hasTestFilters() for: true
 CmdLine.tests.cpp:<line number>: passed: cfg.testSpec().matches(*fakeTestCase("notIncluded")) == false for: false == false
diff --git a/tests/SelfTest/Baselines/console.sw.approved.txt b/tests/SelfTest/Baselines/console.sw.approved.txt
index 938e96b0..d0e3e990 100644
--- a/tests/SelfTest/Baselines/console.sw.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.approved.txt
@@ -9438,7 +9438,7 @@ with expansion:
   1 == 1
 
 CmdLine.tests.cpp:<line number>: PASSED:
-  CHECK( cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, {}, {}, {} } )
+  CHECK( cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, std::string{}, Catch::ColourMode::PlatformDefault, {} } )
 with expansion:
   {?} == {?}
 
diff --git a/tests/SelfTest/Baselines/console.sw.multi.approved.txt b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
index dea69f25..512d4966 100644
--- a/tests/SelfTest/Baselines/console.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/console.sw.multi.approved.txt
@@ -9436,7 +9436,7 @@ with expansion:
   1 == 1
 
 CmdLine.tests.cpp:<line number>: PASSED:
-  CHECK( cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, {}, {}, {} } )
+  CHECK( cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, std::string{}, Catch::ColourMode::PlatformDefault, {} } )
 with expansion:
   {?} == {?}
 
diff --git a/tests/SelfTest/Baselines/tap.sw.approved.txt b/tests/SelfTest/Baselines/tap.sw.approved.txt
index 6c38f276..c4e166db 100644
--- a/tests/SelfTest/Baselines/tap.sw.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.approved.txt
@@ -2481,7 +2481,7 @@ ok {test-number} - !(cfg.hasTestFilters()) for: !false
 # Process can be configured on command line
 ok {test-number} - cfg.getReporterSpecs().size() == 1 for: 1 == 1
 # Process can be configured on command line
-ok {test-number} - cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, {}, {}, {} } for: {?} == {?}
+ok {test-number} - cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, std::string{}, Catch::ColourMode::PlatformDefault, {} } for: {?} == {?}
 # Process can be configured on command line
 ok {test-number} - result for: {?}
 # Process can be configured on command line
diff --git a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
index 35777386..54cb7d84 100644
--- a/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/tap.sw.multi.approved.txt
@@ -2479,7 +2479,7 @@ ok {test-number} - !(cfg.hasTestFilters()) for: !false
 # Process can be configured on command line
 ok {test-number} - cfg.getReporterSpecs().size() == 1 for: 1 == 1
 # Process can be configured on command line
-ok {test-number} - cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, {}, {}, {} } for: {?} == {?}
+ok {test-number} - cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, std::string{}, Catch::ColourMode::PlatformDefault, {} } for: {?} == {?}
 # Process can be configured on command line
 ok {test-number} - result for: {?}
 # Process can be configured on command line
diff --git a/tests/SelfTest/Baselines/xml.sw.approved.txt b/tests/SelfTest/Baselines/xml.sw.approved.txt
index d2710bd3..f250f926 100644
--- a/tests/SelfTest/Baselines/xml.sw.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.approved.txt
@@ -11476,7 +11476,7 @@ C
       </Expression>
       <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/CmdLine.tests.cpp" >
         <Original>
-          cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, {}, {}, {} }
+          cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, std::string{}, Catch::ColourMode::PlatformDefault, {} }
         </Original>
         <Expanded>
           {?} == {?}
diff --git a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
index 085a5cad..e19bbb1f 100644
--- a/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
+++ b/tests/SelfTest/Baselines/xml.sw.multi.approved.txt
@@ -11476,7 +11476,7 @@ C
       </Expression>
       <Expression success="true" type="CHECK" filename="tests/<exe-name>/IntrospectiveTests/CmdLine.tests.cpp" >
         <Original>
-          cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, {}, {}, {} }
+          cfg.getReporterSpecs()[0] == Catch::ReporterSpec{ expectedReporter, std::string{}, Catch::ColourMode::PlatformDefault, {} }
         </Original>
         <Expanded>
           {?} == {?}
diff --git a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
index 30cc3a0d..0f02af69 100644
--- a/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/CmdLine.tests.cpp
@@ -363,7 +363,10 @@ TEST_CASE( "Process can be configured on command line", "[config][command-line]"
 
         CHECK( cfg.getReporterSpecs().size() == 1 );
         CHECK( cfg.getReporterSpecs()[0] ==
-               Catch::ReporterSpec{ expectedReporter, {}, {}, {} } );
+               Catch::ReporterSpec{ expectedReporter,
+                                    std::string{},
+                                    Catch::ColourMode::PlatformDefault,
+                                    {} } );
     }
 
     SECTION("test lists") {
diff --git a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
index 84f2b689..e4554fca 100644
--- a/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
+++ b/tests/SelfTest/IntrospectiveTests/Reporters.tests.cpp
@@ -23,6 +23,7 @@
 #include <catch2/reporters/catch_reporter_event_listener.hpp>
 #include <catch2/reporters/catch_reporter_streaming_base.hpp>
 #include <catch2/reporters/catch_reporter_multi.hpp>
+#include <catch2/internal/catch_move_and_forward.hpp>
 
 #include <sstream>
 
@@ -34,6 +35,15 @@ namespace {
     private:
         std::stringstream sstr;
     };
+
+    //! config must outlive the function
+    Catch::ReporterConfig makeDummyRepConfig( Catch::Config const& config ) {
+        return Catch::ReporterConfig{
+            &config,
+            Catch::Detail::make_unique<StringIStream>(),
+            Catch::ColourMode::None,
+            {} };
+    }
 }
 
 TEST_CASE( "The default listing implementation write to provided stream",
@@ -85,20 +95,19 @@ TEST_CASE( "Reporter's write listings to provided stream", "[reporters]" ) {
 
     for (auto const& factory : factories) {
         INFO("Tested reporter: " << factory.first);
-        StringIStream sstream;
+        auto sstream = Catch::Detail::make_unique<StringIStream>();
+        auto& sstreamRef = *sstream.get();
 
-        Catch::ConfigData config_data;
-        Catch::Config config( config_data );
-        Catch::ReporterConfig rep_config(
-            &config, &sstream, Catch::ColourMode::None, {} );
-        auto reporter = factory.second->create( rep_config );
+        Catch::Config config( Catch::ConfigData{} );
+        auto reporter = factory.second->create( Catch::ReporterConfig{
+            &config, CATCH_MOVE( sstream ), Catch::ColourMode::None, {} } );
 
         DYNAMIC_SECTION( factory.first << " reporter lists tags" ) {
             std::vector<Catch::TagInfo> tags(1);
             tags[0].add("fakeTag"_catch_sr);
             reporter->listTags(tags);
 
-            auto listingString = sstream.str();
+            auto listingString = sstreamRef.str();
             REQUIRE_THAT(listingString, ContainsSubstring("fakeTag"s));
         }
 
@@ -107,7 +116,7 @@ TEST_CASE( "Reporter's write listings to provided stream", "[reporters]" ) {
                 { { "fake reporter", "fake description" } } );
             reporter->listReporters(reporters);
 
-            auto listingString = sstream.str();
+            auto listingString = sstreamRef.str();
             REQUIRE_THAT(listingString, ContainsSubstring("fake reporter"s));
         }
 
@@ -119,7 +128,7 @@ TEST_CASE( "Reporter's write listings to provided stream", "[reporters]" ) {
             std::vector<Catch::TestCaseHandle> tests({ {&fakeInfo, nullptr} });
             reporter->listTests(tests);
 
-            auto listingString = sstream.str();
+            auto listingString = sstreamRef.str();
             REQUIRE_THAT( listingString,
                           ContainsSubstring( "fake test name"s ) &&
                               ContainsSubstring( "fakeTestTag"s ) );
@@ -159,8 +168,8 @@ namespace {
     public:
         MockReporter( std::string witness,
                       std::vector<std::string>& recorder,
-                      Catch::ReporterConfig const& config ):
-            StreamingReporterBase( config ),
+                      Catch::ReporterConfig&& config ):
+            StreamingReporterBase( CATCH_MOVE(config) ),
             m_witness( witness ),
             m_recorder( recorder )
         {}
@@ -173,25 +182,20 @@ namespace {
 
 TEST_CASE("Multireporter calls reporters and listeners in correct order",
           "[reporters][multi-reporter]") {
-
-    Catch::ConfigData config_data;
-    Catch::Config config( config_data );
-    StringIStream sstream;
-    Catch::ReporterConfig rep_config(
-        &config, &sstream, Catch::ColourMode::None, {} );
+    Catch::Config config( Catch::ConfigData{} );
 
     // We add reporters before listeners, to check that internally they
     // get sorted properly, and listeners are called first anyway.
     Catch::MultiReporter multiReporter( &config );
     std::vector<std::string> records;
     multiReporter.addReporter( Catch::Detail::make_unique<MockReporter>(
-        "Goodbye", records, rep_config ) );
+        "Goodbye", records, makeDummyRepConfig(config) ) );
     multiReporter.addListener(
         Catch::Detail::make_unique<MockListener>( "Hello", records, &config ) );
     multiReporter.addListener(
         Catch::Detail::make_unique<MockListener>( "world", records, &config ) );
     multiReporter.addReporter( Catch::Detail::make_unique<MockReporter>(
-        "world", records, rep_config ) );
+        "world", records, makeDummyRepConfig(config) ) );
     multiReporter.testRunStarting( { "" } );
 
     std::vector<std::string> expected( { "Hello", "world", "Goodbye", "world" } );
@@ -217,8 +221,8 @@ namespace {
     public:
         PreferenceReporter( bool redirectStdout,
                             bool reportAllAssertions,
-                            Catch::ReporterConfig const& config ):
-            StreamingReporterBase( config ) {
+                            Catch::ReporterConfig&& config ):
+            StreamingReporterBase( CATCH_MOVE(config) ) {
             m_preferences.shouldRedirectStdOut = redirectStdout;
             m_preferences.shouldReportAllAssertions = reportAllAssertions;
         }
@@ -228,11 +232,7 @@ namespace {
 TEST_CASE("Multireporter updates ReporterPreferences properly",
           "[reporters][multi-reporter]") {
 
-    Catch::ConfigData config_data;
-    Catch::Config config( config_data );
-    StringIStream sstream;
-    Catch::ReporterConfig rep_config(
-        &config, &sstream, Catch::ColourMode::None, {} );
+    Catch::Config config( Catch::ConfigData{} );
     Catch::MultiReporter multiReporter( &config );
 
     // Post init defaults
@@ -261,19 +261,19 @@ TEST_CASE("Multireporter updates ReporterPreferences properly",
     SECTION( "Adding reporters" ) {
         multiReporter.addReporter(
             Catch::Detail::make_unique<PreferenceReporter>(
-                true, false, rep_config ) );
+                true, false, makeDummyRepConfig(config) ) );
         REQUIRE( multiReporter.getPreferences().shouldRedirectStdOut == true );
         REQUIRE( multiReporter.getPreferences().shouldReportAllAssertions == false );
 
         multiReporter.addReporter(
             Catch::Detail::make_unique<PreferenceReporter>(
-                false, true, rep_config ) );
+                false, true, makeDummyRepConfig( config ) ) );
         REQUIRE( multiReporter.getPreferences().shouldRedirectStdOut == true );
         REQUIRE( multiReporter.getPreferences().shouldReportAllAssertions == true );
 
         multiReporter.addReporter(
             Catch::Detail::make_unique<PreferenceReporter>(
-                false, false, rep_config ) );
+                false, false, makeDummyRepConfig( config ) ) );
         REQUIRE( multiReporter.getPreferences().shouldRedirectStdOut == true );
         REQUIRE( multiReporter.getPreferences().shouldReportAllAssertions == true );
     }
@@ -281,7 +281,7 @@ TEST_CASE("Multireporter updates ReporterPreferences properly",
 
 namespace {
     class TestReporterFactory : public Catch::IReporterFactory {
-        Catch::IEventListenerPtr create( Catch::ReporterConfig const& ) const override {
+        Catch::IEventListenerPtr create( Catch::ReporterConfig&& ) const override {
             CATCH_INTERNAL_ERROR(
                 "This factory should never create a reporter" );
         }