From 248f922465309caa549c126f795f909e8cd69a1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Sun, 8 Dec 2019 11:31:47 +0100 Subject: [PATCH] Cleanup impl and main from the main header --- src/CMakeLists.txt | 6 +++- src/catch2/catch.hpp | 36 ------------------- src/catch2/catch_reporter_registry.cpp | 8 +++++ .../reporters/catch_reporter_automake.cpp | 12 +++++++ .../reporters/catch_reporter_automake.hpp | 12 +------ .../reporters/catch_reporter_sonarqube.cpp | 12 +++++++ .../reporters/catch_reporter_sonarqube.hpp | 15 ++------ src/catch2/reporters/catch_reporter_tap.cpp | 12 +++++++ src/catch2/reporters/catch_reporter_tap.hpp | 14 ++------ .../reporters/catch_reporter_teamcity.cpp | 12 +++++++ .../reporters/catch_reporter_teamcity.hpp | 18 +++------- tests/SelfTest/TestMain.cpp | 22 +++++------- 12 files changed, 80 insertions(+), 99 deletions(-) create mode 100644 src/catch2/reporters/catch_reporter_automake.cpp create mode 100644 src/catch2/reporters/catch_reporter_sonarqube.cpp create mode 100644 src/catch2/reporters/catch_reporter_tap.cpp create mode 100644 src/catch2/reporters/catch_reporter_teamcity.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index e33466a2..3909d481 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -195,17 +195,21 @@ set(REPORTER_HEADERS ${SOURCES_DIR}/reporters/catch_reporter_console.h ${SOURCES_DIR}/reporters/catch_reporter_junit.h ${SOURCES_DIR}/reporters/catch_reporter_listening.h + ${SOURCES_DIR}/reporters/catch_reporter_sonarqube.hpp ${SOURCES_DIR}/reporters/catch_reporter_tap.hpp ${SOURCES_DIR}/reporters/catch_reporter_teamcity.hpp ${SOURCES_DIR}/reporters/catch_reporter_xml.h - ${SOURCES_DIR}/reporters/catch_reporter_sonarqube.hpp ) set(REPORTER_SOURCES + ${SOURCES_DIR}/reporters/catch_reporter_automake.cpp ${SOURCES_DIR}/reporters/catch_reporter_bases.cpp ${SOURCES_DIR}/reporters/catch_reporter_compact.cpp ${SOURCES_DIR}/reporters/catch_reporter_console.cpp ${SOURCES_DIR}/reporters/catch_reporter_junit.cpp ${SOURCES_DIR}/reporters/catch_reporter_listening.cpp + ${SOURCES_DIR}/reporters/catch_reporter_sonarqube.cpp + ${SOURCES_DIR}/reporters/catch_reporter_tap.cpp + ${SOURCES_DIR}/reporters/catch_reporter_teamcity.cpp ${SOURCES_DIR}/reporters/catch_reporter_xml.cpp ) set(REPORTER_FILES ${REPORTER_HEADERS} ${REPORTER_SOURCES}) diff --git a/src/catch2/catch.hpp b/src/catch2/catch.hpp index e8936937..5e3ea8fb 100644 --- a/src/catch2/catch.hpp +++ b/src/catch2/catch.hpp @@ -21,33 +21,9 @@ #include -#if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) -# define CATCH_IMPL -# define CATCH_CONFIG_ALL_PARTS -#endif - -// In the impl file, we want to have access to all parts of the headers -// Can also be used to sanely support PCHs -#if defined(CATCH_CONFIG_ALL_PARTS) -# define CATCH_CONFIG_EXTERNAL_INTERFACES -# if defined(CATCH_CONFIG_DISABLE_MATCHERS) -# undef CATCH_CONFIG_DISABLE_MATCHERS -# endif -# if !defined(CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER) -# define CATCH_CONFIG_ENABLE_CHRONO_STRINGMAKER -# endif -#endif - #if !defined(CATCH_CONFIG_IMPL_ONLY) #include -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - #include #include #include @@ -74,10 +50,7 @@ #include #endif -// Benchmarking needs the externally-facing parts of reporters to work -#if defined(CATCH_CONFIG_EXTERNAL_INTERFACES) || defined(CATCH_CONFIG_ENABLE_BENCHMARKING) #include -#endif #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) #include @@ -85,15 +58,6 @@ #endif // ! CATCH_CONFIG_IMPL_ONLY -#ifdef CATCH_IMPL -#include -#endif - -#ifdef CATCH_CONFIG_MAIN -#include -#endif - - #if !defined(CATCH_CONFIG_IMPL_ONLY) #ifdef CLARA_CONFIG_MAIN_NOT_DEFINED diff --git a/src/catch2/catch_reporter_registry.cpp b/src/catch2/catch_reporter_registry.cpp index 3808e5b3..92f0be89 100644 --- a/src/catch2/catch_reporter_registry.cpp +++ b/src/catch2/catch_reporter_registry.cpp @@ -7,18 +7,26 @@ #include #include +#include #include #include #include +#include +#include +#include #include namespace Catch { ReporterRegistry::ReporterRegistry(): m_factories({ + {"automake", std::make_shared>() }, {"compact", std::make_shared>() }, {"console", std::make_shared>() }, {"junit", std::make_shared>() }, + {"sonarqube", std::make_shared>() }, + {"tap", std::make_shared>() }, + {"teamcity", std::make_shared>() }, {"xml", std::make_shared>() }, }) {} diff --git a/src/catch2/reporters/catch_reporter_automake.cpp b/src/catch2/reporters/catch_reporter_automake.cpp new file mode 100644 index 00000000..b8c3f39a --- /dev/null +++ b/src/catch2/reporters/catch_reporter_automake.cpp @@ -0,0 +1,12 @@ +/* + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include + +namespace Catch { + + AutomakeReporter::~AutomakeReporter() {} + +} // end namespace Catch diff --git a/src/catch2/reporters/catch_reporter_automake.hpp b/src/catch2/reporters/catch_reporter_automake.hpp index 45ff68d0..d4ba82b7 100644 --- a/src/catch2/reporters/catch_reporter_automake.hpp +++ b/src/catch2/reporters/catch_reporter_automake.hpp @@ -8,11 +8,7 @@ #ifndef TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED -// Don't #include any Catch headers here - we can assume they are already -// included before this header. -// This is not good practice in general but is necessary in this case so this -// file can be distributed as a single header that works with the main -// Catch single header. +#include namespace Catch { @@ -51,12 +47,6 @@ namespace Catch { }; -#ifdef CATCH_IMPL - AutomakeReporter::~AutomakeReporter() {} -#endif - - CATCH_REGISTER_REPORTER( "automake", AutomakeReporter) - } // end namespace Catch #endif // TWOBLUECUBES_CATCH_REPORTER_AUTOMAKE_HPP_INCLUDED diff --git a/src/catch2/reporters/catch_reporter_sonarqube.cpp b/src/catch2/reporters/catch_reporter_sonarqube.cpp new file mode 100644 index 00000000..581920ff --- /dev/null +++ b/src/catch2/reporters/catch_reporter_sonarqube.cpp @@ -0,0 +1,12 @@ +/* + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include + +namespace Catch { + + SonarQubeReporter::~SonarQubeReporter() {} + +} // end namespace Catch diff --git a/src/catch2/reporters/catch_reporter_sonarqube.hpp b/src/catch2/reporters/catch_reporter_sonarqube.hpp index aead69e9..e23ceb1b 100644 --- a/src/catch2/reporters/catch_reporter_sonarqube.hpp +++ b/src/catch2/reporters/catch_reporter_sonarqube.hpp @@ -8,12 +8,8 @@ #ifndef CATCH_REPORTER_SONARQUBE_HPP_INCLUDED #define CATCH_REPORTER_SONARQUBE_HPP_INCLUDED - -// Don't #include any Catch headers here - we can assume they are already -// included before this header. -// This is not good practice in general but is necessary in this case so this -// file can be distributed as a single header that works with the main -// Catch single header. +#include +#include #include @@ -170,12 +166,7 @@ namespace Catch { XmlWriter xml; }; -#ifdef CATCH_IMPL - SonarQubeReporter::~SonarQubeReporter() {} -#endif - - CATCH_REGISTER_REPORTER( "sonarqube", SonarQubeReporter ) } // end namespace Catch -#endif // CATCH_REPORTER_SONARQUBE_HPP_INCLUDED \ No newline at end of file +#endif // CATCH_REPORTER_SONARQUBE_HPP_INCLUDED diff --git a/src/catch2/reporters/catch_reporter_tap.cpp b/src/catch2/reporters/catch_reporter_tap.cpp new file mode 100644 index 00000000..98cc58be --- /dev/null +++ b/src/catch2/reporters/catch_reporter_tap.cpp @@ -0,0 +1,12 @@ +/* + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include + +namespace Catch { + + TAPReporter::~TAPReporter() {} + +} // end namespace Catch diff --git a/src/catch2/reporters/catch_reporter_tap.hpp b/src/catch2/reporters/catch_reporter_tap.hpp index 2e026fdf..a9b72dcb 100644 --- a/src/catch2/reporters/catch_reporter_tap.hpp +++ b/src/catch2/reporters/catch_reporter_tap.hpp @@ -8,12 +8,8 @@ #ifndef TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED - -// Don't #include any Catch headers here - we can assume they are already -// included before this header. -// This is not good practice in general but is necessary in this case so this -// file can be distributed as a single header that works with the main -// Catch single header. +#include +#include #include @@ -242,12 +238,6 @@ namespace Catch { } }; -#ifdef CATCH_IMPL - TAPReporter::~TAPReporter() {} -#endif - - CATCH_REGISTER_REPORTER( "tap", TAPReporter ) - } // end namespace Catch #endif // TWOBLUECUBES_CATCH_REPORTER_TAP_HPP_INCLUDED diff --git a/src/catch2/reporters/catch_reporter_teamcity.cpp b/src/catch2/reporters/catch_reporter_teamcity.cpp new file mode 100644 index 00000000..d14abe3a --- /dev/null +++ b/src/catch2/reporters/catch_reporter_teamcity.cpp @@ -0,0 +1,12 @@ +/* + * Distributed under the Boost Software License, Version 1.0. (See accompanying + * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) + */ + +#include + +namespace Catch { + + TeamCityReporter::~TeamCityReporter() {} + +} // end namespace Catch diff --git a/src/catch2/reporters/catch_reporter_teamcity.hpp b/src/catch2/reporters/catch_reporter_teamcity.hpp index 0f81c341..e94035be 100644 --- a/src/catch2/reporters/catch_reporter_teamcity.hpp +++ b/src/catch2/reporters/catch_reporter_teamcity.hpp @@ -8,11 +8,10 @@ #ifndef TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED #define TWOBLUECUBES_CATCH_REPORTER_TEAMCITY_HPP_INCLUDED -// Don't #include any Catch headers here - we can assume they are already -// included before this header. -// This is not good practice in general but is necessary in this case so this -// file can be distributed as a single header that works with the main -// Catch single header. +#include +#include +#include +#include #include @@ -46,8 +45,7 @@ namespace Catch { return "Reports test results as TeamCity service messages"; } - void skipTest( TestCaseInfo const& /* testInfo */ ) override { - } + void skipTest( TestCaseInfo const& /* testInfo */ ) override {} void noMatchingTestCases( std::string const& /* spec */ ) override {} @@ -205,12 +203,6 @@ namespace Catch { Timer m_testTimer; }; -#ifdef CATCH_IMPL - TeamCityReporter::~TeamCityReporter() {} -#endif - - CATCH_REGISTER_REPORTER( "teamcity", TeamCityReporter ) - } // end namespace Catch #ifdef __clang__ diff --git a/tests/SelfTest/TestMain.cpp b/tests/SelfTest/TestMain.cpp index 4bb6d7aa..c7cc5fd0 100644 --- a/tests/SelfTest/TestMain.cpp +++ b/tests/SelfTest/TestMain.cpp @@ -1,34 +1,28 @@ /* - * Created by Phil on 22/10/2010. - * Copyright 2010 Two Blue Cubes Ltd - * * Distributed under the Boost Software License, Version 1.0. (See accompanying * file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) */ -#define CATCH_CONFIG_MAIN -#include - -// These reporters are not included in the single include, so must be included separately in the main file -#include -#include -#include -#include - +#include // Some example tag aliases CATCH_REGISTER_TAG_ALIAS( "[@nhf]", "[failing]~[.]" ) CATCH_REGISTER_TAG_ALIAS( "[@tricky]", "[tricky]~[.]" ) - #ifdef __clang__ # pragma clang diagnostic ignored "-Wpadded" # pragma clang diagnostic ignored "-Wweak-vtables" # pragma clang diagnostic ignored "-Wc++98-compat" #endif +#include + struct TestListener : Catch::TestEventListenerBase { - using TestEventListenerBase::TestEventListenerBase; // inherit constructor + using TestEventListenerBase::TestEventListenerBase; }; + +#include + CATCH_REGISTER_LISTENER( TestListener ) +#include