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

Tweak to reporter registrar to make sure generated name is unique

Commit
245be004feefb43c451917c5d0446c39430dcb1e
Author
Phil Nash ·
Parents
27fdf01b7636

Files · Download .tar.gz

Changes

 catch_reporter_basic.hpp             | 2 ++
 catch_reporter_junit.hpp             | 2 ++
 catch_reporter_xml.hpp               | 2 ++
 catch_runner.hpp                     | 4 ----
 internal/catch_commandline.hpp       | 4 ++++
 internal/catch_reporter_registry.hpp | 2 +-
 6 files changed, 11 insertions(+), 5 deletions(-)

diff --git a/catch_reporter_basic.hpp b/catch_reporter_basic.hpp
index 427b4d01..37e5a1d8 100644
--- a/catch_reporter_basic.hpp
+++ b/catch_reporter_basic.hpp
@@ -169,6 +169,8 @@ namespace Catch
         const ReporterConfig& m_config;
         bool m_firstSectionInTestCase;
     };
+
+    CATCH_REGISTER_REPORTER( "basic", BasicReporter );
     
 } // end namespace Catch
     
diff --git a/catch_reporter_junit.hpp b/catch_reporter_junit.hpp
index 1d9f39ca..e71a47d2 100644
--- a/catch_reporter_junit.hpp
+++ b/catch_reporter_junit.hpp
@@ -254,6 +254,8 @@ namespace Catch
         std::ostringstream m_stdOut;
         std::ostringstream m_stdErr;
     };
+
+    CATCH_REGISTER_REPORTER( "junit", JunitReporter );
     
 } // end namespace Catch
 
diff --git a/catch_reporter_xml.hpp b/catch_reporter_xml.hpp
index 31ec426f..848eb93e 100644
--- a/catch_reporter_xml.hpp
+++ b/catch_reporter_xml.hpp
@@ -150,6 +150,8 @@ namespace Catch
         XmlWriter m_xml;
     };
 
+    CATCH_REGISTER_REPORTER( "xml", XmlReporter );
+
 } // end namespace Catch
 
 #endif // TWOBLUECUBES_CATCH_REPORTER_XML_HPP_INCLUDED
diff --git a/catch_runner.hpp b/catch_runner.hpp
index 37060b99..ea0dbfa0 100644
--- a/catch_runner.hpp
+++ b/catch_runner.hpp
@@ -23,10 +23,6 @@ namespace Catch
 {
     inline int Main( int argc, char * const argv[] )
     {
-        ReporterRegistry::instance().registerReporter<BasicReporter>( "basic" );
-        ReporterRegistry::instance().registerReporter<XmlReporter>( "xml" );
-        ReporterRegistry::instance().registerReporter<JunitReporter>( "junit" );
-
         RunnerConfig config;
         ArgParser( argc, argv, config );     
         
diff --git a/internal/catch_commandline.hpp b/internal/catch_commandline.hpp
index 3e80603a..dac7a567 100644
--- a/internal/catch_commandline.hpp
+++ b/internal/catch_commandline.hpp
@@ -18,6 +18,10 @@
 
 namespace Catch
 {
+    // !TBD: This could be refactored to be more "declarative"
+    //       have a table up front that relates the mode, option strings, # arguments, names of arguments
+    //       - may not be worth it at this scale
+    
     // -l, --list tests [xml] lists available tests (optionally in xml)
     // -l, --list reporters [xml] lists available reports (optionally in xml)
     // -l, --list all [xml] lists available tests and reports (optionally in xml)
diff --git a/internal/catch_reporter_registry.hpp b/internal/catch_reporter_registry.hpp
index b9996774..455108fb 100644
--- a/internal/catch_reporter_registry.hpp
+++ b/internal/catch_reporter_registry.hpp
@@ -180,6 +180,6 @@ namespace Catch
     }; 
 }
 
-#define CATCH_REGISTER_REPORTER( name, reporterType ) Catch::ReporterRegistrar<reporterType> INTERNAL_CATCH_UNIQUE_NAME(  catch_internal_ReporterReg )( name );
+#define CATCH_REGISTER_REPORTER( name, reporterType ) Catch::ReporterRegistrar<reporterType> catch_internal_RegistrarFor##reporterType( name );
 
 #endif // TWOBLUECUBES_CATCH_REPORTER_REGISTRY_HPP_INCLUDED
\ No newline at end of file