mirror of
https://github.com/catchorg/Catch2.git
synced 2024-11-16 10:42:25 +01:00
Add PCH support and 'CATCH_ENABLE_PCH' flag
This commit is contained in:
parent
1078e7e95b
commit
38710a38b1
@ -12,6 +12,7 @@ option(CATCH_INSTALL_DOCS "Install documentation alongside library" ON)
|
|||||||
option(CATCH_INSTALL_EXTRAS "Install extras (CMake scripts, debugger helpers) alongside library" ON)
|
option(CATCH_INSTALL_EXTRAS "Install extras (CMake scripts, debugger helpers) alongside library" ON)
|
||||||
option(CATCH_DEVELOPMENT_BUILD "Build tests, enable warnings, enable Werror, etc" OFF)
|
option(CATCH_DEVELOPMENT_BUILD "Build tests, enable warnings, enable Werror, etc" OFF)
|
||||||
option(CATCH_ENABLE_REPRODUCIBLE_BUILD "Add compiler flags for improving build reproducibility" ON)
|
option(CATCH_ENABLE_REPRODUCIBLE_BUILD "Add compiler flags for improving build reproducibility" ON)
|
||||||
|
option(CATCH_ENABLE_PCH "Enable pre-compiled headers to improve build speed" ON)
|
||||||
|
|
||||||
include(CMakeDependentOption)
|
include(CMakeDependentOption)
|
||||||
cmake_dependent_option(CATCH_BUILD_TESTING "Build the SelfTest project" ON "CATCH_DEVELOPMENT_BUILD" OFF)
|
cmake_dependent_option(CATCH_BUILD_TESTING "Build the SelfTest project" ON "CATCH_DEVELOPMENT_BUILD" OFF)
|
||||||
@ -155,7 +156,7 @@ if (NOT_SUBPROJECT)
|
|||||||
DESTINATION
|
DESTINATION
|
||||||
${CATCH_CMAKE_CONFIG_DESTINATION}
|
${CATCH_CMAKE_CONFIG_DESTINATION}
|
||||||
)
|
)
|
||||||
|
|
||||||
# Install debugger helpers
|
# Install debugger helpers
|
||||||
install(
|
install(
|
||||||
FILES
|
FILES
|
||||||
|
@ -23,6 +23,10 @@ add_executable(231-Cfg_OutputStreams
|
|||||||
target_link_libraries(231-Cfg_OutputStreams Catch2_buildall_interface)
|
target_link_libraries(231-Cfg_OutputStreams Catch2_buildall_interface)
|
||||||
target_compile_definitions(231-Cfg_OutputStreams PUBLIC CATCH_CONFIG_NOSTDOUT)
|
target_compile_definitions(231-Cfg_OutputStreams PUBLIC CATCH_CONFIG_NOSTDOUT)
|
||||||
|
|
||||||
|
if (CATCH_ENABLE_PCH)
|
||||||
|
target_precompile_headers(231-Cfg_OutputStreams PRIVATE "${SOURCES_DIR}/internal/catch_pch.hpp")
|
||||||
|
endif()
|
||||||
|
|
||||||
# These examples use the standard separate compilation
|
# These examples use the standard separate compilation
|
||||||
set( SOURCES_IDIOMATIC_EXAMPLES
|
set( SOURCES_IDIOMATIC_EXAMPLES
|
||||||
030-Asn-Require-Check.cpp
|
030-Asn-Require-Check.cpp
|
||||||
@ -55,6 +59,10 @@ set(ALL_EXAMPLE_TARGETS
|
|||||||
|
|
||||||
foreach( name ${ALL_EXAMPLE_TARGETS} )
|
foreach( name ${ALL_EXAMPLE_TARGETS} )
|
||||||
target_link_libraries( ${name} Catch2WithMain )
|
target_link_libraries( ${name} Catch2WithMain )
|
||||||
|
|
||||||
|
if (CATCH_ENABLE_PCH)
|
||||||
|
target_precompile_headers(${name} REUSE_FROM Catch2)
|
||||||
|
endif()
|
||||||
endforeach()
|
endforeach()
|
||||||
|
|
||||||
|
|
||||||
|
@ -10,6 +10,8 @@
|
|||||||
#include <catch2/internal/catch_test_spec_parser.hpp>
|
#include <catch2/internal/catch_test_spec_parser.hpp>
|
||||||
#include <catch2/internal/catch_tag_alias_registry.hpp>
|
#include <catch2/internal/catch_tag_alias_registry.hpp>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||||
|
|
||||||
Catch::TagAliasRegistry tar;
|
Catch::TagAliasRegistry tar;
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#include "NullOStream.h"
|
#include "NullOStream.h"
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
||||||
|
|
||||||
std::string buf(Data,Data+Size);
|
std::string buf(Data,Data+Size);
|
||||||
@ -19,4 +21,3 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
|||||||
encode.encodeTo(nul);
|
encode.encodeTo(nul);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -14,6 +14,8 @@
|
|||||||
#include <string>
|
#include <string>
|
||||||
#include <string_view>
|
#include <string_view>
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
|
||||||
|
|
||||||
template<class Callback>
|
template<class Callback>
|
||||||
void split(const char *Data, size_t Size, Callback callback) {
|
void split(const char *Data, size_t Size, Callback callback) {
|
||||||
@ -50,4 +52,3 @@ extern "C" int LLVMFuzzerTestOneInput(const uint8_t *Data, size_t Size) {
|
|||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -348,6 +348,11 @@ source_group("generated headers"
|
|||||||
)
|
)
|
||||||
|
|
||||||
add_library(Catch2 ${ALL_FILES})
|
add_library(Catch2 ${ALL_FILES})
|
||||||
|
|
||||||
|
if (CATCH_ENABLE_PCH)
|
||||||
|
target_precompile_headers(Catch2 PRIVATE "${SOURCES_DIR}/internal/catch_pch.hpp")
|
||||||
|
endif()
|
||||||
|
|
||||||
if (CATCH_ENABLE_REPRODUCIBLE_BUILD)
|
if (CATCH_ENABLE_REPRODUCIBLE_BUILD)
|
||||||
add_build_reproducibility_settings(Catch2)
|
add_build_reproducibility_settings(Catch2)
|
||||||
endif()
|
endif()
|
||||||
@ -403,6 +408,11 @@ target_include_directories(Catch2
|
|||||||
add_library(Catch2WithMain
|
add_library(Catch2WithMain
|
||||||
${SOURCES_DIR}/internal/catch_main.cpp
|
${SOURCES_DIR}/internal/catch_main.cpp
|
||||||
)
|
)
|
||||||
|
|
||||||
|
if (CATCH_ENABLE_PCH)
|
||||||
|
target_precompile_headers(Catch2WithMain REUSE_FROM Catch2)
|
||||||
|
endif()
|
||||||
|
|
||||||
if (CATCH_ENABLE_REPRODUCIBLE_BUILD)
|
if (CATCH_ENABLE_REPRODUCIBLE_BUILD)
|
||||||
add_build_reproducibility_settings(Catch2WithMain)
|
add_build_reproducibility_settings(Catch2WithMain)
|
||||||
endif()
|
endif()
|
||||||
@ -458,6 +468,11 @@ endif()
|
|||||||
# the sources into the binary.
|
# the sources into the binary.
|
||||||
if (CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
|
if (CATCH_BUILD_EXAMPLES OR CATCH_BUILD_EXTRA_TESTS)
|
||||||
add_library(Catch2_buildall_interface INTERFACE)
|
add_library(Catch2_buildall_interface INTERFACE)
|
||||||
|
|
||||||
|
if (CATCH_ENABLE_PCH)
|
||||||
|
target_precompile_headers(Catch2_buildall_interface REUSE_FROM Catch2)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_sources(Catch2_buildall_interface INTERFACE
|
target_sources(Catch2_buildall_interface INTERFACE
|
||||||
${ALL_FILES}
|
${ALL_FILES}
|
||||||
# Also include main entry point
|
# Also include main entry point
|
||||||
|
31
src/catch2/internal/catch_pch.hpp
Normal file
31
src/catch2/internal/catch_pch.hpp
Normal file
@ -0,0 +1,31 @@
|
|||||||
|
|
||||||
|
// 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_PCH_HPP_INCLUDED
|
||||||
|
#define CATCH_PCH_HPP_INCLUDED
|
||||||
|
|
||||||
|
#include <catch2/catch_test_macros.hpp>
|
||||||
|
|
||||||
|
#include <catch2/interfaces/catch_interfaces_reporter.hpp>
|
||||||
|
|
||||||
|
#include <catch2/internal/catch_assertion_handler.hpp>
|
||||||
|
#include <catch2/internal/catch_clara.hpp>
|
||||||
|
#include <catch2/internal/catch_reusable_string_stream.hpp>
|
||||||
|
#include <catch2/internal/catch_stringref.hpp>
|
||||||
|
|
||||||
|
#include <algorithm>
|
||||||
|
#include <chrono>
|
||||||
|
#include <cmath>
|
||||||
|
#include <iomanip>
|
||||||
|
#include <map>
|
||||||
|
#include <memory>
|
||||||
|
#include <ostream>
|
||||||
|
#include <sstream>
|
||||||
|
#include <string>
|
||||||
|
#include <vector>
|
||||||
|
|
||||||
|
#endif // CATCH_PCH_HPP_INCLUDED
|
@ -160,6 +160,10 @@ set(HEADERS
|
|||||||
include(CTest)
|
include(CTest)
|
||||||
|
|
||||||
add_executable(SelfTest ${TEST_SOURCES} ${TEST_HEADERS})
|
add_executable(SelfTest ${TEST_SOURCES} ${TEST_HEADERS})
|
||||||
|
if (CATCH_ENABLE_PCH)
|
||||||
|
target_precompile_headers(SelfTest REUSE_FROM Catch2)
|
||||||
|
endif()
|
||||||
|
|
||||||
target_include_directories(SelfTest PRIVATE ${SELF_TEST_DIR})
|
target_include_directories(SelfTest PRIVATE ${SELF_TEST_DIR})
|
||||||
target_link_libraries(SelfTest PRIVATE Catch2WithMain)
|
target_link_libraries(SelfTest PRIVATE Catch2WithMain)
|
||||||
if (BUILD_SHARED_LIBS AND WIN32)
|
if (BUILD_SHARED_LIBS AND WIN32)
|
||||||
|
@ -65,11 +65,28 @@ set_tests_properties(
|
|||||||
# define folders used:
|
# define folders used:
|
||||||
set( TESTS_DIR ${CATCH_DIR}/tests/ExtraTests )
|
set( TESTS_DIR ${CATCH_DIR}/tests/ExtraTests )
|
||||||
|
|
||||||
add_executable(PrefixedMacros ${TESTS_DIR}/X01-PrefixedMacros.cpp)
|
function(catch2_add_extratest target SOURCES)
|
||||||
|
add_executable(${target} ${SOURCES})
|
||||||
|
target_link_libraries(${target} PRIVATE Catch2WithMain)
|
||||||
|
|
||||||
|
if (CATCH_ENABLE_PCH)
|
||||||
|
target_precompile_headers(${target} REUSE_FROM Catch2)
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
function(catch2_add_extratest_no_pch_reuse target SOURCES)
|
||||||
|
add_executable(${target} ${SOURCES})
|
||||||
|
target_link_libraries(${target} PRIVATE Catch2WithMain)
|
||||||
|
|
||||||
|
if (CATCH_ENABLE_PCH)
|
||||||
|
target_precompile_headers(${target} PRIVATE "${SOURCES_DIR}/internal/catch_pch.hpp")
|
||||||
|
endif()
|
||||||
|
endfunction()
|
||||||
|
|
||||||
|
catch2_add_extratest_no_pch_reuse(PrefixedMacros ${TESTS_DIR}/X01-PrefixedMacros.cpp)
|
||||||
target_compile_definitions( PrefixedMacros PRIVATE CATCH_CONFIG_PREFIX_ALL CATCH_CONFIG_RUNTIME_STATIC_REQUIRE )
|
target_compile_definitions( PrefixedMacros PRIVATE CATCH_CONFIG_PREFIX_ALL CATCH_CONFIG_RUNTIME_STATIC_REQUIRE )
|
||||||
# Macro configuration does not touch the compiled parts, so we can link
|
# Macro configuration does not touch the compiled parts, so we can link
|
||||||
# it against the main library
|
# it against the main library
|
||||||
target_link_libraries( PrefixedMacros Catch2WithMain )
|
|
||||||
|
|
||||||
add_test(NAME CATCH_CONFIG_PREFIX_ALL COMMAND PrefixedMacros -s)
|
add_test(NAME CATCH_CONFIG_PREFIX_ALL COMMAND PrefixedMacros -s)
|
||||||
set_tests_properties(
|
set_tests_properties(
|
||||||
@ -83,11 +100,10 @@ set_tests_properties(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_executable(DisabledMacros ${TESTS_DIR}/X02-DisabledMacros.cpp)
|
catch2_add_extratest_no_pch_reuse(DisabledMacros ${TESTS_DIR}/X02-DisabledMacros.cpp)
|
||||||
target_compile_definitions( DisabledMacros PRIVATE CATCH_CONFIG_DISABLE )
|
target_compile_definitions( DisabledMacros PRIVATE CATCH_CONFIG_DISABLE )
|
||||||
# Macro configuration does not touch the compiled parts, so we can link
|
# Macro configuration does not touch the compiled parts, so we can link
|
||||||
# it against the main library
|
# it against the main library
|
||||||
target_link_libraries( DisabledMacros Catch2WithMain )
|
|
||||||
|
|
||||||
add_test(NAME CATCH_CONFIG_DISABLE-1 COMMAND DisabledMacros -s)
|
add_test(NAME CATCH_CONFIG_DISABLE-1 COMMAND DisabledMacros -s)
|
||||||
set_tests_properties(
|
set_tests_properties(
|
||||||
@ -103,8 +119,8 @@ set_tests_properties(
|
|||||||
PASS_REGULAR_EXPRESSION "0 test cases"
|
PASS_REGULAR_EXPRESSION "0 test cases"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable( DisabledExceptions-DefaultHandler ${TESTS_DIR}/X03-DisabledExceptions-DefaultHandler.cpp )
|
catch2_add_extratest_no_pch_reuse( DisabledExceptions-DefaultHandler ${TESTS_DIR}/X03-DisabledExceptions-DefaultHandler.cpp )
|
||||||
add_executable( DisabledExceptions-CustomHandler ${TESTS_DIR}/X04-DisabledExceptions-CustomHandler.cpp )
|
catch2_add_extratest_no_pch_reuse( DisabledExceptions-CustomHandler ${TESTS_DIR}/X04-DisabledExceptions-CustomHandler.cpp )
|
||||||
|
|
||||||
foreach(target DisabledExceptions-DefaultHandler DisabledExceptions-CustomHandler)
|
foreach(target DisabledExceptions-DefaultHandler DisabledExceptions-CustomHandler)
|
||||||
target_compile_options( ${target}
|
target_compile_options( ${target}
|
||||||
@ -112,7 +128,7 @@ foreach(target DisabledExceptions-DefaultHandler DisabledExceptions-CustomHandle
|
|||||||
$<$<CXX_COMPILER_ID:MSVC>:/EHs-c-;/D_HAS_EXCEPTIONS=0>
|
$<$<CXX_COMPILER_ID:MSVC>:/EHs-c-;/D_HAS_EXCEPTIONS=0>
|
||||||
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:AppleClang>>:-fno-exceptions>
|
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:GNU>,$<CXX_COMPILER_ID:AppleClang>>:-fno-exceptions>
|
||||||
)
|
)
|
||||||
target_link_libraries(${target} Catch2_buildall_interface)
|
target_link_libraries(${target} PRIVATE Catch2_buildall_interface)
|
||||||
endforeach()
|
endforeach()
|
||||||
target_compile_definitions( DisabledExceptions-CustomHandler PUBLIC CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER )
|
target_compile_definitions( DisabledExceptions-CustomHandler PUBLIC CATCH_CONFIG_DISABLE_EXCEPTIONS_CUSTOM_HANDLER )
|
||||||
|
|
||||||
@ -125,9 +141,9 @@ set_tests_properties(
|
|||||||
FAIL_REGULAR_EXPRESSION "abort;terminate;fatal"
|
FAIL_REGULAR_EXPRESSION "abort;terminate;fatal"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable( BazelReporter ${TESTS_DIR}/X30-BazelReporter.cpp )
|
catch2_add_extratest_no_pch_reuse( BazelReporter ${TESTS_DIR}/X30-BazelReporter.cpp )
|
||||||
target_compile_definitions( BazelReporter PRIVATE CATCH_CONFIG_BAZEL_SUPPORT )
|
target_compile_definitions( BazelReporter PRIVATE CATCH_CONFIG_BAZEL_SUPPORT )
|
||||||
target_link_libraries(BazelReporter Catch2_buildall_interface)
|
target_link_libraries(BazelReporter PRIVATE Catch2_buildall_interface)
|
||||||
add_test(NAME CATCH_CONFIG_BAZEL_REPORTER-1
|
add_test(NAME CATCH_CONFIG_BAZEL_REPORTER-1
|
||||||
COMMAND
|
COMMAND
|
||||||
"${PYTHON_EXECUTABLE}" "${CATCH_DIR}/tests/TestScripts/testBazelReporter.py" $<TARGET_FILE:BazelReporter> "${CMAKE_CURRENT_BINARY_DIR}"
|
"${PYTHON_EXECUTABLE}" "${CATCH_DIR}/tests/TestScripts/testBazelReporter.py" $<TARGET_FILE:BazelReporter> "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
@ -138,8 +154,7 @@ set_tests_properties(CATCH_CONFIG_BAZEL_REPORTER-1
|
|||||||
)
|
)
|
||||||
|
|
||||||
# We must now test this works without the build flag.
|
# We must now test this works without the build flag.
|
||||||
add_executable( BazelReporterNoCatchConfig ${TESTS_DIR}/X30-BazelReporter.cpp )
|
catch2_add_extratest( BazelReporterNoCatchConfig ${TESTS_DIR}/X30-BazelReporter.cpp )
|
||||||
target_link_libraries(BazelReporterNoCatchConfig Catch2WithMain)
|
|
||||||
add_test(NAME NO_CATCH_CONFIG_BAZEL_REPORTER-1
|
add_test(NAME NO_CATCH_CONFIG_BAZEL_REPORTER-1
|
||||||
COMMAND
|
COMMAND
|
||||||
"${PYTHON_EXECUTABLE}" "${CATCH_DIR}/tests/TestScripts/testBazelReporter.py" $<TARGET_FILE:BazelReporterNoCatchConfig> "${CMAKE_CURRENT_BINARY_DIR}"
|
"${PYTHON_EXECUTABLE}" "${CATCH_DIR}/tests/TestScripts/testBazelReporter.py" $<TARGET_FILE:BazelReporterNoCatchConfig> "${CMAKE_CURRENT_BINARY_DIR}"
|
||||||
@ -202,8 +217,7 @@ set_tests_properties(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_executable(DeferredStaticChecks ${TESTS_DIR}/X05-DeferredStaticChecks.cpp)
|
catch2_add_extratest_no_pch_reuse(DeferredStaticChecks ${TESTS_DIR}/X05-DeferredStaticChecks.cpp)
|
||||||
target_link_libraries(DeferredStaticChecks PRIVATE Catch2WithMain)
|
|
||||||
target_compile_definitions(DeferredStaticChecks PRIVATE "CATCH_CONFIG_RUNTIME_STATIC_REQUIRE")
|
target_compile_definitions(DeferredStaticChecks PRIVATE "CATCH_CONFIG_RUNTIME_STATIC_REQUIRE")
|
||||||
|
|
||||||
add_test(NAME DeferredStaticChecks COMMAND DeferredStaticChecks -r compact)
|
add_test(NAME DeferredStaticChecks COMMAND DeferredStaticChecks -r compact)
|
||||||
@ -214,9 +228,8 @@ set_tests_properties(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_executable(FallbackStringifier ${TESTS_DIR}/X10-FallbackStringifier.cpp)
|
catch2_add_extratest_no_pch_reuse(FallbackStringifier ${TESTS_DIR}/X10-FallbackStringifier.cpp)
|
||||||
target_compile_definitions( FallbackStringifier PRIVATE CATCH_CONFIG_FALLBACK_STRINGIFIER=fallbackStringifier )
|
target_compile_definitions( FallbackStringifier PRIVATE CATCH_CONFIG_FALLBACK_STRINGIFIER=fallbackStringifier )
|
||||||
target_link_libraries( FallbackStringifier Catch2WithMain )
|
|
||||||
|
|
||||||
add_test(NAME FallbackStringifier COMMAND FallbackStringifier -r compact -s)
|
add_test(NAME FallbackStringifier COMMAND FallbackStringifier -r compact -s)
|
||||||
set_tests_properties(
|
set_tests_properties(
|
||||||
@ -226,9 +239,8 @@ set_tests_properties(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_executable(DisableStringification ${TESTS_DIR}/X11-DisableStringification.cpp)
|
catch2_add_extratest_no_pch_reuse(DisableStringification ${TESTS_DIR}/X11-DisableStringification.cpp)
|
||||||
target_compile_definitions( DisableStringification PRIVATE CATCH_CONFIG_DISABLE_STRINGIFICATION )
|
target_compile_definitions( DisableStringification PRIVATE CATCH_CONFIG_DISABLE_STRINGIFICATION )
|
||||||
target_link_libraries(DisableStringification Catch2WithMain)
|
|
||||||
add_test(NAME CATCH_CONFIG_DISABLE_STRINGIFICATION COMMAND DisableStringification -r compact -s)
|
add_test(NAME CATCH_CONFIG_DISABLE_STRINGIFICATION COMMAND DisableStringification -r compact -s)
|
||||||
set_tests_properties(
|
set_tests_properties(
|
||||||
CATCH_CONFIG_DISABLE_STRINGIFICATION
|
CATCH_CONFIG_DISABLE_STRINGIFICATION
|
||||||
@ -241,15 +253,13 @@ set_tests_properties(
|
|||||||
# This test touches windows.h, so it should only be compiled under msvc
|
# This test touches windows.h, so it should only be compiled under msvc
|
||||||
if (MSVC)
|
if (MSVC)
|
||||||
# This test fails if it does not compile and succeeds otherwise
|
# This test fails if it does not compile and succeeds otherwise
|
||||||
add_executable(WindowsHeader ${TESTS_DIR}/X90-WindowsHeaderInclusion.cpp)
|
catch2_add_extratest(WindowsHeader ${TESTS_DIR}/X90-WindowsHeaderInclusion.cpp)
|
||||||
target_link_libraries( WindowsHeader Catch2WithMain )
|
|
||||||
add_test(NAME WindowsHeader COMMAND WindowsHeader -r compact)
|
add_test(NAME WindowsHeader COMMAND WindowsHeader -r compact)
|
||||||
list(APPEND CATCH_WARNING_TARGETS ${EXTRA_TEST_BINARIES} WindowsHeader)
|
list(APPEND CATCH_WARNING_TARGETS ${EXTRA_TEST_BINARIES} WindowsHeader)
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_executable(PartialTestCaseEvents ${TESTS_DIR}/X21-PartialTestCaseEvents.cpp)
|
catch2_add_extratest(PartialTestCaseEvents ${TESTS_DIR}/X21-PartialTestCaseEvents.cpp)
|
||||||
target_link_libraries(PartialTestCaseEvents PRIVATE Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME PartialTestCaseEvents
|
NAME PartialTestCaseEvents
|
||||||
COMMAND ${PYTHON_EXECUTABLE} ${CATCH_DIR}/tests/TestScripts/testPartialTestCaseEvent.py $<TARGET_FILE:PartialTestCaseEvents>
|
COMMAND ${PYTHON_EXECUTABLE} ${CATCH_DIR}/tests/TestScripts/testPartialTestCaseEvent.py $<TARGET_FILE:PartialTestCaseEvents>
|
||||||
@ -259,8 +269,7 @@ set_tests_properties(PartialTestCaseEvents
|
|||||||
LABELS "uses-python"
|
LABELS "uses-python"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(BenchmarksInCumulativeReporter ${TESTS_DIR}/X22-BenchmarksInCumulativeReporter.cpp)
|
catch2_add_extratest(BenchmarksInCumulativeReporter ${TESTS_DIR}/X22-BenchmarksInCumulativeReporter.cpp)
|
||||||
target_link_libraries(BenchmarksInCumulativeReporter PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME BenchmarksInCumulativeReporter
|
NAME BenchmarksInCumulativeReporter
|
||||||
COMMAND BenchmarksInCumulativeReporter --reporter testReporter
|
COMMAND BenchmarksInCumulativeReporter --reporter testReporter
|
||||||
@ -273,8 +282,7 @@ set_tests_properties(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_executable(CasingInReporterNames ${TESTS_DIR}/X23-CasingInReporterNames.cpp)
|
catch2_add_extratest(CasingInReporterNames ${TESTS_DIR}/X23-CasingInReporterNames.cpp)
|
||||||
target_link_libraries(CasingInReporterNames PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME Reporters::registration-is-case-preserving
|
NAME Reporters::registration-is-case-preserving
|
||||||
COMMAND CasingInReporterNames --list-reporters
|
COMMAND CasingInReporterNames --list-reporters
|
||||||
@ -294,8 +302,7 @@ set_tests_properties(
|
|||||||
PASS_REGULAR_EXPRESSION "TestReporter constructed"
|
PASS_REGULAR_EXPRESSION "TestReporter constructed"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(CapturedStdoutInTestCaseEvents ${TESTS_DIR}/X27-CapturedStdoutInTestCaseEvents.cpp)
|
catch2_add_extratest(CapturedStdoutInTestCaseEvents ${TESTS_DIR}/X27-CapturedStdoutInTestCaseEvents.cpp)
|
||||||
target_link_libraries(CapturedStdoutInTestCaseEvents PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME Reporters::CapturedStdOutInEvents
|
NAME Reporters::CapturedStdOutInEvents
|
||||||
COMMAND CapturedStdoutInTestCaseEvents
|
COMMAND CapturedStdoutInTestCaseEvents
|
||||||
@ -315,8 +322,7 @@ else()
|
|||||||
set(_NullFile "/dev/null")
|
set(_NullFile "/dev/null")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
add_executable(ListenerStdoutCaptureInMultireporter ${TESTS_DIR}/X24-ListenerStdoutCaptureInMultireporter.cpp)
|
catch2_add_extratest(ListenerStdoutCaptureInMultireporter ${TESTS_DIR}/X24-ListenerStdoutCaptureInMultireporter.cpp)
|
||||||
target_link_libraries(ListenerStdoutCaptureInMultireporter PRIVATE Catch2::Catch2WithMain)
|
|
||||||
|
|
||||||
# This test checks that there is nothing written out from the process,
|
# This test checks that there is nothing written out from the process,
|
||||||
# but if CMake is running the tests under Valgrind or similar tool, then
|
# but if CMake is running the tests under Valgrind or similar tool, then
|
||||||
@ -338,8 +344,7 @@ if (NOT MEMORYCHECK_COMMAND)
|
|||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
|
||||||
add_executable(ListenerCanAskForCapturedStdout ${TESTS_DIR}/X25-ListenerCanAskForCapturedStdout.cpp)
|
catch2_add_extratest(ListenerCanAskForCapturedStdout ${TESTS_DIR}/X25-ListenerCanAskForCapturedStdout.cpp)
|
||||||
target_link_libraries(ListenerCanAskForCapturedStdout PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME MultiReporter::CapturingListenerCausesStdoutCapture
|
NAME MultiReporter::CapturingListenerCausesStdoutCapture
|
||||||
COMMAND ListenerCanAskForCapturedStdout
|
COMMAND ListenerCanAskForCapturedStdout
|
||||||
@ -353,8 +358,7 @@ set_tests_properties(
|
|||||||
FAIL_REGULAR_EXPRESSION "X25 - ERROR"
|
FAIL_REGULAR_EXPRESSION "X25 - ERROR"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(ReporterPreferencesForPassingAssertionsIsRespected ${TESTS_DIR}/X26-ReporterPreferencesForPassingAssertionsIsRespected.cpp)
|
catch2_add_extratest(ReporterPreferencesForPassingAssertionsIsRespected ${TESTS_DIR}/X26-ReporterPreferencesForPassingAssertionsIsRespected.cpp)
|
||||||
target_link_libraries(ReporterPreferencesForPassingAssertionsIsRespected PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME Reporters::PreferencesForPassingAssertionsIsRespected
|
NAME Reporters::PreferencesForPassingAssertionsIsRespected
|
||||||
COMMAND ReporterPreferencesForPassingAssertionsIsRespected
|
COMMAND ReporterPreferencesForPassingAssertionsIsRespected
|
||||||
@ -379,8 +383,7 @@ set_tests_properties(
|
|||||||
FAIL_REGULAR_EXPRESSION "X26 - assertionEnded"
|
FAIL_REGULAR_EXPRESSION "X26 - assertionEnded"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(ListenersGetEventsBeforeReporters ${TESTS_DIR}/X28-ListenersGetEventsBeforeReporters.cpp)
|
catch2_add_extratest(ListenersGetEventsBeforeReporters ${TESTS_DIR}/X28-ListenersGetEventsBeforeReporters.cpp)
|
||||||
target_link_libraries(ListenersGetEventsBeforeReporters PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME ListenersGetEventsBeforeReporters
|
NAME ListenersGetEventsBeforeReporters
|
||||||
COMMAND ListenersGetEventsBeforeReporters --reporter test-reporter
|
COMMAND ListenersGetEventsBeforeReporters --reporter test-reporter
|
||||||
@ -392,8 +395,7 @@ set_tests_properties(
|
|||||||
FAIL_REGULAR_EXPRESSION "X28 - ERROR"
|
FAIL_REGULAR_EXPRESSION "X28 - ERROR"
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(CustomArgumentsForReporters ${TESTS_DIR}/X29-CustomArgumentsForReporters.cpp)
|
catch2_add_extratest(CustomArgumentsForReporters ${TESTS_DIR}/X29-CustomArgumentsForReporters.cpp)
|
||||||
target_link_libraries(CustomArgumentsForReporters PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME CustomArgumentsForReporters
|
NAME CustomArgumentsForReporters
|
||||||
COMMAND CustomArgumentsForReporters
|
COMMAND CustomArgumentsForReporters
|
||||||
@ -406,8 +408,7 @@ set_tests_properties(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_executable(DuplicatedTestCases-SameNameAndTags ${TESTS_DIR}/X31-DuplicatedTestCases.cpp)
|
catch2_add_extratest(DuplicatedTestCases-SameNameAndTags ${TESTS_DIR}/X31-DuplicatedTestCases.cpp)
|
||||||
target_link_libraries(DuplicatedTestCases-SameNameAndTags PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME DuplicatedTestCases::SameNameAndTags
|
NAME DuplicatedTestCases::SameNameAndTags
|
||||||
COMMAND $<TARGET_FILE:DuplicatedTestCases-SameNameAndTags>
|
COMMAND $<TARGET_FILE:DuplicatedTestCases-SameNameAndTags>
|
||||||
@ -418,8 +419,7 @@ set_tests_properties(
|
|||||||
PASS_REGULAR_EXPRESSION "error: .* already defined\\."
|
PASS_REGULAR_EXPRESSION "error: .* already defined\\."
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(DuplicatedTestCases-SameNameDifferentTags ${TESTS_DIR}/X32-DuplicatedTestCasesDifferentTags.cpp)
|
catch2_add_extratest(DuplicatedTestCases-SameNameDifferentTags ${TESTS_DIR}/X32-DuplicatedTestCasesDifferentTags.cpp)
|
||||||
target_link_libraries(DuplicatedTestCases-SameNameDifferentTags PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME DuplicatedTestCases::SameNameDifferentTags
|
NAME DuplicatedTestCases::SameNameDifferentTags
|
||||||
COMMAND $<TARGET_FILE:DuplicatedTestCases-SameNameDifferentTags>
|
COMMAND $<TARGET_FILE:DuplicatedTestCases-SameNameDifferentTags>
|
||||||
@ -430,8 +430,7 @@ set_tests_properties(
|
|||||||
FAIL_REGULAR_EXPRESSION "error: .* already defined\\."
|
FAIL_REGULAR_EXPRESSION "error: .* already defined\\."
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(DuplicatedTestCases-DuplicatedTestCaseMethods ${TESTS_DIR}/X33-DuplicatedTestCaseMethods.cpp)
|
catch2_add_extratest(DuplicatedTestCases-DuplicatedTestCaseMethods ${TESTS_DIR}/X33-DuplicatedTestCaseMethods.cpp)
|
||||||
target_link_libraries(DuplicatedTestCases-DuplicatedTestCaseMethods PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME DuplicatedTestCases::DuplicatedTestCaseMethods
|
NAME DuplicatedTestCases::DuplicatedTestCaseMethods
|
||||||
COMMAND $<TARGET_FILE:DuplicatedTestCases-DuplicatedTestCaseMethods>
|
COMMAND $<TARGET_FILE:DuplicatedTestCases-DuplicatedTestCaseMethods>
|
||||||
@ -442,8 +441,7 @@ set_tests_properties(
|
|||||||
PASS_REGULAR_EXPRESSION "error: .* already defined\\."
|
PASS_REGULAR_EXPRESSION "error: .* already defined\\."
|
||||||
)
|
)
|
||||||
|
|
||||||
add_executable(DuplicatedTestCases-DifferentFixtures ${TESTS_DIR}/X34-DuplicatedTestCaseMethodsDifferentFixtures.cpp)
|
catch2_add_extratest(DuplicatedTestCases-DifferentFixtures ${TESTS_DIR}/X34-DuplicatedTestCaseMethodsDifferentFixtures.cpp)
|
||||||
target_link_libraries(DuplicatedTestCases-DifferentFixtures PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME DuplicatedTestCases::DuplicatedTestCaseMethodsDifferentFixtures
|
NAME DuplicatedTestCases::DuplicatedTestCaseMethodsDifferentFixtures
|
||||||
COMMAND $<TARGET_FILE:DuplicatedTestCases-DifferentFixtures>
|
COMMAND $<TARGET_FILE:DuplicatedTestCases-DifferentFixtures>
|
||||||
@ -455,8 +453,7 @@ set_tests_properties(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_executable(DuplicatedReporters ${TESTS_DIR}/X35-DuplicatedReporterNames.cpp)
|
catch2_add_extratest(DuplicatedReporters ${TESTS_DIR}/X35-DuplicatedReporterNames.cpp)
|
||||||
target_link_libraries(DuplicatedReporters PRIVATE Catch2::Catch2WithMain)
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME Reporters::RegistrationErrorsAreCaught
|
NAME Reporters::RegistrationErrorsAreCaught
|
||||||
COMMAND $<TARGET_FILE:DuplicatedReporters>
|
COMMAND $<TARGET_FILE:DuplicatedReporters>
|
||||||
@ -468,18 +465,15 @@ set_tests_properties(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_executable(AssertionStartingEventGoesBeforeAssertionIsEvaluated
|
catch2_add_extratest(AssertionStartingEventGoesBeforeAssertionIsEvaluated
|
||||||
X20-AssertionStartingEventGoesBeforeAssertionIsEvaluated.cpp
|
${TESTS_DIR}/X20-AssertionStartingEventGoesBeforeAssertionIsEvaluated.cpp
|
||||||
)
|
|
||||||
target_link_libraries(AssertionStartingEventGoesBeforeAssertionIsEvaluated
|
|
||||||
PRIVATE Catch2::Catch2WithMain
|
|
||||||
)
|
)
|
||||||
add_test(
|
add_test(
|
||||||
NAME ReporterEvents::AssertionStartingHappensBeforeAssertionIsEvaluated
|
NAME ReporterEvents::AssertionStartingHappensBeforeAssertionIsEvaluated
|
||||||
COMMAND $<TARGET_FILE:AssertionStartingEventGoesBeforeAssertionIsEvaluated>
|
COMMAND $<TARGET_FILE:AssertionStartingEventGoesBeforeAssertionIsEvaluated>
|
||||||
)
|
)
|
||||||
|
|
||||||
#add_executable(DebugBreakMacros ${TESTS_DIR}/X12-CustomDebugBreakMacro.cpp)
|
#catch2_add_extratest(DebugBreakMacros ${TESTS_DIR}/X12-CustomDebugBreakMacro.cpp)
|
||||||
#target_link_libraries(DebugBreakMacros Catch2)
|
#target_link_libraries(DebugBreakMacros Catch2)
|
||||||
#add_test(NAME DebugBreakMacros COMMAND DebugBreakMacros --break)
|
#add_test(NAME DebugBreakMacros COMMAND DebugBreakMacros --break)
|
||||||
#set_tests_properties(
|
#set_tests_properties(
|
||||||
@ -488,8 +482,7 @@ add_test(
|
|||||||
# PASS_REGULAR_EXPRESSION "Pretty please, break into debugger"
|
# PASS_REGULAR_EXPRESSION "Pretty please, break into debugger"
|
||||||
#)
|
#)
|
||||||
|
|
||||||
add_executable(NoTests ${TESTS_DIR}/X92-NoTests.cpp)
|
catch2_add_extratest(NoTests ${TESTS_DIR}/X92-NoTests.cpp)
|
||||||
target_link_libraries(NoTests PRIVATE Catch2::Catch2WithMain)
|
|
||||||
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME TestSpecs::EmptySpecWithNoTestsFails
|
NAME TestSpecs::EmptySpecWithNoTestsFails
|
||||||
@ -511,8 +504,7 @@ add_test(
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
add_executable(AllSkipped ${TESTS_DIR}/X93-AllSkipped.cpp)
|
catch2_add_extratest(AllSkipped ${TESTS_DIR}/X93-AllSkipped.cpp)
|
||||||
target_link_libraries(AllSkipped PRIVATE Catch2::Catch2WithMain)
|
|
||||||
|
|
||||||
add_test(
|
add_test(
|
||||||
NAME TestSpecs::SkippingAllTestsFails
|
NAME TestSpecs::SkippingAllTestsFails
|
||||||
@ -557,6 +549,10 @@ add_executable(AmalgamatedTestCompilation
|
|||||||
)
|
)
|
||||||
target_include_directories(AmalgamatedTestCompilation PRIVATE ${CATCH_DIR}/extras)
|
target_include_directories(AmalgamatedTestCompilation PRIVATE ${CATCH_DIR}/extras)
|
||||||
|
|
||||||
|
if (CATCH_ENABLE_PCH)
|
||||||
|
target_precompile_headers(AmalgamatedTestCompilation REUSE_FROM Catch2)
|
||||||
|
endif()
|
||||||
|
|
||||||
add_test(NAME AmalgamatedFileTest COMMAND AmalgamatedTestCompilation)
|
add_test(NAME AmalgamatedFileTest COMMAND AmalgamatedTestCompilation)
|
||||||
set_tests_properties(
|
set_tests_properties(
|
||||||
AmalgamatedFileTest
|
AmalgamatedFileTest
|
||||||
|
@ -25,6 +25,16 @@ namespace bar {
|
|||||||
struct TypeList {};
|
struct TypeList {};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef __clang__
|
||||||
|
#pragma clang diagnostic push
|
||||||
|
#pragma clang diagnostic ignored "-Wunused-function"
|
||||||
|
#endif
|
||||||
|
#ifdef __GNUC__
|
||||||
|
// Note that because -~GCC~-, this warning cannot be silenced temporarily, by pushing diagnostic stack...
|
||||||
|
// Luckily it is firing in test files and thus can be silenced for the whole file, without losing much.
|
||||||
|
#pragma GCC diagnostic ignored "-Wunused-function"
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef __GNUC__
|
#ifdef __GNUC__
|
||||||
#pragma GCC diagnostic ignored "-Wmissing-declarations"
|
#pragma GCC diagnostic ignored "-Wmissing-declarations"
|
||||||
#endif
|
#endif
|
||||||
@ -77,16 +87,6 @@ struct B : private A {
|
|||||||
bool operator==(int) const { return true; }
|
bool operator==(int) const { return true; }
|
||||||
};
|
};
|
||||||
|
|
||||||
#ifdef __clang__
|
|
||||||
#pragma clang diagnostic push
|
|
||||||
#pragma clang diagnostic ignored "-Wunused-function"
|
|
||||||
#endif
|
|
||||||
#ifdef __GNUC__
|
|
||||||
// Note that because -~GCC~-, this warning cannot be silenced temporarily, by pushing diagnostic stack...
|
|
||||||
// Luckily it is firing in test files and thus can be silenced for the whole file, without losing much.
|
|
||||||
#pragma GCC diagnostic ignored "-Wunused-function"
|
|
||||||
#endif
|
|
||||||
|
|
||||||
B f();
|
B f();
|
||||||
|
|
||||||
std::ostream g();
|
std::ostream g();
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
|
|
||||||
#if defined(CATCH_CONFIG_CPP17_OPTIONAL)
|
#if defined(CATCH_CONFIG_CPP17_OPTIONAL)
|
||||||
|
|
||||||
|
#include <optional>
|
||||||
|
|
||||||
TEST_CASE( "std::optional<int> -> toString", "[toString][optional][approvals]" ) {
|
TEST_CASE( "std::optional<int> -> toString", "[toString][optional][approvals]" ) {
|
||||||
using type = std::optional<int>;
|
using type = std::optional<int>;
|
||||||
REQUIRE( "{ }" == ::Catch::Detail::stringify( type{} ) );
|
REQUIRE( "{ }" == ::Catch::Detail::stringify( type{} ) );
|
||||||
|
@ -11,6 +11,10 @@ add_executable(tests
|
|||||||
add_subdirectory(${CATCH2_PATH} catch2-build)
|
add_subdirectory(${CATCH2_PATH} catch2-build)
|
||||||
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
|
target_link_libraries(tests PRIVATE Catch2::Catch2WithMain)
|
||||||
|
|
||||||
|
if (CATCH_ENABLE_PCH)
|
||||||
|
target_precompile_headers(tests REUSE_FROM Catch2)
|
||||||
|
endif()
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
include(Catch)
|
include(Catch)
|
||||||
catch_discover_tests(tests)
|
catch_discover_tests(tests)
|
||||||
|
Loading…
Reference in New Issue
Block a user