From 8730260457ddbd19f3df70c53931934398fc54d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Ho=C5=99e=C5=88ovsk=C3=BD?= Date: Tue, 21 Jun 2022 16:19:50 +0200 Subject: [PATCH] Split apart combined TUs The compile time improvements from using combined TUs mostly isn't worth the annoyance they cause with various IDE shortcuts, like when switching between header and its impl. file. Splitting them apart also fixes the issue of empty subdirs being installed due to `foo/internal` folders that only contained the combined TUs and no headers. Closes #2457 Closes #2463 --- src/CMakeLists.txt | 34 ++- src/catch2/benchmark/catch_chronometer.cpp | 17 ++ .../detail/catch_benchmark_function.cpp | 17 ++ .../detail/catch_run_for_at_least.cpp | 30 +++ .../internal/catch_benchmark_combined_tu.cpp | 75 ------ src/catch2/catch_tag_alias_autoregistrar.cpp | 24 ++ .../generators/catch_generator_exception.cpp | 17 ++ ...s_combined_tu.cpp => catch_generators.cpp} | 30 --- .../interfaces/catch_interfaces_capture.cpp | 13 + .../catch_interfaces_combined_tu.cpp | 90 ------- .../interfaces/catch_interfaces_config.cpp | 13 + .../interfaces/catch_interfaces_exception.cpp | 14 ++ .../catch_interfaces_registry_hub.cpp | 14 ++ .../catch_interfaces_reporter_factory.cpp | 14 ++ .../catch_interfaces_reporter_registry.cpp | 13 + .../interfaces/catch_interfaces_testcase.cpp | 14 ++ src/catch2/internal/catch_combined_tu.cpp | 237 ------------------ src/catch2/internal/catch_decomposer.cpp | 23 ++ src/catch2/internal/catch_errno_guard.cpp | 16 ++ src/catch2/internal/catch_lazy_expr.cpp | 29 +++ src/catch2/internal/catch_leak_detector.cpp | 38 +++ src/catch2/internal/catch_message_info.cpp | 25 ++ src/catch2/internal/catch_polyfills.cpp | 34 +++ .../catch_startup_exception_registry.cpp | 29 +++ .../internal/catch_uncaught_exceptions.cpp | 26 ++ src/catch2/matchers/catch_matchers.cpp | 25 ++ .../catch_matchers_container_properties.cpp | 34 +++ .../matchers/catch_matchers_exception.cpp | 26 ++ .../matchers/catch_matchers_predicate.cpp | 17 ++ .../internal/catch_matchers_combined_tu.cpp | 135 ---------- .../matchers/internal/catch_matchers_impl.cpp | 25 ++ .../catch_reporter_event_listener.cpp | 40 +++ ...ined_tu.cpp => catch_reporter_helpers.cpp} | 45 ---- 33 files changed, 615 insertions(+), 618 deletions(-) create mode 100644 src/catch2/benchmark/catch_chronometer.cpp create mode 100644 src/catch2/benchmark/detail/catch_benchmark_function.cpp create mode 100644 src/catch2/benchmark/detail/catch_run_for_at_least.cpp delete mode 100644 src/catch2/benchmark/internal/catch_benchmark_combined_tu.cpp create mode 100644 src/catch2/catch_tag_alias_autoregistrar.cpp create mode 100644 src/catch2/generators/catch_generator_exception.cpp rename src/catch2/generators/{internal/catch_generators_combined_tu.cpp => catch_generators.cpp} (52%) create mode 100644 src/catch2/interfaces/catch_interfaces_capture.cpp delete mode 100644 src/catch2/interfaces/catch_interfaces_combined_tu.cpp create mode 100644 src/catch2/interfaces/catch_interfaces_config.cpp create mode 100644 src/catch2/interfaces/catch_interfaces_exception.cpp create mode 100644 src/catch2/interfaces/catch_interfaces_registry_hub.cpp create mode 100644 src/catch2/interfaces/catch_interfaces_reporter_factory.cpp create mode 100644 src/catch2/interfaces/catch_interfaces_reporter_registry.cpp create mode 100644 src/catch2/interfaces/catch_interfaces_testcase.cpp delete mode 100644 src/catch2/internal/catch_combined_tu.cpp create mode 100644 src/catch2/internal/catch_decomposer.cpp create mode 100644 src/catch2/internal/catch_errno_guard.cpp create mode 100644 src/catch2/internal/catch_lazy_expr.cpp create mode 100644 src/catch2/internal/catch_leak_detector.cpp create mode 100644 src/catch2/internal/catch_message_info.cpp create mode 100644 src/catch2/internal/catch_polyfills.cpp create mode 100644 src/catch2/internal/catch_startup_exception_registry.cpp create mode 100644 src/catch2/internal/catch_uncaught_exceptions.cpp create mode 100644 src/catch2/matchers/catch_matchers.cpp create mode 100644 src/catch2/matchers/catch_matchers_container_properties.cpp create mode 100644 src/catch2/matchers/catch_matchers_exception.cpp create mode 100644 src/catch2/matchers/catch_matchers_predicate.cpp delete mode 100644 src/catch2/matchers/internal/catch_matchers_combined_tu.cpp create mode 100644 src/catch2/matchers/internal/catch_matchers_impl.cpp create mode 100644 src/catch2/reporters/catch_reporter_event_listener.cpp rename src/catch2/reporters/{catch_reporter_combined_tu.cpp => catch_reporter_helpers.cpp} (80%) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 341da85c..d00d368b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -31,7 +31,9 @@ set(BENCHMARK_HEADERS ${SOURCES_DIR}/benchmark/detail/catch_timing.hpp ) set(BENCHMARK_SOURCES - ${SOURCES_DIR}/benchmark/internal/catch_benchmark_combined_tu.cpp + ${SOURCES_DIR}/benchmark/catch_chronometer.cpp + ${SOURCES_DIR}/benchmark/detail/catch_benchmark_function.cpp + ${SOURCES_DIR}/benchmark/detail/catch_run_for_at_least.cpp ${SOURCES_DIR}/benchmark/detail/catch_stats.cpp ) @@ -166,7 +168,6 @@ set(IMPL_SOURCES ${SOURCES_DIR}/catch_approx.cpp ${SOURCES_DIR}/internal/catch_assertion_handler.cpp ${SOURCES_DIR}/catch_assertion_result.cpp - ${SOURCES_DIR}/matchers/internal/catch_matchers_combined_tu.cpp ${SOURCES_DIR}/internal/catch_clara.cpp ${SOURCES_DIR}/internal/catch_commandline.cpp ${SOURCES_DIR}/internal/catch_source_line_info.cpp @@ -182,8 +183,6 @@ set(IMPL_SOURCES ${SOURCES_DIR}/internal/catch_fatal_condition_handler.cpp ${SOURCES_DIR}/internal/catch_floating_point_helpers.cpp ${SOURCES_DIR}/internal/catch_istream.cpp - ${SOURCES_DIR}/generators/internal/catch_generators_combined_tu.cpp - ${SOURCES_DIR}/interfaces/catch_interfaces_combined_tu.cpp ${SOURCES_DIR}/interfaces/catch_interfaces_generatortracker.cpp ${SOURCES_DIR}/interfaces/catch_interfaces_reporter.cpp ${SOURCES_DIR}/internal/catch_list.cpp @@ -193,7 +192,6 @@ set(IMPL_SOURCES ${SOURCES_DIR}/catch_message.cpp ${SOURCES_DIR}/internal/catch_output_redirect.cpp ${SOURCES_DIR}/catch_registry_hub.cpp - ${SOURCES_DIR}/internal/catch_combined_tu.cpp ${SOURCES_DIR}/internal/catch_random_number_generator.cpp ${SOURCES_DIR}/internal/catch_random_seed_generation.cpp ${SOURCES_DIR}/internal/catch_reporter_registry.cpp @@ -223,6 +221,29 @@ set(IMPL_SOURCES ${SOURCES_DIR}/internal/catch_xmlwriter.cpp ${SOURCES_DIR}/internal/catch_test_case_info_hasher.cpp ${SOURCES_DIR}/generators/catch_generators_random.cpp + ${SOURCES_DIR}/generators/catch_generator_exception.cpp + ${SOURCES_DIR}/generators/catch_generators.cpp + ${SOURCES_DIR}/matchers/catch_matchers.cpp + ${SOURCES_DIR}/matchers/catch_matchers_container_properties.cpp + ${SOURCES_DIR}/matchers/catch_matchers_exception.cpp + ${SOURCES_DIR}/matchers/catch_matchers_predicate.cpp + ${SOURCES_DIR}/matchers/internal/catch_matchers_impl.cpp + ${SOURCES_DIR}/catch_tag_alias_autoregistrar.cpp + ${SOURCES_DIR}/internal/catch_decomposer.cpp + ${SOURCES_DIR}/internal/catch_errno_guard.cpp + ${SOURCES_DIR}/internal/catch_lazy_expr.cpp + ${SOURCES_DIR}/internal/catch_leak_detector.cpp + ${SOURCES_DIR}/internal/catch_message_info.cpp + ${SOURCES_DIR}/internal/catch_polyfills.cpp + ${SOURCES_DIR}/internal/catch_startup_exception_registry.cpp + ${SOURCES_DIR}/internal/catch_uncaught_exceptions.cpp + ${SOURCES_DIR}/interfaces/catch_interfaces_capture.cpp + ${SOURCES_DIR}/interfaces/catch_interfaces_config.cpp + ${SOURCES_DIR}/interfaces/catch_interfaces_exception.cpp + ${SOURCES_DIR}/interfaces/catch_interfaces_registry_hub.cpp + ${SOURCES_DIR}/interfaces/catch_interfaces_reporter_factory.cpp + ${SOURCES_DIR}/interfaces/catch_interfaces_reporter_registry.cpp + ${SOURCES_DIR}/interfaces/catch_interfaces_testcase.cpp ) set(INTERNAL_FILES ${IMPL_SOURCES} ${INTERNAL_HEADERS}) @@ -247,11 +268,12 @@ set(REPORTER_HEADERS ) set(REPORTER_SOURCES ${SOURCES_DIR}/reporters/catch_reporter_automake.cpp - ${SOURCES_DIR}/reporters/catch_reporter_combined_tu.cpp ${SOURCES_DIR}/reporters/catch_reporter_common_base.cpp ${SOURCES_DIR}/reporters/catch_reporter_compact.cpp ${SOURCES_DIR}/reporters/catch_reporter_console.cpp ${SOURCES_DIR}/reporters/catch_reporter_cumulative_base.cpp + ${SOURCES_DIR}/reporters/catch_reporter_event_listener.cpp + ${SOURCES_DIR}/reporters/catch_reporter_helpers.cpp ${SOURCES_DIR}/reporters/catch_reporter_junit.cpp ${SOURCES_DIR}/reporters/catch_reporter_multi.cpp ${SOURCES_DIR}/reporters/catch_reporter_registrars.cpp diff --git a/src/catch2/benchmark/catch_chronometer.cpp b/src/catch2/benchmark/catch_chronometer.cpp new file mode 100644 index 00000000..459a26c7 --- /dev/null +++ b/src/catch2/benchmark/catch_chronometer.cpp @@ -0,0 +1,17 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + ChronometerConcept::~ChronometerConcept() = default; + } // namespace Detail + } // namespace Benchmark +} // namespace Catch diff --git a/src/catch2/benchmark/detail/catch_benchmark_function.cpp b/src/catch2/benchmark/detail/catch_benchmark_function.cpp new file mode 100644 index 00000000..9562d29e --- /dev/null +++ b/src/catch2/benchmark/detail/catch_benchmark_function.cpp @@ -0,0 +1,17 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + BenchmarkFunction::callable::~callable() = default; + } // namespace Detail + } // namespace Benchmark +} // namespace Catch diff --git a/src/catch2/benchmark/detail/catch_run_for_at_least.cpp b/src/catch2/benchmark/detail/catch_run_for_at_least.cpp new file mode 100644 index 00000000..6c246d6a --- /dev/null +++ b/src/catch2/benchmark/detail/catch_run_for_at_least.cpp @@ -0,0 +1,30 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include +#include + +namespace Catch { + namespace Benchmark { + namespace Detail { + struct optimized_away_error : std::exception { + const char* what() const noexcept override; + }; + + const char* optimized_away_error::what() const noexcept { + return "could not measure benchmark, maybe it was optimized away"; + } + + void throw_optimized_away_error() { + Catch::throw_exception(optimized_away_error{}); + } + + } // namespace Detail + } // namespace Benchmark +} // namespace Catch diff --git a/src/catch2/benchmark/internal/catch_benchmark_combined_tu.cpp b/src/catch2/benchmark/internal/catch_benchmark_combined_tu.cpp deleted file mode 100644 index ffbae696..00000000 --- a/src/catch2/benchmark/internal/catch_benchmark_combined_tu.cpp +++ /dev/null @@ -1,75 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -/** \file - * This is a special TU that combines what would otherwise be a very - * small benchmarking-related TUs into one bigger TU. - * - * The reason for this is compilation performance improvements by - * avoiding reparsing headers for many small TUs, instead having this - * one TU include bit more, but having it all parsed only once. - * - * To avoid heavy-tail problem with compilation times, each "subpart" - * of Catch2 has its own combined TU like this. - */ - -//////////////////////////////////////////// -// vvv formerly catch_chronometer.cpp vvv // -//////////////////////////////////////////// - -#include - -namespace Catch { - namespace Benchmark { - namespace Detail { - ChronometerConcept::~ChronometerConcept() = default; - } // namespace Detail - } // namespace Benchmark -} // namespace Catch - - -/////////////////////////////////////////////////// -// vvv formerly catch_benchmark_function.cpp vvv // -/////////////////////////////////////////////////// - -#include - -namespace Catch { - namespace Benchmark { - namespace Detail { - BenchmarkFunction::callable::~callable() = default; - } // namespace Detail - } // namespace Benchmark -} // namespace Catch - - -///////////////////////////////////////////////// -// vvv formerly catch_run_for_at_least.cpp vvv // -///////////////////////////////////////////////// - -#include -#include -#include - -namespace Catch { - namespace Benchmark { - namespace Detail { - struct optimized_away_error : std::exception { - const char* what() const noexcept override; - }; - - const char* optimized_away_error::what() const noexcept { - return "could not measure benchmark, maybe it was optimized away"; - } - - void throw_optimized_away_error() { - Catch::throw_exception(optimized_away_error{}); - } - - } // namespace Detail - } // namespace Benchmark -} // namespace Catch diff --git a/src/catch2/catch_tag_alias_autoregistrar.cpp b/src/catch2/catch_tag_alias_autoregistrar.cpp new file mode 100644 index 00000000..d3e10cb0 --- /dev/null +++ b/src/catch2/catch_tag_alias_autoregistrar.cpp @@ -0,0 +1,24 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include +#include + +namespace Catch { + + RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) { + CATCH_TRY { + getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo); + } CATCH_CATCH_ALL { + // Do not throw when constructing global objects, instead register the exception to be processed later + getMutableRegistryHub().registerStartupException(); + } + } + +} diff --git a/src/catch2/generators/catch_generator_exception.cpp b/src/catch2/generators/catch_generator_exception.cpp new file mode 100644 index 00000000..70a991e3 --- /dev/null +++ b/src/catch2/generators/catch_generator_exception.cpp @@ -0,0 +1,17 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + + const char* GeneratorException::what() const noexcept { + return m_msg; + } + +} // end namespace Catch diff --git a/src/catch2/generators/internal/catch_generators_combined_tu.cpp b/src/catch2/generators/catch_generators.cpp similarity index 52% rename from src/catch2/generators/internal/catch_generators_combined_tu.cpp rename to src/catch2/generators/catch_generators.cpp index da1b62e9..3e09bfd9 100644 --- a/src/catch2/generators/internal/catch_generators_combined_tu.cpp +++ b/src/catch2/generators/catch_generators.cpp @@ -5,36 +5,6 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 -/** \file - * This is a special TU that combines what would otherwise be a very - * small generator-related TUs into one bigger TU. - * - * The reason for this is compilation performance improvements by - * avoiding reparsing headers for many small TUs, instead having this - * one TU include bit more, but having it all parsed only once. - * - * To avoid heavy-tail problem with compilation times, each "subpart" - * of Catch2 has its own combined TU like this. - */ - -//////////////////////////////////////////////////// -// vvv formerly catch_generator_exception.cpp vvv // -//////////////////////////////////////////////////// - -#include - -namespace Catch { - - const char* GeneratorException::what() const noexcept { - return m_msg; - } - -} // end namespace Catch - - -/////////////////////////////////////////// -// vvv formerly catch_generators.cpp vvv // -/////////////////////////////////////////// #include #include diff --git a/src/catch2/interfaces/catch_interfaces_capture.cpp b/src/catch2/interfaces/catch_interfaces_capture.cpp new file mode 100644 index 00000000..fb98a75d --- /dev/null +++ b/src/catch2/interfaces/catch_interfaces_capture.cpp @@ -0,0 +1,13 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + IResultCapture::~IResultCapture() = default; +} diff --git a/src/catch2/interfaces/catch_interfaces_combined_tu.cpp b/src/catch2/interfaces/catch_interfaces_combined_tu.cpp deleted file mode 100644 index 2e126a46..00000000 --- a/src/catch2/interfaces/catch_interfaces_combined_tu.cpp +++ /dev/null @@ -1,90 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -/** \file - * This is a special TU that combines what would otherwise be a very - * small interfaces-related TUs into one bigger TU. - * - * The reason for this is compilation performance improvements by - * avoiding reparsing headers for many small TUs, instead having this - * one TU include bit more, but having it all parsed only once. - * - * To avoid heavy-tail problem with compilation times, each "subpart" - * of Catch2 has its own combined TU like this. - */ - -/////////////////////////////////////////////////// -// vvv formerly catch_interfaces_capture.cpp vvv // -/////////////////////////////////////////////////// - -#include - -namespace Catch { - IResultCapture::~IResultCapture() = default; -} - - -////////////////////////////////////////////////// -// vvv formerly catch_interfaces_config.cpp vvv // -////////////////////////////////////////////////// - -#include - -namespace Catch { - IConfig::~IConfig() = default; -} - - -///////////////////////////////////////////////////// -// vvv formerly catch_interfaces_exception.cpp vvv // -///////////////////////////////////////////////////// - -#include - -namespace Catch { - IExceptionTranslator::~IExceptionTranslator() = default; - IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; -} - - -//////////////////////////////////////////////////////// -// vvv formerly catch_interfaces_registry_hub.cpp vvv // -//////////////////////////////////////////////////////// - -#include - -namespace Catch { - IRegistryHub::~IRegistryHub() = default; - IMutableRegistryHub::~IMutableRegistryHub() = default; -} - - -//////////////////////////////////////////////////// -// vvv formerly catch_interfaces_testcase.cpp vvv // -//////////////////////////////////////////////////// - -#include - -namespace Catch { - ITestInvoker::~ITestInvoker() = default; - ITestCaseRegistry::~ITestCaseRegistry() = default; -} - - -#include - -namespace Catch { - IReporterRegistry::~IReporterRegistry() = default; -} - - -#include - -namespace Catch { - IReporterFactory::~IReporterFactory() = default; - EventListenerFactory::~EventListenerFactory() = default; -} diff --git a/src/catch2/interfaces/catch_interfaces_config.cpp b/src/catch2/interfaces/catch_interfaces_config.cpp new file mode 100644 index 00000000..13d761df --- /dev/null +++ b/src/catch2/interfaces/catch_interfaces_config.cpp @@ -0,0 +1,13 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + IConfig::~IConfig() = default; +} diff --git a/src/catch2/interfaces/catch_interfaces_exception.cpp b/src/catch2/interfaces/catch_interfaces_exception.cpp new file mode 100644 index 00000000..f0de7450 --- /dev/null +++ b/src/catch2/interfaces/catch_interfaces_exception.cpp @@ -0,0 +1,14 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + IExceptionTranslator::~IExceptionTranslator() = default; + IExceptionTranslatorRegistry::~IExceptionTranslatorRegistry() = default; +} diff --git a/src/catch2/interfaces/catch_interfaces_registry_hub.cpp b/src/catch2/interfaces/catch_interfaces_registry_hub.cpp new file mode 100644 index 00000000..557f7303 --- /dev/null +++ b/src/catch2/interfaces/catch_interfaces_registry_hub.cpp @@ -0,0 +1,14 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + IRegistryHub::~IRegistryHub() = default; + IMutableRegistryHub::~IMutableRegistryHub() = default; +} diff --git a/src/catch2/interfaces/catch_interfaces_reporter_factory.cpp b/src/catch2/interfaces/catch_interfaces_reporter_factory.cpp new file mode 100644 index 00000000..8732ed89 --- /dev/null +++ b/src/catch2/interfaces/catch_interfaces_reporter_factory.cpp @@ -0,0 +1,14 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + IReporterFactory::~IReporterFactory() = default; + EventListenerFactory::~EventListenerFactory() = default; +} diff --git a/src/catch2/interfaces/catch_interfaces_reporter_registry.cpp b/src/catch2/interfaces/catch_interfaces_reporter_registry.cpp new file mode 100644 index 00000000..bd38ac28 --- /dev/null +++ b/src/catch2/interfaces/catch_interfaces_reporter_registry.cpp @@ -0,0 +1,13 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + IReporterRegistry::~IReporterRegistry() = default; +} diff --git a/src/catch2/interfaces/catch_interfaces_testcase.cpp b/src/catch2/interfaces/catch_interfaces_testcase.cpp new file mode 100644 index 00000000..ec32d667 --- /dev/null +++ b/src/catch2/interfaces/catch_interfaces_testcase.cpp @@ -0,0 +1,14 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + ITestInvoker::~ITestInvoker() = default; + ITestCaseRegistry::~ITestCaseRegistry() = default; +} diff --git a/src/catch2/internal/catch_combined_tu.cpp b/src/catch2/internal/catch_combined_tu.cpp deleted file mode 100644 index 601ac8e7..00000000 --- a/src/catch2/internal/catch_combined_tu.cpp +++ /dev/null @@ -1,237 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -/** \file - * This is a special TU that combines what would otherwise be a very - * small top-level TUs into one bigger TU. - * - * The reason for this is compilation performance improvements by - * avoiding reparsing headers for many small TUs, instead having this - * one TU include bit more, but having it all parsed only once. - * - * To avoid heavy-tail problem with compilation times, each "subpart" - * of Catch2 has its own combined TU like this. - */ - - -//////////////////////////////////////////////////////// -// vvv formerly catch_tag_alias_autoregistrar.cpp vvv // -//////////////////////////////////////////////////////// - -#include -#include -#include - -namespace Catch { - - RegistrarForTagAliases::RegistrarForTagAliases(char const* alias, char const* tag, SourceLineInfo const& lineInfo) { - CATCH_TRY { - getMutableRegistryHub().registerTagAlias(alias, tag, lineInfo); - } CATCH_CATCH_ALL { - // Do not throw when constructing global objects, instead register the exception to be processed later - getMutableRegistryHub().registerStartupException(); - } - } - -} - - -////////////////////////////////////////// -// vvv formerly catch_polyfills.cpp vvv // -////////////////////////////////////////// - -#include -#include -#include - -namespace Catch { - -#if !defined(CATCH_CONFIG_POLYFILL_ISNAN) - bool isnan(float f) { - return std::isnan(f); - } - bool isnan(double d) { - return std::isnan(d); - } -#else - // For now we only use this for embarcadero - bool isnan(float f) { - return std::_isnan(f); - } - bool isnan(double d) { - return std::_isnan(d); - } -#endif - -} // end namespace Catch - - -//////////////////////////////////////////////////// -// vvv formerly catch_uncaught_exceptions.cpp vvv // -//////////////////////////////////////////////////// - -#include -#include -#include - -#include - -namespace Catch { - bool uncaught_exceptions() { -#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) - return false; -#elif defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) - return std::uncaught_exceptions() > 0; -#else - return std::uncaught_exception(); -#endif - } -} // end namespace Catch - - -//////////////////////////////////////////// -// vvv formerly catch_errno_guard.cpp vvv // -//////////////////////////////////////////// -#include - -#include - -namespace Catch { - ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} - ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } -} - - -/////////////////////////////////////////// -// vvv formerly catch_decomposer.cpp vvv // -/////////////////////////////////////////// -#include - -namespace Catch { - - ITransientExpression::~ITransientExpression() = default; - - void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { - if( lhs.size() + rhs.size() < 40 && - lhs.find('\n') == std::string::npos && - rhs.find('\n') == std::string::npos ) - os << lhs << ' ' << op << ' ' << rhs; - else - os << lhs << '\n' << op << '\n' << rhs; - } -} - - -/////////////////////////////////////////////////////////// -// vvv formerly catch_startup_exception_registry.cpp vvv // -/////////////////////////////////////////////////////////// -#include -#include - -namespace Catch { -#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) - void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { - CATCH_TRY { - m_exceptions.push_back(exception); - } CATCH_CATCH_ALL { - // If we run out of memory during start-up there's really not a lot more we can do about it - std::terminate(); - } - } - - std::vector const& StartupExceptionRegistry::getExceptions() const noexcept { - return m_exceptions; - } -#endif - -} // end namespace Catch - - -////////////////////////////////////////////// -// vvv formerly catch_leak_detector.cpp vvv // -////////////////////////////////////////////// -#include -#include - - -#ifdef CATCH_CONFIG_WINDOWS_CRTDBG -#include - -namespace Catch { - - LeakDetector::LeakDetector() { - int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); - flag |= _CRTDBG_LEAK_CHECK_DF; - flag |= _CRTDBG_ALLOC_MEM_DF; - _CrtSetDbgFlag(flag); - _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); - _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); - // Change this to leaking allocation's number to break there - _CrtSetBreakAlloc(-1); - } -} - -#else // ^^ Windows crt debug heap enabled // Windows crt debug heap disabled vv - - Catch::LeakDetector::LeakDetector() {} - -#endif // CATCH_CONFIG_WINDOWS_CRTDBG - -Catch::LeakDetector::~LeakDetector() { - Catch::cleanUp(); -} - - -///////////////////////////////////////////// -// vvv formerly catch_message_info.cpp vvv // -///////////////////////////////////////////// - -#include - -namespace Catch { - - MessageInfo::MessageInfo( StringRef _macroName, - SourceLineInfo const& _lineInfo, - ResultWas::OfType _type ) - : macroName( _macroName ), - lineInfo( _lineInfo ), - type( _type ), - sequence( ++globalCount ) - {} - - // This may need protecting if threading support is added - unsigned int MessageInfo::globalCount = 0; - -} // end namespace Catch - - - - -////////////////////////////////////////// -// vvv formerly catch_lazy_expr.cpp vvv // -////////////////////////////////////////// -#include -#include - -namespace Catch { - - auto operator << (std::ostream& os, LazyExpression const& lazyExpr) -> std::ostream& { - if (lazyExpr.m_isNegated) - os << '!'; - - if (lazyExpr) { - if (lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression()) - os << '(' << *lazyExpr.m_transientExpression << ')'; - else - os << *lazyExpr.m_transientExpression; - } else { - os << "{** error - unchecked empty expression requested **}"; - } - return os; - } - -} // namespace Catch diff --git a/src/catch2/internal/catch_decomposer.cpp b/src/catch2/internal/catch_decomposer.cpp new file mode 100644 index 00000000..a8569538 --- /dev/null +++ b/src/catch2/internal/catch_decomposer.cpp @@ -0,0 +1,23 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + + ITransientExpression::~ITransientExpression() = default; + + void formatReconstructedExpression( std::ostream &os, std::string const& lhs, StringRef op, std::string const& rhs ) { + if( lhs.size() + rhs.size() < 40 && + lhs.find('\n') == std::string::npos && + rhs.find('\n') == std::string::npos ) + os << lhs << ' ' << op << ' ' << rhs; + else + os << lhs << '\n' << op << '\n' << rhs; + } +} diff --git a/src/catch2/internal/catch_errno_guard.cpp b/src/catch2/internal/catch_errno_guard.cpp new file mode 100644 index 00000000..95c192df --- /dev/null +++ b/src/catch2/internal/catch_errno_guard.cpp @@ -0,0 +1,16 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +#include + +namespace Catch { + ErrnoGuard::ErrnoGuard():m_oldErrno(errno){} + ErrnoGuard::~ErrnoGuard() { errno = m_oldErrno; } +} diff --git a/src/catch2/internal/catch_lazy_expr.cpp b/src/catch2/internal/catch_lazy_expr.cpp new file mode 100644 index 00000000..96ecf5c3 --- /dev/null +++ b/src/catch2/internal/catch_lazy_expr.cpp @@ -0,0 +1,29 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include + +namespace Catch { + + auto operator << (std::ostream& os, LazyExpression const& lazyExpr) -> std::ostream& { + if (lazyExpr.m_isNegated) + os << '!'; + + if (lazyExpr) { + if (lazyExpr.m_isNegated && lazyExpr.m_transientExpression->isBinaryExpression()) + os << '(' << *lazyExpr.m_transientExpression << ')'; + else + os << *lazyExpr.m_transientExpression; + } else { + os << "{** error - unchecked empty expression requested **}"; + } + return os; + } + +} // namespace Catch diff --git a/src/catch2/internal/catch_leak_detector.cpp b/src/catch2/internal/catch_leak_detector.cpp new file mode 100644 index 00000000..c9abbdfc --- /dev/null +++ b/src/catch2/internal/catch_leak_detector.cpp @@ -0,0 +1,38 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include +#include + +#ifdef CATCH_CONFIG_WINDOWS_CRTDBG +#include + +namespace Catch { + + LeakDetector::LeakDetector() { + int flag = _CrtSetDbgFlag(_CRTDBG_REPORT_FLAG); + flag |= _CRTDBG_LEAK_CHECK_DF; + flag |= _CRTDBG_ALLOC_MEM_DF; + _CrtSetDbgFlag(flag); + _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE | _CRTDBG_MODE_DEBUG); + _CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR); + // Change this to leaking allocation's number to break there + _CrtSetBreakAlloc(-1); + } +} + +#else // ^^ Windows crt debug heap enabled // Windows crt debug heap disabled vv + + Catch::LeakDetector::LeakDetector() {} + +#endif // CATCH_CONFIG_WINDOWS_CRTDBG + +Catch::LeakDetector::~LeakDetector() { + Catch::cleanUp(); +} diff --git a/src/catch2/internal/catch_message_info.cpp b/src/catch2/internal/catch_message_info.cpp new file mode 100644 index 00000000..11127e3f --- /dev/null +++ b/src/catch2/internal/catch_message_info.cpp @@ -0,0 +1,25 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + + MessageInfo::MessageInfo( StringRef _macroName, + SourceLineInfo const& _lineInfo, + ResultWas::OfType _type ) + : macroName( _macroName ), + lineInfo( _lineInfo ), + type( _type ), + sequence( ++globalCount ) + {} + + // This may need protecting if threading support is added + unsigned int MessageInfo::globalCount = 0; + +} // end namespace Catch diff --git a/src/catch2/internal/catch_polyfills.cpp b/src/catch2/internal/catch_polyfills.cpp new file mode 100644 index 00000000..13e60f4a --- /dev/null +++ b/src/catch2/internal/catch_polyfills.cpp @@ -0,0 +1,34 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include +#include + +#include + +namespace Catch { + +#if !defined(CATCH_CONFIG_POLYFILL_ISNAN) + bool isnan(float f) { + return std::isnan(f); + } + bool isnan(double d) { + return std::isnan(d); + } +#else + // For now we only use this for embarcadero + bool isnan(float f) { + return std::_isnan(f); + } + bool isnan(double d) { + return std::_isnan(d); + } +#endif + +} // end namespace Catch diff --git a/src/catch2/internal/catch_startup_exception_registry.cpp b/src/catch2/internal/catch_startup_exception_registry.cpp new file mode 100644 index 00000000..7681f442 --- /dev/null +++ b/src/catch2/internal/catch_startup_exception_registry.cpp @@ -0,0 +1,29 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include +#include + +namespace Catch { +#if !defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + void StartupExceptionRegistry::add( std::exception_ptr const& exception ) noexcept { + CATCH_TRY { + m_exceptions.push_back(exception); + } CATCH_CATCH_ALL { + // If we run out of memory during start-up there's really not a lot more we can do about it + std::terminate(); + } + } + + std::vector const& StartupExceptionRegistry::getExceptions() const noexcept { + return m_exceptions; + } +#endif + +} // end namespace Catch diff --git a/src/catch2/internal/catch_uncaught_exceptions.cpp b/src/catch2/internal/catch_uncaught_exceptions.cpp new file mode 100644 index 00000000..c6251a3f --- /dev/null +++ b/src/catch2/internal/catch_uncaught_exceptions.cpp @@ -0,0 +1,26 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include +#include +#include + +#include + +namespace Catch { + bool uncaught_exceptions() { +#if defined(CATCH_CONFIG_DISABLE_EXCEPTIONS) + return false; +#elif defined(CATCH_CONFIG_CPP17_UNCAUGHT_EXCEPTIONS) + return std::uncaught_exceptions() > 0; +#else + return std::uncaught_exception(); +#endif + } +} // end namespace Catch diff --git a/src/catch2/matchers/catch_matchers.cpp b/src/catch2/matchers/catch_matchers.cpp new file mode 100644 index 00000000..6b604e4a --- /dev/null +++ b/src/catch2/matchers/catch_matchers.cpp @@ -0,0 +1,25 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + + +#include + +namespace Catch { +namespace Matchers { + + std::string MatcherUntypedBase::toString() const { + if (m_cachedToString.empty()) { + m_cachedToString = describe(); + } + return m_cachedToString; + } + + MatcherUntypedBase::~MatcherUntypedBase() = default; + +} // namespace Matchers +} // namespace Catch diff --git a/src/catch2/matchers/catch_matchers_container_properties.cpp b/src/catch2/matchers/catch_matchers_container_properties.cpp new file mode 100644 index 00000000..5344abcd --- /dev/null +++ b/src/catch2/matchers/catch_matchers_container_properties.cpp @@ -0,0 +1,34 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include + +namespace Catch { +namespace Matchers { + + std::string IsEmptyMatcher::describe() const { + return "is empty"; + } + + std::string HasSizeMatcher::describe() const { + ReusableStringStream sstr; + sstr << "has size == " << m_target_size; + return sstr.str(); + } + + IsEmptyMatcher IsEmpty() { + return {}; + } + + HasSizeMatcher SizeIs(std::size_t sz) { + return HasSizeMatcher{ sz }; + } + +} // end namespace Matchers +} // end namespace Catch diff --git a/src/catch2/matchers/catch_matchers_exception.cpp b/src/catch2/matchers/catch_matchers_exception.cpp new file mode 100644 index 00000000..af3ea15a --- /dev/null +++ b/src/catch2/matchers/catch_matchers_exception.cpp @@ -0,0 +1,26 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 +#include + +namespace Catch { +namespace Matchers { + +bool ExceptionMessageMatcher::match(std::exception const& ex) const { + return ex.what() == m_message; +} + +std::string ExceptionMessageMatcher::describe() const { + return "exception message matches \"" + m_message + '"'; +} + +ExceptionMessageMatcher Message(std::string const& message) { + return ExceptionMessageMatcher(message); +} + +} // namespace Matchers +} // namespace Catch diff --git a/src/catch2/matchers/catch_matchers_predicate.cpp b/src/catch2/matchers/catch_matchers_predicate.cpp new file mode 100644 index 00000000..a9ecffc9 --- /dev/null +++ b/src/catch2/matchers/catch_matchers_predicate.cpp @@ -0,0 +1,17 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +std::string Catch::Matchers::Detail::finalizeDescription(const std::string& desc) { + if (desc.empty()) { + return "matches undescribed predicate"; + } else { + return "matches predicate: \"" + desc + '"'; + } +} diff --git a/src/catch2/matchers/internal/catch_matchers_combined_tu.cpp b/src/catch2/matchers/internal/catch_matchers_combined_tu.cpp deleted file mode 100644 index 6ec878b0..00000000 --- a/src/catch2/matchers/internal/catch_matchers_combined_tu.cpp +++ /dev/null @@ -1,135 +0,0 @@ - -// Copyright Catch2 Authors -// Distributed under the Boost Software License, Version 1.0. -// (See accompanying file LICENSE_1_0.txt or copy at -// https://www.boost.org/LICENSE_1_0.txt) - -// SPDX-License-Identifier: BSL-1.0 -/** \file - * This is a special TU that combines what would otherwise be a very - * small matcher-related TUs into one bigger TU. - * - * The reason for this is compilation performance improvements by - * avoiding reparsing headers for many small TUs, instead having this - * one TU include bit more, but having it all parsed only once. - * - * To avoid heavy-tail problem with compilation times, each "subpart" - * of Catch2 has its own combined TU like this. - */ - -////////////////////////////////////////////// -// vvv formerly catch_matchers_impl.cpp vvv // -////////////////////////////////////////////// -#include -#include -#include -#include - -namespace Catch { - - // This is the general overload that takes a any string matcher - // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers - // the Equals matcher (so the header does not mention matchers) - void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) { - std::string exceptionMessage = Catch::translateActiveException(); - MatchExpr expr( CATCH_MOVE(exceptionMessage), matcher, matcherString ); - handler.handleExpr( expr ); - } - -} // namespace Catch - - -////////////////////////////////////////////////////////////// -// vvv formerly catch_matchers_container_properties.cpp vvv // -////////////////////////////////////////////////////////////// -#include -#include - -namespace Catch { -namespace Matchers { - - std::string IsEmptyMatcher::describe() const { - return "is empty"; - } - - std::string HasSizeMatcher::describe() const { - ReusableStringStream sstr; - sstr << "has size == " << m_target_size; - return sstr.str(); - } - - IsEmptyMatcher IsEmpty() { - return {}; - } - - HasSizeMatcher SizeIs(std::size_t sz) { - return HasSizeMatcher{ sz }; - } - -} // end namespace Matchers -} // end namespace Catch - - - -///////////////////////////////////////// -// vvv formerly catch_matchers.cpp vvv // -///////////////////////////////////////// - -#include - -namespace Catch { -namespace Matchers { - - std::string MatcherUntypedBase::toString() const { - if (m_cachedToString.empty()) { - m_cachedToString = describe(); - } - return m_cachedToString; - } - - MatcherUntypedBase::~MatcherUntypedBase() = default; - -} // namespace Matchers -} // namespace Catch - - - -/////////////////////////////////////////////////// -// vvv formerly catch_matchers_predicate.cpp vvv // -/////////////////////////////////////////////////// -#include - -std::string Catch::Matchers::Detail::finalizeDescription(const std::string& desc) { - if (desc.empty()) { - return "matches undescribed predicate"; - } else { - return "matches predicate: \"" + desc + '"'; - } -} - - - - - -/////////////////////////////////////////////////// -// vvv formerly catch_matchers_exception.cpp vvv // -/////////////////////////////////////////////////// -#include - -namespace Catch { -namespace Matchers { - -bool ExceptionMessageMatcher::match(std::exception const& ex) const { - return ex.what() == m_message; -} - -std::string ExceptionMessageMatcher::describe() const { - return "exception message matches \"" + m_message + '"'; -} - -ExceptionMessageMatcher Message(std::string const& message) { - return ExceptionMessageMatcher(message); -} - -} // namespace Matchers -} // namespace Catch diff --git a/src/catch2/matchers/internal/catch_matchers_impl.cpp b/src/catch2/matchers/internal/catch_matchers_impl.cpp new file mode 100644 index 00000000..2c2a6117 --- /dev/null +++ b/src/catch2/matchers/internal/catch_matchers_impl.cpp @@ -0,0 +1,25 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include +#include +#include +#include + +namespace Catch { + + // This is the general overload that takes a any string matcher + // There is another overload, in catch_assertionhandler.h/.cpp, that only takes a string and infers + // the Equals matcher (so the header does not mention matchers) + void handleExceptionMatchExpr( AssertionHandler& handler, StringMatcher const& matcher, StringRef matcherString ) { + std::string exceptionMessage = Catch::translateActiveException(); + MatchExpr expr( CATCH_MOVE(exceptionMessage), matcher, matcherString ); + handler.handleExpr( expr ); + } + +} // namespace Catch diff --git a/src/catch2/reporters/catch_reporter_event_listener.cpp b/src/catch2/reporters/catch_reporter_event_listener.cpp new file mode 100644 index 00000000..a997a315 --- /dev/null +++ b/src/catch2/reporters/catch_reporter_event_listener.cpp @@ -0,0 +1,40 @@ + +// Copyright Catch2 Authors +// Distributed under the Boost Software License, Version 1.0. +// (See accompanying file LICENSE_1_0.txt or copy at +// https://www.boost.org/LICENSE_1_0.txt) + +// SPDX-License-Identifier: BSL-1.0 + +#include + +namespace Catch { + + void EventListenerBase::fatalErrorEncountered( StringRef ) {} + + void EventListenerBase::benchmarkPreparing( StringRef ) {} + void EventListenerBase::benchmarkStarting( BenchmarkInfo const& ) {} + void EventListenerBase::benchmarkEnded( BenchmarkStats<> const& ) {} + void EventListenerBase::benchmarkFailed( StringRef ) {} + + void EventListenerBase::assertionStarting( AssertionInfo const& ) {} + + void EventListenerBase::assertionEnded( AssertionStats const& ) {} + void EventListenerBase::listReporters( + std::vector const& ) {} + void EventListenerBase::listListeners( + std::vector const& ) {} + void EventListenerBase::listTests( std::vector const& ) {} + void EventListenerBase::listTags( std::vector const& ) {} + void EventListenerBase::noMatchingTestCases( StringRef ) {} + void EventListenerBase::reportInvalidTestSpec( StringRef ) {} + void EventListenerBase::testRunStarting( TestRunInfo const& ) {} + void EventListenerBase::testCaseStarting( TestCaseInfo const& ) {} + void EventListenerBase::testCasePartialStarting(TestCaseInfo const&, uint64_t) {} + void EventListenerBase::sectionStarting( SectionInfo const& ) {} + void EventListenerBase::sectionEnded( SectionStats const& ) {} + void EventListenerBase::testCasePartialEnded(TestCaseStats const&, uint64_t) {} + void EventListenerBase::testCaseEnded( TestCaseStats const& ) {} + void EventListenerBase::testRunEnded( TestRunStats const& ) {} + void EventListenerBase::skipTest( TestCaseInfo const& ) {} +} // namespace Catch diff --git a/src/catch2/reporters/catch_reporter_combined_tu.cpp b/src/catch2/reporters/catch_reporter_helpers.cpp similarity index 80% rename from src/catch2/reporters/catch_reporter_combined_tu.cpp rename to src/catch2/reporters/catch_reporter_helpers.cpp index 2d6e112c..31df851a 100644 --- a/src/catch2/reporters/catch_reporter_combined_tu.cpp +++ b/src/catch2/reporters/catch_reporter_helpers.cpp @@ -5,17 +5,6 @@ // https://www.boost.org/LICENSE_1_0.txt) // SPDX-License-Identifier: BSL-1.0 -/** \file - * This is a special TU that combines what would otherwise be a very - * small reporter-related TUs into one bigger TU. - * - * The reason for this is compilation performance improvements by - * avoiding reparsing headers for many small TUs, instead having this - * one TU include bit more, but having it all parsed only once. - * - * To avoid heavy-tail problem with compilation times, each "subpart" - * of Catch2 has its own combined TU like this. - */ #include #include @@ -247,37 +236,3 @@ namespace Catch { } } // namespace Catch - - -#include - -namespace Catch { - - void EventListenerBase::fatalErrorEncountered( StringRef ) {} - - void EventListenerBase::benchmarkPreparing( StringRef ) {} - void EventListenerBase::benchmarkStarting( BenchmarkInfo const& ) {} - void EventListenerBase::benchmarkEnded( BenchmarkStats<> const& ) {} - void EventListenerBase::benchmarkFailed( StringRef ) {} - - void EventListenerBase::assertionStarting( AssertionInfo const& ) {} - - void EventListenerBase::assertionEnded( AssertionStats const& ) {} - void EventListenerBase::listReporters( - std::vector const& ) {} - void EventListenerBase::listListeners( - std::vector const& ) {} - void EventListenerBase::listTests( std::vector const& ) {} - void EventListenerBase::listTags( std::vector const& ) {} - void EventListenerBase::noMatchingTestCases( StringRef ) {} - void EventListenerBase::reportInvalidTestSpec( StringRef ) {} - void EventListenerBase::testRunStarting( TestRunInfo const& ) {} - void EventListenerBase::testCaseStarting( TestCaseInfo const& ) {} - void EventListenerBase::testCasePartialStarting(TestCaseInfo const&, uint64_t) {} - void EventListenerBase::sectionStarting( SectionInfo const& ) {} - void EventListenerBase::sectionEnded( SectionStats const& ) {} - void EventListenerBase::testCasePartialEnded(TestCaseStats const&, uint64_t) {} - void EventListenerBase::testCaseEnded( TestCaseStats const& ) {} - void EventListenerBase::testRunEnded( TestRunStats const& ) {} - void EventListenerBase::skipTest( TestCaseInfo const& ) {} -} // namespace Catch