From 24af32f37871bbd3856c6f3021ba3639cb301b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Thu, 17 Aug 2017 20:21:06 +0200 Subject: [PATCH] Add define that pulls in reporter and listeners interfaces This allows users to define reporters and listeners in files different from the main file. Related to #991, #986 --- CMakeLists.txt | 1 + include/catch.hpp | 5 +++++ include/internal/catch_external_interfaces.h | 13 +++++++++++++ include/internal/catch_reporter_registrars.hpp | 3 ++- 4 files changed, 21 insertions(+), 1 deletion(-) create mode 100644 include/internal/catch_external_interfaces.h diff --git a/CMakeLists.txt b/CMakeLists.txt index c98c326b..b538f5d7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -138,6 +138,7 @@ set(INTERNAL_HEADERS ${HEADER_DIR}/internal/catch_enforce.h ${HEADER_DIR}/internal/catch_errno_guard.h ${HEADER_DIR}/internal/catch_exception_translator_registry.h + ${HEADER_DIR}/internal/catch_external_interfaces.h ${HEADER_DIR}/internal/catch_fatal_condition.h ${HEADER_DIR}/internal/catch_impl.hpp ${HEADER_DIR}/internal/catch_interfaces_capture.h diff --git a/include/catch.hpp b/include/catch.hpp index 4b149b4e..db1f366c 100644 --- a/include/catch.hpp +++ b/include/catch.hpp @@ -19,6 +19,7 @@ #if defined(CATCH_CONFIG_MAIN) || defined(CATCH_CONFIG_RUNNER) # define CATCH_IMPL +# define CATCH_CONFIG_EXTERNAL_INTERFACES #endif #ifdef CATCH_IMPL @@ -52,6 +53,10 @@ #include "internal/catch_objc.hpp" #endif +#ifdef CATCH_CONFIG_EXTERNAL_INTERFACES +#include "internal/catch_external_interfaces.h" +#endif + #ifdef CATCH_IMPL #include "internal/catch_impl.hpp" #endif diff --git a/include/internal/catch_external_interfaces.h b/include/internal/catch_external_interfaces.h new file mode 100644 index 00000000..7243ed7b --- /dev/null +++ b/include/internal/catch_external_interfaces.h @@ -0,0 +1,13 @@ +/* + * Created by Martin on 17/08/2017. + * + * 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) + */ +#ifndef TWOBLUECUBES_CATCH_EXTERNAL_INTERFACES_H +#define TWOBLUECUBES_CATCH_EXTERNAL_INTERFACES_H + +#include "../reporters/catch_reporter_bases.hpp" +#include "catch_reporter_registrars.hpp" + +#endif // TWOBLUECUBES_CATCH_EXTERNAL_INTERFACES_H diff --git a/include/internal/catch_reporter_registrars.hpp b/include/internal/catch_reporter_registrars.hpp index 74ee494e..e0db392b 100644 --- a/include/internal/catch_reporter_registrars.hpp +++ b/include/internal/catch_reporter_registrars.hpp @@ -1,3 +1,4 @@ + /* * Created by Phil on 31/12/2010. * Copyright 2010 Two Blue Cubes Ltd. All rights reserved. @@ -39,7 +40,7 @@ namespace Catch { class ListenerFactory : public IReporterFactory { virtual IStreamingReporterPtr create( ReporterConfig const& config ) const override { - return std::make_shared( config ); + return std::unique_ptr( new T( config ) ); } virtual std::string getDescription() const override { return std::string();