diff options
| author | Leitwolf | 2026-10-25 10:31:36 +0300 |
|---|---|---|
| committer | GitHub | 2026-10-25 10:31:36 +0300 |
| commit | d2e3e074bb2e1b8ffd9fc990d0b87667ea602f58 (patch) | |
| tree | 0bce4462b2e190c39b3e1c5f697e3e4abd1a5e2a /tests | |
| parent | 13f81a480a93807c14dddb5abdb97355ced4d4c5 (diff) | |
| parent | 126dc333564cb72b5115d9a9242d66694694b6d0 (diff) | |
| download | catch3-d2e3e074bb2e1b8ffd9fc990d0b87667ea602f58.tar.gz | |
Merge pull request #18 from Progmasoft/build/catch3-identity
Give Catch3 its own build names and headers
Diffstat (limited to 'tests')
99 files changed, 336 insertions, 367 deletions
diff --git a/tests/BUILD.bazel b/tests/BUILD.bazel index 00c39a7d..1fe8cb2b 100644 --- a/tests/BUILD.bazel +++ b/tests/BUILD.bazel @@ -3,7 +3,7 @@ load("@rules_cc//cc:defs.bzl", "cc_library", "cc_test") package(default_visibility = ["//visibility:public"]) cc_library( - name = "catch2_self_test_helper", + name = "catch3_self_test_helper", srcs = ["SelfTest/helpers/parse_test_spec.cpp"], hdrs = [ "SelfTest/helpers/parse_test_spec.hpp", @@ -12,12 +12,12 @@ cc_library( ], includes = ["SelfTest"], deps = [ - "//:catch2", + "//:catch3", ], ) cc_test( - name = "catch2_self_test", + name = "catch3_self_test", size = "small", srcs = [ "SelfTest/IntrospectiveTests/Algorithms.tests.cpp", @@ -70,8 +70,8 @@ cc_test( "SelfTest/UsageTests/VariadicMacros.tests.cpp", ], deps = [ - ":catch2_self_test_helper", - "//:catch2", - "//:catch2_main", + ":catch3_self_test_helper", + "//:catch3", + "//:catch3_main", ], ) diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 71411b53..5d152378 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -1,6 +1,6 @@ include(CatchMiscFunctions) -if(CATCH_BUILD_SURROGATES) +if(CATCH3_BUILD_SURROGATES) message(STATUS "Configuring targets for surrogate TUs") # If the folder does not exist before we ask for output redirect to @@ -13,7 +13,10 @@ if(CATCH_BUILD_SURROGATES) set(pathPrefix ${PROJECT_SOURCE_DIR}/src) file(RELATIVE_PATH includePath ${pathPrefix} ${sourceHeader}) - get_filename_component(basicFileName "${sourceHeader}" NAME_WE) + # Headers in different directories may share a name, so the directory + # is part of the surrogate's name. + string(REGEX REPLACE "\\.hpp$" "" basicFileName "${includePath}") + string(REPLACE "/" "_" basicFileName "${basicFileName}") set(surrogateFilePath ${CMAKE_CURRENT_BINARY_DIR}/surrogates/surrogate_${basicFileName}.cpp) add_custom_command( @@ -25,24 +28,26 @@ if(CATCH_BUILD_SURROGATES) set(${pathToFile} ${surrogateFilePath} PARENT_SCOPE) endfunction() - # Extracts all non-helper (e.g. catch_all.hpp) headers from the - # Catch2 target, and returns them through the argument. - function(ExtractCatch2Headers OutArg) - get_target_property(targetSources Catch2 SOURCES) + # Extracts all non-helper (e.g. Progmasoft/Catch3/All.hpp) headers from the + # Catch3 target, and returns them through the argument. + function(ExtractCatch3Headers OutArg) + # The engine's headers are the ones that come from Catch2. The other + # headers need C++20; the surrogates check the engine's headers at the + # language level of the build. + file(STRINGS "${CATCH_DIR}/tools/scripts/upstreamFiles.txt" upstreamFiles REGEX "^src/") + get_target_property(targetSources Catch3 SOURCES) foreach(Source ${targetSources}) string(REGEX MATCH "^.*\\.hpp$" isHeader ${Source}) - string(REGEX MATCH "_all.hpp" isAllHeader ${Source}) - # The runner's headers need C++20; the surrogates check Catch2's - # headers at the language level of the build. - string(REGEX MATCH "/Progmasoft/" isRunnerHeader ${Source}) - if(isHeader AND NOT isAllHeader AND NOT isRunnerHeader) + string(REGEX MATCH "/All\\.hpp$" isAllHeader ${Source}) + file(RELATIVE_PATH relativeSource "${CATCH_DIR}" "${Source}") + if(isHeader AND NOT isAllHeader AND relativeSource IN_LIST upstreamFiles) list(APPEND AllHeaders ${Source}) endif() endforeach() set(${OutArg} ${AllHeaders} PARENT_SCOPE) endfunction() - ExtractCatch2Headers(mainHeaders) + ExtractCatch3Headers(mainHeaders) if(NOT mainHeaders) message(FATAL_ERROR "No headers in the main target were detected. Something is broken.") @@ -53,10 +58,10 @@ if(CATCH_BUILD_SURROGATES) list(APPEND surrogateFiles ${pathToGeneratedFile}) endforeach() - add_executable(Catch2SurrogateTarget + add_executable(Catch3SurrogateTarget ${surrogateFiles} ) - target_link_libraries(Catch2SurrogateTarget PRIVATE Catch2WithMain) + target_link_libraries(Catch3SurrogateTarget PRIVATE Catch3WithMain) endif() #### @@ -146,7 +151,7 @@ include(CTest) add_executable(SelfTest ${TEST_SOURCES} ${TEST_HEADERS}) target_include_directories(SelfTest PRIVATE ${SELF_TEST_DIR}) -target_link_libraries(SelfTest PRIVATE Catch2WithMain) +target_link_libraries(SelfTest PRIVATE Catch3WithMain) # Exercise the C++20 Progmasoft layer independently so the upstream Catch2 # SelfTest continues to compile at its supported baseline language level. @@ -165,12 +170,12 @@ add_executable(ProgmasoftSelfTest Progmasoft/Stateful.tests.cpp Progmasoft/Strategy.tests.cpp ) -target_link_libraries(ProgmasoftSelfTest PRIVATE Progmasoft::Catch3 Catch2WithMain) +target_link_libraries(ProgmasoftSelfTest PRIVATE Catch3WithMain) target_compile_features(ProgmasoftSelfTest PRIVATE cxx_std_20) # Tests that misbehave on purpose, for the runner's integration tests. add_executable(RunnerFixture Progmasoft/RunnerFixture.cpp) -target_link_libraries(RunnerFixture PRIVATE Catch2WithMain) +target_link_libraries(RunnerFixture PRIVATE Catch3WithMain) target_compile_features(RunnerFixture PRIVATE cxx_std_20) add_dependencies(ProgmasoftSelfTest RunnerFixture) @@ -180,12 +185,12 @@ set_tests_properties(Progmasoft::PropertyTests PROPERTIES ) if(BUILD_SHARED_LIBS AND WIN32) add_custom_command(TARGET SelfTest PRE_LINK - COMMAND ${CMAKE_COMMAND} -E copy_if_different $<TARGET_FILE:Catch2> - $<TARGET_FILE:Catch2WithMain> $<TARGET_FILE_DIR:SelfTest> + COMMAND $ |