From df25da6d04f43bec03c085bd0ae4b2fbc6273d7c Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Sun, 30 Jul 2023 11:12:29 +0200 Subject: [PATCH] Switch to system Catch2 In case the tests are enabled, require a system installed version of Catch2: - find it using its CMake config file - use the Catch2::Catch2 CMake target - switch the includes to the canonical form - stop using the tools/include subdirectory in the include path Also adapt the Nix configuration for this. --- CMakeLists.txt | 3 ++- shell.nix | 1 + test/CMakeLists.txt | 2 +- test/cereal/immer_array.cpp | 2 +- test/cereal/immer_box.cpp | 2 +- test/cereal/immer_flex_vector.cpp | 2 +- test/cereal/immer_vector.cpp | 2 +- test/cereal/tuple.cpp | 2 +- test/cereal/variant_with_name.cpp | 2 +- test/core.cpp | 2 +- test/cursor.cpp | 2 +- test/debug.cpp | 2 +- test/deps.cpp | 2 +- test/detail/nodes.cpp | 2 +- test/errors.cpp | 2 +- test/event_loop/boost_asio.cpp | 2 +- test/event_loop/manual.cpp | 2 +- test/event_loop/qml.cpp | 2 +- test/event_loop/qt.cpp | 2 +- test/event_loop/queue.cpp | 2 +- test/event_loop/safe_queue.cpp | 2 +- test/extra/derive.cpp | 2 +- test/extra/enum.cpp | 2 +- test/extra/struct.cpp | 2 +- test/futures.cpp | 2 +- test/lenses.cpp | 2 +- test/sensor.cpp | 2 +- test/setter.cpp | 2 +- test/state.cpp | 2 +- test/type_erased_lens.cpp | 2 +- test/util.cpp | 2 +- test/watchers.cpp | 2 +- test/xformed.cpp | 2 +- 33 files changed, 34 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f3e0ae81..e1c276a0 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -77,9 +77,10 @@ endif() # the library, local development target if(lager_BUILD_TESTS) + find_package(Catch2 REQUIRED) + add_library(lager-dev INTERFACE) target_include_directories(lager-dev SYSTEM INTERFACE - "$/tools/include" ${lager_SOURCE_DIR} ${Boost_INCLUDE_DIR} ) diff --git a/shell.nix b/shell.nix index de6d6f59..749bdbb8 100644 --- a/shell.nix +++ b/shell.nix @@ -36,6 +36,7 @@ in theStdenv.mkDerivation rec { name = "lager-env"; buildInputs = [ + catch2 cmake ccache ncurses diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index b7db9a73..dc7eed11 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -63,7 +63,7 @@ foreach(_file IN LISTS lager_unit_tests) set_target_properties(${_target} PROPERTIES OUTPUT_NAME ${_output}) add_dependencies(tests ${_target}) target_compile_definitions(${_target} PUBLIC CATCH_CONFIG_MAIN) - target_link_libraries(${_target} PUBLIC lager-dev ${_qt_libs}) + target_link_libraries(${_target} PUBLIC lager-dev Catch2::Catch2 ${_qt_libs}) add_test("test/${_output}" ${_output}) endforeach() diff --git a/test/cereal/immer_array.cpp b/test/cereal/immer_array.cpp index 5d5b3bbc..ac48c328 100644 --- a/test/cereal/immer_array.cpp +++ b/test/cereal/immer_array.cpp @@ -11,7 +11,7 @@ // #include "cerealize.hpp" -#include +#include #include TEST_CASE("basic") diff --git a/test/cereal/immer_box.cpp b/test/cereal/immer_box.cpp index 708f5636..97297d53 100644 --- a/test/cereal/immer_box.cpp +++ b/test/cereal/immer_box.cpp @@ -11,7 +11,7 @@ // #include "cerealize.hpp" -#include +#include #include TEST_CASE("basic") diff --git a/test/cereal/immer_flex_vector.cpp b/test/cereal/immer_flex_vector.cpp index 68554573..0b39b436 100644 --- a/test/cereal/immer_flex_vector.cpp +++ b/test/cereal/immer_flex_vector.cpp @@ -11,7 +11,7 @@ // #include "cerealize.hpp" -#include +#include #include TEST_CASE("basic") diff --git a/test/cereal/immer_vector.cpp b/test/cereal/immer_vector.cpp index 56bb22ba..5fa24b8e 100644 --- a/test/cereal/immer_vector.cpp +++ b/test/cereal/immer_vector.cpp @@ -11,7 +11,7 @@ // #include "cerealize.hpp" -#include +#include #include TEST_CASE("basic") diff --git a/test/cereal/tuple.cpp b/test/cereal/tuple.cpp index c824829b..33840a4a 100644 --- a/test/cereal/tuple.cpp +++ b/test/cereal/tuple.cpp @@ -11,7 +11,7 @@ // #include "cerealize.hpp" -#include +#include #include TEST_CASE("basic") diff --git a/test/cereal/variant_with_name.cpp b/test/cereal/variant_with_name.cpp index fdba9132..20b49338 100644 --- a/test/cereal/variant_with_name.cpp +++ b/test/cereal/variant_with_name.cpp @@ -11,7 +11,7 @@ // #include "cerealize.hpp" -#include +#include #include TEST_CASE("basic") diff --git a/test/core.cpp b/test/core.cpp index b5999d84..ccc65691 100644 --- a/test/core.cpp +++ b/test/core.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/cursor.cpp b/test/cursor.cpp index 0cc801eb..7e807d86 100644 --- a/test/cursor.cpp +++ b/test/cursor.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/debug.cpp b/test/debug.cpp index 3d2988e3..b86360a3 100644 --- a/test/debug.cpp +++ b/test/debug.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/deps.cpp b/test/deps.cpp index 5eafeaa4..ccae5830 100644 --- a/test/deps.cpp +++ b/test/deps.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include diff --git a/test/detail/nodes.cpp b/test/detail/nodes.cpp index 9dacdab3..e7cce062 100644 --- a/test/detail/nodes.cpp +++ b/test/detail/nodes.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include "../spies.hpp" diff --git a/test/errors.cpp b/test/errors.cpp index aa32ef77..cdd2d035 100644 --- a/test/errors.cpp +++ b/test/errors.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/event_loop/boost_asio.cpp b/test/event_loop/boost_asio.cpp index 7cdcace2..15cd206b 100644 --- a/test/event_loop/boost_asio.cpp +++ b/test/event_loop/boost_asio.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/event_loop/manual.cpp b/test/event_loop/manual.cpp index d56ffc04..72f143fc 100644 --- a/test/event_loop/manual.cpp +++ b/test/event_loop/manual.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/event_loop/qml.cpp b/test/event_loop/qml.cpp index 635f0086..03c65a83 100644 --- a/test/event_loop/qml.cpp +++ b/test/event_loop/qml.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/event_loop/qt.cpp b/test/event_loop/qt.cpp index 67c19148..5cc622df 100644 --- a/test/event_loop/qt.cpp +++ b/test/event_loop/qt.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include diff --git a/test/event_loop/queue.cpp b/test/event_loop/queue.cpp index 3c47b85e..d162f180 100644 --- a/test/event_loop/queue.cpp +++ b/test/event_loop/queue.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/event_loop/safe_queue.cpp b/test/event_loop/safe_queue.cpp index bbe0aea2..06a6f16d 100644 --- a/test/event_loop/safe_queue.cpp +++ b/test/event_loop/safe_queue.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/extra/derive.cpp b/test/extra/derive.cpp index 3c2caa51..72d2b735 100644 --- a/test/extra/derive.cpp +++ b/test/extra/derive.cpp @@ -12,7 +12,7 @@ #include "test/cereal/cerealize.hpp" -#include +#include #include #include diff --git a/test/extra/enum.cpp b/test/extra/enum.cpp index 2cce007a..b90204ff 100644 --- a/test/extra/enum.cpp +++ b/test/extra/enum.cpp @@ -11,7 +11,7 @@ // #include "test/cereal/cerealize.hpp" -#include +#include #include #include diff --git a/test/extra/struct.cpp b/test/extra/struct.cpp index dab4a88e..e8e145ad 100644 --- a/test/extra/struct.cpp +++ b/test/extra/struct.cpp @@ -11,7 +11,7 @@ // #include "test/cereal/cerealize.hpp" -#include +#include #include #include diff --git a/test/futures.cpp b/test/futures.cpp index 8c84421e..4a9ff371 100644 --- a/test/futures.cpp +++ b/test/futures.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/lenses.cpp b/test/lenses.cpp index 3446d756..8b159f87 100644 --- a/test/lenses.cpp +++ b/test/lenses.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/sensor.cpp b/test/sensor.cpp index 8ea1879c..a1532d16 100644 --- a/test/sensor.cpp +++ b/test/sensor.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include diff --git a/test/setter.cpp b/test/setter.cpp index 183c0069..6ecd0593 100644 --- a/test/setter.cpp +++ b/test/setter.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include diff --git a/test/state.cpp b/test/state.cpp index 5eeb6668..95d2562b 100644 --- a/test/state.cpp +++ b/test/state.cpp @@ -12,7 +12,7 @@ #include -#include +#include #include diff --git a/test/type_erased_lens.cpp b/test/type_erased_lens.cpp index 4d1323e6..1460da44 100644 --- a/test/type_erased_lens.cpp +++ b/test/type_erased_lens.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include diff --git a/test/util.cpp b/test/util.cpp index 06d6dda9..839e58e7 100644 --- a/test/util.cpp +++ b/test/util.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include diff --git a/test/watchers.cpp b/test/watchers.cpp index b8aa0ec8..52dcab55 100644 --- a/test/watchers.cpp +++ b/test/watchers.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include diff --git a/test/xformed.cpp b/test/xformed.cpp index 93d705e4..f9b23b03 100644 --- a/test/xformed.cpp +++ b/test/xformed.cpp @@ -10,7 +10,7 @@ // or here: // -#include +#include #include #include