mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-23 05:46:11 +01:00
Devirtualize RegistryHub
This commit is contained in:
parent
02ce0a2eec
commit
f3960c02ce
@ -106,6 +106,7 @@ set(IMPL_HEADERS
|
|||||||
${SOURCES_DIR}/internal/catch_preprocessor_remove_parens.hpp
|
${SOURCES_DIR}/internal/catch_preprocessor_remove_parens.hpp
|
||||||
${SOURCES_DIR}/internal/catch_random_number_generator.hpp
|
${SOURCES_DIR}/internal/catch_random_number_generator.hpp
|
||||||
${SOURCES_DIR}/internal/catch_random_seed_generation.hpp
|
${SOURCES_DIR}/internal/catch_random_seed_generation.hpp
|
||||||
|
${SOURCES_DIR}/internal/catch_registry_hub.hpp
|
||||||
${SOURCES_DIR}/internal/catch_reporter_registry.hpp
|
${SOURCES_DIR}/internal/catch_reporter_registry.hpp
|
||||||
${SOURCES_DIR}/internal/catch_reporter_spec_parser.hpp
|
${SOURCES_DIR}/internal/catch_reporter_spec_parser.hpp
|
||||||
${SOURCES_DIR}/internal/catch_result_type.hpp
|
${SOURCES_DIR}/internal/catch_result_type.hpp
|
||||||
@ -145,7 +146,6 @@ set(IMPL_SOURCES
|
|||||||
${SOURCES_DIR}/catch_config.cpp
|
${SOURCES_DIR}/catch_config.cpp
|
||||||
${SOURCES_DIR}/catch_get_random_seed.cpp
|
${SOURCES_DIR}/catch_get_random_seed.cpp
|
||||||
${SOURCES_DIR}/catch_message.cpp
|
${SOURCES_DIR}/catch_message.cpp
|
||||||
${SOURCES_DIR}/catch_registry_hub.cpp
|
|
||||||
${SOURCES_DIR}/catch_session.cpp
|
${SOURCES_DIR}/catch_session.cpp
|
||||||
${SOURCES_DIR}/catch_tag_alias_autoregistrar.cpp
|
${SOURCES_DIR}/catch_tag_alias_autoregistrar.cpp
|
||||||
${SOURCES_DIR}/catch_test_case_info.cpp
|
${SOURCES_DIR}/catch_test_case_info.cpp
|
||||||
@ -181,6 +181,7 @@ set(IMPL_SOURCES
|
|||||||
${SOURCES_DIR}/internal/catch_polyfills.cpp
|
${SOURCES_DIR}/internal/catch_polyfills.cpp
|
||||||
${SOURCES_DIR}/internal/catch_random_number_generator.cpp
|
${SOURCES_DIR}/internal/catch_random_number_generator.cpp
|
||||||
${SOURCES_DIR}/internal/catch_random_seed_generation.cpp
|
${SOURCES_DIR}/internal/catch_random_seed_generation.cpp
|
||||||
|
${SOURCES_DIR}/internal/catch_registry_hub.cpp
|
||||||
${SOURCES_DIR}/internal/catch_reporter_registry.cpp
|
${SOURCES_DIR}/internal/catch_reporter_registry.cpp
|
||||||
${SOURCES_DIR}/internal/catch_reporter_spec_parser.cpp
|
${SOURCES_DIR}/internal/catch_reporter_spec_parser.cpp
|
||||||
${SOURCES_DIR}/internal/catch_result_type.cpp
|
${SOURCES_DIR}/internal/catch_result_type.cpp
|
||||||
@ -213,7 +214,6 @@ set(INTERFACE_HEADERS
|
|||||||
${SOURCES_DIR}/interfaces/catch_interfaces_config.hpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_config.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_exception.hpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_exception.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.hpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.hpp
|
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.hpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.hpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.hpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_testcase.hpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_testcase.hpp
|
||||||
@ -223,7 +223,6 @@ set(INTERFACE_SOURCES
|
|||||||
${SOURCES_DIR}/interfaces/catch_interfaces_config.cpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_config.cpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_exception.cpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_exception.cpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.cpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.cpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.cpp
|
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.cpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.cpp
|
||||||
${SOURCES_DIR}/interfaces/catch_interfaces_testcase.cpp
|
${SOURCES_DIR}/interfaces/catch_interfaces_testcase.cpp
|
||||||
|
@ -14,6 +14,7 @@
|
|||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
#include <catch2/internal/catch_context.hpp>
|
#include <catch2/internal/catch_context.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||||
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
#include <catch2/internal/catch_unique_name.hpp>
|
#include <catch2/internal/catch_unique_name.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
#include <catch2/benchmark/catch_chronometer.hpp>
|
#include <catch2/benchmark/catch_chronometer.hpp>
|
||||||
@ -26,6 +27,7 @@
|
|||||||
#include <catch2/benchmark/detail/catch_benchmark_function.hpp>
|
#include <catch2/benchmark/detail/catch_benchmark_function.hpp>
|
||||||
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
|
#include <catch2/benchmark/detail/catch_run_for_at_least.hpp>
|
||||||
|
|
||||||
|
|
||||||
#include <algorithm>
|
#include <algorithm>
|
||||||
#include <functional>
|
#include <functional>
|
||||||
#include <string>
|
#include <string>
|
||||||
|
@ -13,7 +13,6 @@
|
|||||||
#include <catch2/internal/catch_test_failure_exception.hpp>
|
#include <catch2/internal/catch_test_failure_exception.hpp>
|
||||||
#include <catch2/internal/catch_meta.hpp>
|
#include <catch2/internal/catch_meta.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
#include <catch2/interfaces/catch_interfaces_capture.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
#include <type_traits>
|
#include <type_traits>
|
||||||
|
@ -89,6 +89,7 @@
|
|||||||
#include <catch2/internal/catch_preprocessor_remove_parens.hpp>
|
#include <catch2/internal/catch_preprocessor_remove_parens.hpp>
|
||||||
#include <catch2/internal/catch_random_number_generator.hpp>
|
#include <catch2/internal/catch_random_number_generator.hpp>
|
||||||
#include <catch2/internal/catch_random_seed_generation.hpp>
|
#include <catch2/internal/catch_random_seed_generation.hpp>
|
||||||
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
#include <catch2/internal/catch_reporter_registry.hpp>
|
#include <catch2/internal/catch_reporter_registry.hpp>
|
||||||
#include <catch2/internal/catch_reporter_spec_parser.hpp>
|
#include <catch2/internal/catch_reporter_spec_parser.hpp>
|
||||||
#include <catch2/internal/catch_result_type.hpp>
|
#include <catch2/internal/catch_result_type.hpp>
|
||||||
|
@ -1,105 +0,0 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// (See accompanying file LICENSE.txt or copy at
|
|
||||||
// https://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
|
||||||
|
|
||||||
#include <catch2/internal/catch_context.hpp>
|
|
||||||
#include <catch2/internal/catch_enforce.hpp>
|
|
||||||
#include <catch2/internal/catch_test_case_registry_impl.hpp>
|
|
||||||
#include <catch2/internal/catch_reporter_registry.hpp>
|
|
||||||
#include <catch2/internal/catch_exception_translator_registry.hpp>
|
|
||||||
#include <catch2/internal/catch_tag_alias_registry.hpp>
|
|
||||||
#include <catch2/internal/catch_startup_exception_registry.hpp>
|
|
||||||
#include <catch2/internal/catch_singletons.hpp>
|
|
||||||
#include <catch2/internal/catch_enum_values_registry.hpp>
|
|
||||||
#include <catch2/catch_test_case_info.hpp>
|
|
||||||
#include <catch2/internal/catch_noncopyable.hpp>
|
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
|
||||||
#include <catch2/internal/catch_reporter_registry.hpp>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
namespace {
|
|
||||||
|
|
||||||
class RegistryHub : public IRegistryHub,
|
|
||||||
public IMutableRegistryHub,
|
|
||||||
private Detail::NonCopyable {
|
|
||||||
|
|
||||||
public: // IRegistryHub
|
|
||||||
RegistryHub() = default;
|
|
||||||
ReporterRegistry const& getReporterRegistry() const override {
|
|
||||||
return m_reporterRegistry;
|
|
||||||
}
|
|
||||||
TestCaseRegistry const& getTestCaseRegistry() const override {
|
|
||||||
return m_testCaseRegistry;
|
|
||||||
}
|
|
||||||
ExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const override {
|
|
||||||
return m_exceptionTranslatorRegistry;
|
|
||||||
}
|
|
||||||
TagAliasRegistry const& getTagAliasRegistry() const override {
|
|
||||||
return m_tagAliasRegistry;
|
|
||||||
}
|
|
||||||
StartupExceptionRegistry const& getStartupExceptionRegistry() const override {
|
|
||||||
return m_exceptionRegistry;
|
|
||||||
}
|
|
||||||
|
|
||||||
public: // IMutableRegistryHub
|
|
||||||
void registerReporter( std::string const& name, IReporterFactoryPtr factory ) override {
|
|
||||||
m_reporterRegistry.registerReporter( name, CATCH_MOVE(factory) );
|
|
||||||
}
|
|
||||||
void registerListener( Detail::unique_ptr<EventListenerFactory> factory ) override {
|
|
||||||
m_reporterRegistry.registerListener( CATCH_MOVE(factory) );
|
|
||||||
}
|
|
||||||
void registerTest( Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker ) override {
|
|
||||||
m_testCaseRegistry.registerTest( CATCH_MOVE(testInfo), CATCH_MOVE(invoker) );
|
|
||||||
}
|
|
||||||
void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) override {
|
|
||||||
m_exceptionTranslatorRegistry.registerTranslator( CATCH_MOVE(translator) );
|
|
||||||
}
|
|
||||||
void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) override {
|
|
||||||
m_tagAliasRegistry.add( alias, tag, lineInfo );
|
|
||||||
}
|
|
||||||
void registerStartupException() noexcept override {
|
|
||||||
#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS)
|
|
||||||
m_exceptionRegistry.add(std::current_exception());
|
|
||||||
#else
|
|
||||||
CATCH_INTERNAL_ERROR("Attempted to register active exception under CATCH_CONFIG_DISABLE_EXCEPTIONS!");
|
|
||||||
#endif
|
|
||||||
}
|
|
||||||
EnumValuesRegistry& getMutableEnumValuesRegistry() override {
|
|
||||||
return m_enumValuesRegistry;
|
|
||||||
}
|
|
||||||
|
|
||||||
private:
|
|
||||||
TestCaseRegistry m_testCaseRegistry;
|
|
||||||
ReporterRegistry m_reporterRegistry;
|
|
||||||
ExceptionTranslatorRegistry m_exceptionTranslatorRegistry;
|
|
||||||
TagAliasRegistry m_tagAliasRegistry;
|
|
||||||
StartupExceptionRegistry m_exceptionRegistry;
|
|
||||||
EnumValuesRegistry m_enumValuesRegistry;
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
using RegistryHubSingleton = Singleton<RegistryHub, IRegistryHub, IMutableRegistryHub>;
|
|
||||||
|
|
||||||
IRegistryHub const& getRegistryHub() {
|
|
||||||
return RegistryHubSingleton::get();
|
|
||||||
}
|
|
||||||
IMutableRegistryHub& getMutableRegistryHub() {
|
|
||||||
return RegistryHubSingleton::getMutable();
|
|
||||||
}
|
|
||||||
void cleanUp() {
|
|
||||||
cleanupSingletons();
|
|
||||||
cleanUpContext();
|
|
||||||
}
|
|
||||||
std::string translateActiveException() {
|
|
||||||
return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException();
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
} // end namespace Catch
|
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <catch2/catch_tag_alias_autoregistrar.hpp>
|
#include <catch2/catch_tag_alias_autoregistrar.hpp>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
|
||||||
|
@ -648,7 +648,7 @@ struct ratio_string<std::milli> {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
|
|
||||||
#define INTERNAL_CATCH_REGISTER_ENUM( enumName, ... ) \
|
#define INTERNAL_CATCH_REGISTER_ENUM( enumName, ... ) \
|
||||||
namespace Catch { \
|
namespace Catch { \
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
|
||||||
#include <catch2/catch_translate_exception.hpp>
|
#include <catch2/catch_translate_exception.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
@ -26,7 +26,6 @@
|
|||||||
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_exception.hpp>
|
#include <catch2/interfaces/catch_interfaces_exception.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_generatortracker.hpp>
|
#include <catch2/interfaces/catch_interfaces_generatortracker.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
|
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
|
||||||
|
@ -1,14 +0,0 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// (See accompanying file LICENSE.txt or copy at
|
|
||||||
// https://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
|
||||||
|
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
IRegistryHub::~IRegistryHub() = default;
|
|
||||||
IMutableRegistryHub::~IMutableRegistryHub() = default;
|
|
||||||
}
|
|
@ -1,66 +0,0 @@
|
|||||||
|
|
||||||
// Copyright Catch2 Authors
|
|
||||||
// Distributed under the Boost Software License, Version 1.0.
|
|
||||||
// (See accompanying file LICENSE.txt or copy at
|
|
||||||
// https://www.boost.org/LICENSE_1_0.txt)
|
|
||||||
|
|
||||||
// SPDX-License-Identifier: BSL-1.0
|
|
||||||
#ifndef CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED
|
|
||||||
#define CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED
|
|
||||||
|
|
||||||
#include <catch2/internal/catch_unique_ptr.hpp>
|
|
||||||
|
|
||||||
#include <string>
|
|
||||||
|
|
||||||
namespace Catch {
|
|
||||||
|
|
||||||
class TestCaseHandle;
|
|
||||||
struct TestCaseInfo;
|
|
||||||
class TestCaseRegistry;
|
|
||||||
class ExceptionTranslatorRegistry;
|
|
||||||
class IExceptionTranslator;
|
|
||||||
class ReporterRegistry;
|
|
||||||
class IReporterFactory;
|
|
||||||
class TagAliasRegistry;
|
|
||||||
class ITestInvoker;
|
|
||||||
class EnumValuesRegistry;
|
|
||||||
struct SourceLineInfo;
|
|
||||||
|
|
||||||
class StartupExceptionRegistry;
|
|
||||||
class EventListenerFactory;
|
|
||||||
|
|
||||||
using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
|
|
||||||
|
|
||||||
class IRegistryHub {
|
|
||||||
public:
|
|
||||||
virtual ~IRegistryHub(); // = default
|
|
||||||
|
|
||||||
virtual ReporterRegistry const& getReporterRegistry() const = 0;
|
|
||||||
virtual TestCaseRegistry const& getTestCaseRegistry() const = 0;
|
|
||||||
virtual TagAliasRegistry const& getTagAliasRegistry() const = 0;
|
|
||||||
virtual ExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const = 0;
|
|
||||||
|
|
||||||
|
|
||||||
virtual StartupExceptionRegistry const& getStartupExceptionRegistry() const = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
class IMutableRegistryHub {
|
|
||||||
public:
|
|
||||||
virtual ~IMutableRegistryHub(); // = default
|
|
||||||
virtual void registerReporter( std::string const& name, IReporterFactoryPtr factory ) = 0;
|
|
||||||
virtual void registerListener( Detail::unique_ptr<EventListenerFactory> factory ) = 0;
|
|
||||||
virtual void registerTest(Detail::unique_ptr<TestCaseInfo>&& testInfo, Detail::unique_ptr<ITestInvoker>&& invoker) = 0;
|
|
||||||
virtual void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator ) = 0;
|
|
||||||
virtual void registerTagAlias( std::string const& alias, std::string const& tag, SourceLineInfo const& lineInfo ) = 0;
|
|
||||||
virtual void registerStartupException() noexcept = 0;
|
|
||||||
virtual EnumValuesRegistry& getMutableEnumValuesRegistry() = 0;
|
|
||||||
};
|
|
||||||
|
|
||||||
IRegistryHub const& getRegistryHub();
|
|
||||||
IMutableRegistryHub& getMutableRegistryHub();
|
|
||||||
void cleanUp();
|
|
||||||
std::string translateActiveException();
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
#endif // CATCH_INTERFACES_REGISTRY_HUB_HPP_INCLUDED
|
|
@ -11,7 +11,7 @@
|
|||||||
#include <catch2/internal/catch_enforce.hpp>
|
#include <catch2/internal/catch_enforce.hpp>
|
||||||
#include <catch2/internal/catch_debugger.hpp>
|
#include <catch2/internal/catch_debugger.hpp>
|
||||||
#include <catch2/internal/catch_test_failure_exception.hpp>
|
#include <catch2/internal/catch_test_failure_exception.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
#include <catch2/internal/catch_run_context.hpp>
|
#include <catch2/internal/catch_run_context.hpp>
|
||||||
#include <catch2/matchers/catch_matchers_string.hpp>
|
#include <catch2/matchers/catch_matchers_string.hpp>
|
||||||
|
|
||||||
|
@ -9,7 +9,7 @@
|
|||||||
|
|
||||||
#include <catch2/catch_config.hpp>
|
#include <catch2/catch_config.hpp>
|
||||||
#include <catch2/internal/catch_string_manip.hpp>
|
#include <catch2/internal/catch_string_manip.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
#include <catch2/internal/catch_reporter_registry.hpp>
|
#include <catch2/internal/catch_reporter_registry.hpp>
|
||||||
#include <catch2/internal/catch_console_colour.hpp>
|
#include <catch2/internal/catch_console_colour.hpp>
|
||||||
#include <catch2/internal/catch_parse_numbers.hpp>
|
#include <catch2/internal/catch_parse_numbers.hpp>
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
|
||||||
#include <catch2/internal/catch_leak_detector.hpp>
|
#include <catch2/internal/catch_leak_detector.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
#include <catch2/catch_user_config.hpp>
|
#include <catch2/catch_user_config.hpp>
|
||||||
|
|
||||||
#ifdef CATCH_CONFIG_WINDOWS_CRTDBG
|
#ifdef CATCH_CONFIG_WINDOWS_CRTDBG
|
||||||
|
@ -7,7 +7,7 @@
|
|||||||
// SPDX-License-Identifier: BSL-1.0
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
#include <catch2/internal/catch_list.hpp>
|
#include <catch2/internal/catch_list.hpp>
|
||||||
|
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
|
#include <catch2/interfaces/catch_interfaces_testcase.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||||
|
114
src/catch2/internal/catch_registry_hub.cpp
Normal file
114
src/catch2/internal/catch_registry_hub.cpp
Normal file
@ -0,0 +1,114 @@
|
|||||||
|
|
||||||
|
// Copyright Catch2 Authors
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE.txt or copy at
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
|
|
||||||
|
#include <catch2/internal/catch_context.hpp>
|
||||||
|
#include <catch2/internal/catch_enforce.hpp>
|
||||||
|
#include <catch2/internal/catch_test_case_registry_impl.hpp>
|
||||||
|
#include <catch2/internal/catch_reporter_registry.hpp>
|
||||||
|
#include <catch2/internal/catch_exception_translator_registry.hpp>
|
||||||
|
#include <catch2/internal/catch_tag_alias_registry.hpp>
|
||||||
|
#include <catch2/internal/catch_startup_exception_registry.hpp>
|
||||||
|
#include <catch2/internal/catch_singletons.hpp>
|
||||||
|
#include <catch2/internal/catch_enum_values_registry.hpp>
|
||||||
|
#include <catch2/catch_test_case_info.hpp>
|
||||||
|
#include <catch2/internal/catch_noncopyable.hpp>
|
||||||
|
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||||
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
#include <catch2/internal/catch_reporter_registry.hpp>
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
|
||||||
|
struct RegistryHub::RegistryHubImpl {
|
||||||
|
TestCaseRegistry testCaseRegistry;
|
||||||
|
ReporterRegistry reporterRegistry;
|
||||||
|
ExceptionTranslatorRegistry exceptionTranslatorRegistry;
|
||||||
|
TagAliasRegistry tagAliasRegistry;
|
||||||
|
StartupExceptionRegistry exceptionRegistry;
|
||||||
|
EnumValuesRegistry enumValuesRegistry;
|
||||||
|
};
|
||||||
|
|
||||||
|
RegistryHub::RegistryHub():
|
||||||
|
m_impl( Detail::make_unique<RegistryHubImpl>() ) {}
|
||||||
|
RegistryHub::~RegistryHub() = default;
|
||||||
|
|
||||||
|
ReporterRegistry const&
|
||||||
|
RegistryHub::getReporterRegistry() const {
|
||||||
|
return m_impl->reporterRegistry;
|
||||||
|
}
|
||||||
|
TestCaseRegistry const&
|
||||||
|
RegistryHub::getTestCaseRegistry() const {
|
||||||
|
return m_impl->testCaseRegistry;
|
||||||
|
}
|
||||||
|
ExceptionTranslatorRegistry const&
|
||||||
|
RegistryHub::getExceptionTranslatorRegistry() const {
|
||||||
|
return m_impl->exceptionTranslatorRegistry;
|
||||||
|
}
|
||||||
|
TagAliasRegistry const&
|
||||||
|
RegistryHub::getTagAliasRegistry() const {
|
||||||
|
return m_impl->tagAliasRegistry;
|
||||||
|
}
|
||||||
|
StartupExceptionRegistry const&
|
||||||
|
RegistryHub::getStartupExceptionRegistry() const {
|
||||||
|
return m_impl->exceptionRegistry;
|
||||||
|
}
|
||||||
|
void
|
||||||
|
RegistryHub::registerReporter( std::string const& name,
|
||||||
|
IReporterFactoryPtr factory ) {
|
||||||
|
m_impl->reporterRegistry.registerReporter( name, CATCH_MOVE( factory ) );
|
||||||
|
}
|
||||||
|
void RegistryHub::registerListener(
|
||||||
|
Detail::unique_ptr<EventListenerFactory> factory ) {
|
||||||
|
m_impl->reporterRegistry.registerListener( CATCH_MOVE( factory ) );
|
||||||
|
}
|
||||||
|
void RegistryHub::registerTest(
|
||||||
|
Detail::unique_ptr<TestCaseInfo>&& testInfo,
|
||||||
|
Detail::unique_ptr<ITestInvoker>&& invoker ) {
|
||||||
|
m_impl->testCaseRegistry.registerTest( CATCH_MOVE( testInfo ),
|
||||||
|
CATCH_MOVE( invoker ) );
|
||||||
|
}
|
||||||
|
void RegistryHub::registerTranslator(
|
||||||
|
Detail::unique_ptr<IExceptionTranslator>&& translator ) {
|
||||||
|
m_impl->exceptionTranslatorRegistry.registerTranslator(
|
||||||
|
CATCH_MOVE( translator ) );
|
||||||
|
}
|
||||||
|
void RegistryHub::registerTagAlias( std::string const& alias,
|
||||||
|
std::string const& tag,
|
||||||
|
SourceLineInfo const& lineInfo ) {
|
||||||
|
m_impl->tagAliasRegistry.add( alias, tag, lineInfo );
|
||||||
|
}
|
||||||
|
void RegistryHub::registerStartupException() noexcept {
|
||||||
|
#if !defined( CATCH_CONFIG_DISABLE_EXCEPTIONS )
|
||||||
|
m_impl->exceptionRegistry.add( std::current_exception() );
|
||||||
|
#else
|
||||||
|
CATCH_INTERNAL_ERROR( "Attempted to register active exception under "
|
||||||
|
"CATCH_CONFIG_DISABLE_EXCEPTIONS!" );
|
||||||
|
#endif
|
||||||
|
}
|
||||||
|
EnumValuesRegistry& RegistryHub::getMutableEnumValuesRegistry() {
|
||||||
|
return m_impl->enumValuesRegistry;
|
||||||
|
}
|
||||||
|
|
||||||
|
using RegistryHubSingleton = Singleton<RegistryHub>;
|
||||||
|
|
||||||
|
RegistryHub const& getRegistryHub() {
|
||||||
|
return RegistryHubSingleton::get();
|
||||||
|
}
|
||||||
|
RegistryHub& getMutableRegistryHub() {
|
||||||
|
return RegistryHubSingleton::getMutable();
|
||||||
|
}
|
||||||
|
void cleanUp() {
|
||||||
|
cleanupSingletons();
|
||||||
|
cleanUpContext();
|
||||||
|
}
|
||||||
|
std::string translateActiveException() {
|
||||||
|
return getRegistryHub().getExceptionTranslatorRegistry().translateActiveException();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
} // end namespace Catch
|
67
src/catch2/internal/catch_registry_hub.hpp
Normal file
67
src/catch2/internal/catch_registry_hub.hpp
Normal file
@ -0,0 +1,67 @@
|
|||||||
|
|
||||||
|
// Copyright Catch2 Authors
|
||||||
|
// Distributed under the Boost Software License, Version 1.0.
|
||||||
|
// (See accompanying file LICENSE.txt or copy at
|
||||||
|
// https://www.boost.org/LICENSE_1_0.txt)
|
||||||
|
|
||||||
|
// SPDX-License-Identifier: BSL-1.0
|
||||||
|
#ifndef CATCH_REGISTRY_HUB_HPP_INCLUDED
|
||||||
|
#define CATCH_REGISTRY_HUB_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <catch2/internal/catch_unique_ptr.hpp>
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
|
||||||
|
namespace Catch {
|
||||||
|
|
||||||
|
class TestCaseHandle;
|
||||||
|
struct TestCaseInfo;
|
||||||
|
class TestCaseRegistry;
|
||||||
|
class ExceptionTranslatorRegistry;
|
||||||
|
class IExceptionTranslator;
|
||||||
|
class ReporterRegistry;
|
||||||
|
class IReporterFactory;
|
||||||
|
class TagAliasRegistry;
|
||||||
|
class ITestInvoker;
|
||||||
|
class EnumValuesRegistry;
|
||||||
|
struct SourceLineInfo;
|
||||||
|
|
||||||
|
class StartupExceptionRegistry;
|
||||||
|
class EventListenerFactory;
|
||||||
|
|
||||||
|
using IReporterFactoryPtr = Detail::unique_ptr<IReporterFactory>;
|
||||||
|
|
||||||
|
class RegistryHub {
|
||||||
|
struct RegistryHubImpl;
|
||||||
|
Detail::unique_ptr<RegistryHubImpl> m_impl;
|
||||||
|
public:
|
||||||
|
RegistryHub();
|
||||||
|
~RegistryHub();
|
||||||
|
|
||||||
|
ReporterRegistry const& getReporterRegistry() const;
|
||||||
|
TestCaseRegistry const& getTestCaseRegistry() const;
|
||||||
|
TagAliasRegistry const& getTagAliasRegistry() const;
|
||||||
|
ExceptionTranslatorRegistry const& getExceptionTranslatorRegistry() const;
|
||||||
|
StartupExceptionRegistry const& getStartupExceptionRegistry() const;
|
||||||
|
|
||||||
|
void registerReporter( std::string const& name,
|
||||||
|
IReporterFactoryPtr factory );
|
||||||
|
void registerListener( Detail::unique_ptr<EventListenerFactory> factory );
|
||||||
|
void registerTest( Detail::unique_ptr<TestCaseInfo>&& testInfo,
|
||||||
|
Detail::unique_ptr<ITestInvoker>&& invoker );
|
||||||
|
void registerTranslator( Detail::unique_ptr<IExceptionTranslator>&& translator );
|
||||||
|
void registerTagAlias( std::string const& alias,
|
||||||
|
std::string const& tag,
|
||||||
|
SourceLineInfo const& lineInfo );
|
||||||
|
void registerStartupException() noexcept;
|
||||||
|
EnumValuesRegistry& getMutableEnumValuesRegistry();
|
||||||
|
};
|
||||||
|
|
||||||
|
RegistryHub const& getRegistryHub();
|
||||||
|
RegistryHub& getMutableRegistryHub();
|
||||||
|
void cleanUp();
|
||||||
|
std::string translateActiveException();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
#endif // CATCH_REGISTRY_HUB_HPP_INCLUDED
|
@ -8,7 +8,7 @@
|
|||||||
#include <catch2/internal/catch_tag_alias_registry.hpp>
|
#include <catch2/internal/catch_tag_alias_registry.hpp>
|
||||||
#include <catch2/internal/catch_console_colour.hpp>
|
#include <catch2/internal/catch_console_colour.hpp>
|
||||||
#include <catch2/internal/catch_enforce.hpp>
|
#include <catch2/internal/catch_enforce.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
#include <catch2/internal/catch_string_manip.hpp>
|
#include <catch2/internal/catch_string_manip.hpp>
|
||||||
|
|
||||||
#include <map>
|
#include <map>
|
||||||
|
@ -10,7 +10,7 @@
|
|||||||
#include <catch2/internal/catch_context.hpp>
|
#include <catch2/internal/catch_context.hpp>
|
||||||
#include <catch2/internal/catch_enforce.hpp>
|
#include <catch2/internal/catch_enforce.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
#include <catch2/interfaces/catch_interfaces_config.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
#include <catch2/internal/catch_random_number_generator.hpp>
|
#include <catch2/internal/catch_random_number_generator.hpp>
|
||||||
#include <catch2/internal/catch_run_context.hpp>
|
#include <catch2/internal/catch_run_context.hpp>
|
||||||
#include <catch2/internal/catch_sharding.hpp>
|
#include <catch2/internal/catch_sharding.hpp>
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
#include <catch2/internal/catch_test_registry.hpp>
|
#include <catch2/internal/catch_test_registry.hpp>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
#include <catch2/catch_test_case_info.hpp>
|
#include <catch2/catch_test_case_info.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
#include <catch2/internal/catch_string_manip.hpp>
|
#include <catch2/internal/catch_string_manip.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
|
@ -8,7 +8,7 @@
|
|||||||
|
|
||||||
#include <catch2/matchers/internal/catch_matchers_impl.hpp>
|
#include <catch2/matchers/internal/catch_matchers_impl.hpp>
|
||||||
#include <catch2/matchers/catch_matchers.hpp>
|
#include <catch2/matchers/catch_matchers.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
#include <catch2/internal/catch_move_and_forward.hpp>
|
#include <catch2/internal/catch_move_and_forward.hpp>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
|
@ -60,7 +60,6 @@ internal_headers = [
|
|||||||
'interfaces/catch_interfaces_config.hpp',
|
'interfaces/catch_interfaces_config.hpp',
|
||||||
'interfaces/catch_interfaces_exception.hpp',
|
'interfaces/catch_interfaces_exception.hpp',
|
||||||
'interfaces/catch_interfaces_generatortracker.hpp',
|
'interfaces/catch_interfaces_generatortracker.hpp',
|
||||||
'interfaces/catch_interfaces_registry_hub.hpp',
|
|
||||||
'interfaces/catch_interfaces_reporter.hpp',
|
'interfaces/catch_interfaces_reporter.hpp',
|
||||||
'interfaces/catch_interfaces_reporter_factory.hpp',
|
'interfaces/catch_interfaces_reporter_factory.hpp',
|
||||||
'interfaces/catch_interfaces_testcase.hpp',
|
'interfaces/catch_interfaces_testcase.hpp',
|
||||||
@ -183,7 +182,6 @@ internal_sources = files(
|
|||||||
'interfaces/catch_interfaces_config.cpp',
|
'interfaces/catch_interfaces_config.cpp',
|
||||||
'interfaces/catch_interfaces_exception.cpp',
|
'interfaces/catch_interfaces_exception.cpp',
|
||||||
'interfaces/catch_interfaces_generatortracker.cpp',
|
'interfaces/catch_interfaces_generatortracker.cpp',
|
||||||
'interfaces/catch_interfaces_registry_hub.cpp',
|
|
||||||
'interfaces/catch_interfaces_reporter.cpp',
|
'interfaces/catch_interfaces_reporter.cpp',
|
||||||
'interfaces/catch_interfaces_reporter_factory.cpp',
|
'interfaces/catch_interfaces_reporter_factory.cpp',
|
||||||
'interfaces/catch_interfaces_testcase.cpp',
|
'interfaces/catch_interfaces_testcase.cpp',
|
||||||
@ -213,6 +211,7 @@ internal_sources = files(
|
|||||||
'internal/catch_polyfills.cpp',
|
'internal/catch_polyfills.cpp',
|
||||||
'internal/catch_random_number_generator.cpp',
|
'internal/catch_random_number_generator.cpp',
|
||||||
'internal/catch_random_seed_generation.cpp',
|
'internal/catch_random_seed_generation.cpp',
|
||||||
|
'internal/catch_registry_hub.cpp',
|
||||||
'internal/catch_reporter_registry.cpp',
|
'internal/catch_reporter_registry.cpp',
|
||||||
'internal/catch_reporter_spec_parser.cpp',
|
'internal/catch_reporter_spec_parser.cpp',
|
||||||
'internal/catch_result_type.cpp',
|
'internal/catch_result_type.cpp',
|
||||||
@ -250,7 +249,6 @@ internal_sources = files(
|
|||||||
'catch_config.cpp',
|
'catch_config.cpp',
|
||||||
'catch_get_random_seed.cpp',
|
'catch_get_random_seed.cpp',
|
||||||
'catch_message.cpp',
|
'catch_message.cpp',
|
||||||
'catch_registry_hub.cpp',
|
|
||||||
'catch_session.cpp',
|
'catch_session.cpp',
|
||||||
'catch_tag_alias_autoregistrar.cpp',
|
'catch_tag_alias_autoregistrar.cpp',
|
||||||
'catch_test_case_info.cpp',
|
'catch_test_case_info.cpp',
|
||||||
|
@ -9,6 +9,7 @@
|
|||||||
#include <catch2/reporters/catch_reporter_registrars.hpp>
|
#include <catch2/reporters/catch_reporter_registrars.hpp>
|
||||||
|
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
|
#include <catch2/internal/catch_registry_hub.hpp>
|
||||||
|
|
||||||
namespace Catch {
|
namespace Catch {
|
||||||
namespace Detail {
|
namespace Detail {
|
||||||
|
@ -8,7 +8,6 @@
|
|||||||
#ifndef CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
#ifndef CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
||||||
#define CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
#define CATCH_REPORTER_REGISTRARS_HPP_INCLUDED
|
||||||
|
|
||||||
#include <catch2/interfaces/catch_interfaces_registry_hub.hpp>
|
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||||
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
#include <catch2/interfaces/catch_interfaces_reporter_factory.hpp>
|
||||||
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
#include <catch2/internal/catch_compiler_capabilities.hpp>
|
||||||
|
Loading…
Reference in New Issue
Block a user