Cleanup impl and main from the main header

This commit is contained in:
Martin Hořeňovský 2019-12-08 11:31:47 +01:00
parent 91ee07e08c
commit 248f922465
No known key found for this signature in database
GPG Key ID: DE48307B8B0D381A
12 changed files with 80 additions and 99 deletions

View File

@ -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})

View File

@ -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

View File

@ -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>>() },
}) {}

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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
#endif // CATCH_REPORTER_SONARQUBE_HPP_INCLUDED

View File

@ -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

View File

@ -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

View File

@ -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

View File

@ -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__

View File

@ -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>