diff options
| author | Martin Hořeňovský | 2019-12-08 11:31:47 +0100 |
|---|---|---|
| committer | Martin Hořeňovský | 2019-12-08 11:31:47 +0100 |
| commit | 248f922465309caa549c126f795f909e8cd69a1e (patch) | |
| tree | 4e146c298928092f79076c9c6261f48fcf0f4fcf | |
| parent | 91ee07e08c5a72536834960ecf2527fa90244046 (diff) | |
| download | catch3-248f922465309caa549c126f795f909e8cd69a1e.tar.gz | |
Cleanup impl and main from the main header
| -rw-r--r-- | src/CMakeLists.txt | 6 | ||||
| -rw-r--r-- | src/catch2/catch.hpp | 36 | ||||
| -rw-r--r-- | src/catch2/catch_reporter_registry.cpp | 8 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_automake.cpp | 12 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_automake.hpp | 12 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_sonarqube.cpp | 12 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_sonarqube.hpp | 15 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_tap.cpp | 12 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_tap.hpp | 14 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_teamcity.cpp | 12 | ||||
| -rw-r--r-- | src/catch2/reporters/catch_reporter_teamcity.hpp | 18 | ||||
| -rw-r--r-- | tests/SelfTest/TestMain.cpp | 22 |
12 files changed, 80 insertions, 99 deletions
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 <catch2/catch_suppress_warnings.h> -#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 <catch2/catch_platform.h> -#ifdef CATCH_IMPL -# ifndef CLARA_CONFIG_MAIN -# define CLARA_CONFIG_MAIN_NOT_DEFINED -# define CLARA_CONFIG_MAIN -# endif -#endif - #include <catch2/catch_user_interfaces.h> #include <catch2/catch_tag_alias_autoregistrar.h> #include <catch2/catch_test_registry.h> @@ -74,10 +50,7 @@ #include <catch2/catch_objc.hpp> #endif -// Benchmarking needs the externally-facing parts of reporters to work -#if defined(CATCH_CONFIG_EXTERNAL_INTERFACES) || defined(CATCH_CONFIG_ENABLE_BENCHMARKING) #include <catch2/catch_external_interfaces.h> -#endif #if defined(CATCH_CONFIG_ENABLE_BENCHMARKING) #include <catch2/benchmark/catch_benchmark.hpp> @@ -85,15 +58,6 @@ #endif // ! CATCH_CONFIG_IMPL_ONLY -#ifdef CATCH_IMPL -#include <catch2/catch_impl.hpp> -#endif - -#ifdef CATCH_CONFIG_MAIN -#include <catch2/catch_default_main.hpp> -#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 <catch2/catch_reporter_registry.h> #include <catch2/catch_reporter_registrars.hpp> +#include <catch2/reporters/catch_reporter_automake.hpp> #include <catch2/reporters/catch_reporter_compact.h> #include <catch2/reporters/catch_reporter_console.h> #include <catch2/reporters/catch_reporter_junit.h> +#include <catch2/reporters/catch_reporter_sonarqube.hpp> +#include <catch2/reporters/catch_reporter_tap.hpp> +#include <catch2/reporters/catch_reporter_teamcity.hpp> #include <catch2/reporters/catch_reporter_xml.h> namespace Catch { ReporterRegistry::ReporterRegistry(): m_factories({ + {"automake", std::make_shared<ReporterFactory<AutomakeReporter>>() }, {"compact", std::make_shared<ReporterFactory<CompactReporter>>() }, {"console", std::make_shared<ReporterFactory<ConsoleReporter>>() }, {"junit", std::make_shared<ReporterFactory<JunitReporter>>() }, + {"sonarqube", std::make_shared<ReporterFactory<SonarQubeReporter>>() }, + {"tap", std::make_shared<ReporterFactory<TAPReporter>>() }, + {"teamcity", std::make_shared<ReporterFactory<TeamCityReporter>>() }, {"xml", std::make_shared<ReporterFactory<XmlReporter>>() }, }) {} 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 <catch2/reporters/catch_reporter_automake.hpp> + +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 <catch2/reporters/catch_reporter_bases.hpp> 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 <catch2/reporters/catch_reporter_sonarqube.hpp> + +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 <catch2/catch_xmlwriter.h> +#include <catch2/reporters/catch_reporter_bases.hpp> #include <map> @@ -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 <catch2/reporters/catch_reporter_tap.hpp> + +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 <catch2/catch_console_colour.h> +#include <catch2/reporters/catch_reporter_bases.hpp> #include <algorithm> @@ -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 <catch2/reporters/catch_reporter_teamcity.hpp> + +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 <catch2/catch_config.hpp> +#include <catch2/catch_text.h> +#include <catch2/catch_timer.h> +#include <catch2/reporters/catch_reporter_bases.hpp> #include <cstring> @@ -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 <catch2/catch.hpp> - -// These reporters are not included in the single include, so must be included separately in the main file -#include <catch2/reporters/catch_reporter_teamcity.hpp> -#include <catch2/reporters/catch_reporter_tap.hpp> -#include <catch2/reporters/catch_reporter_automake.hpp> -#include <catch2/reporters/catch_reporter_sonarqube.hpp> - +#include <catch2/catch_tag_alias_autoregistrar.h> // 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 <catch2/reporters/catch_reporter_bases.hpp> + struct TestListener : Catch::TestEventListenerBase { - using TestEventListenerBase::TestEventListenerBase; // inherit constructor + using TestEventListenerBase::TestEventListenerBase; }; + +#include <catch2/catch_reporter_registrars.hpp> + CATCH_REGISTER_LISTENER( TestListener ) +#include <catch2/catch_default_main.hpp> |