diff --git a/.gitmodules b/.gitmodules index ad0e89c9..de96c6f9 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,9 +1,6 @@ [submodule "lib/fmt"] path = 3rdparty/fmt url = https://github.com/fmtlib/fmt -[submodule "3rdparty/googletest"] - path = 3rdparty/googletest - url = https://github.com/google/googletest [submodule "3rdparty/json"] path = 3rdparty/json url = https://github.com/ArthurSonzogni/nlohmann_json_cmake_fetchcontent @@ -13,3 +10,6 @@ [submodule "3rdparty/subprocess.h"] path = 3rdparty/subprocess.h url = https://github.com/sheredom/subprocess.h +[submodule "3rdparty/Catch2"] + path = 3rdparty/Catch2 + url = https://github.com/catchorg/Catch2 diff --git a/3rdparty/CMakeLists.txt b/3rdparty/CMakeLists.txt index 323b4ef0..6bd8f098 100644 --- a/3rdparty/CMakeLists.txt +++ b/3rdparty/CMakeLists.txt @@ -1,9 +1,4 @@ add_subdirectory(fmt EXCLUDE_FROM_ALL) - -set(BUILD_GMOCK ON CACHE BOOL "" FORCE) -set(INSTALL_GTEST OFF CACHE BOOL "" FORCE) -set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) -add_subdirectory(googletest EXCLUDE_FROM_ALL) - +add_subdirectory(Catch2 EXCLUDE_FROM_ALL) add_subdirectory(json EXCLUDE_FROM_ALL) add_subdirectory(nanobench EXCLUDE_FROM_ALL) diff --git a/3rdparty/Catch2 b/3rdparty/Catch2 new file mode 160000 index 00000000..62fd6605 --- /dev/null +++ b/3rdparty/Catch2 @@ -0,0 +1 @@ +Subproject commit 62fd660583d3ae7a7886930b413c3c570e89786c diff --git a/3rdparty/googletest b/3rdparty/googletest deleted file mode 160000 index e2239ee6..00000000 --- a/3rdparty/googletest +++ /dev/null @@ -1 +0,0 @@ -Subproject commit e2239ee6043f73722e7aa812a459f54a28552929 diff --git a/CMakeLists.txt b/CMakeLists.txt index 8d0f6a90..db8f7e14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,8 @@ cmake_policy(SET CMP0028 NEW) project (ericw-tools) -set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/3rdparty/Catch2/contrib") # Grab the git describe output and store it in GIT_DESCRIBE # Thanks to http://xit0.org/2013/04/cmake-use-git-branch-and-commit-details-in-project/ diff --git a/common/CMakeLists.txt b/common/CMakeLists.txt index 12e4a3b3..490285f3 100644 --- a/common/CMakeLists.txt +++ b/common/CMakeLists.txt @@ -44,7 +44,8 @@ add_executable(testcommon ${COMMON_TEST_SOURCE}) # HACK: copy .dll dependencies add_custom_command(TARGET testcommon POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$") -target_link_libraries (testcommon common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb gtest gmock fmt::fmt) +target_link_libraries (testcommon common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb Catch2::Catch2 fmt::fmt) -include(GoogleTest) -gtest_discover_tests(testcommon) +include(CTest) +include(Catch) +catch_discover_tests(testcommon) \ No newline at end of file diff --git a/common/test.cc b/common/test.cc index 747a38f7..d734540c 100644 --- a/common/test.cc +++ b/common/test.cc @@ -1,4 +1,6 @@ -#include "gtest/gtest.h" +#define CATCH_CONFIG_MAIN // request a main() +#include + #include "common/settings.hh" #include @@ -368,9 +370,3 @@ TEST(settings, resetContainer) EXPECT_TRUE(settings::source::DEFAULT == stringSetting1.getSource()); EXPECT_TRUE("abc" == stringSetting1.value()); } - -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} diff --git a/light/CMakeLists.txt b/light/CMakeLists.txt index 691ee455..123f883a 100644 --- a/light/CMakeLists.txt +++ b/light/CMakeLists.txt @@ -127,7 +127,7 @@ set(LIGHT_TEST_SOURCE test_light.cc test_common.cc) add_executable(testlight ${LIGHT_TEST_SOURCE}) -target_link_libraries (testlight PRIVATE liblight common ${CMAKE_THREAD_LIBS_INIT} gtest gmock fmt::fmt) +target_link_libraries (testlight PRIVATE liblight common ${CMAKE_THREAD_LIBS_INIT} Catch2::Catch2 fmt::fmt) if (embree_FOUND) target_link_libraries (testlight PRIVATE embree) @@ -144,5 +144,6 @@ if (embree_FOUND) add_definitions(-DHAVE_EMBREE) endif (embree_FOUND) -include(GoogleTest) -gtest_discover_tests(testlight) +include(CTest) +include(Catch) +catch_discover_tests(testlight) \ No newline at end of file diff --git a/light/test.cc b/light/test.cc index 7b7d6f3d..ecefaa92 100644 --- a/light/test.cc +++ b/light/test.cc @@ -1,7 +1,2 @@ -#include "gtest/gtest.h" - -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} +#define CATCH_CONFIG_MAIN // request a main() +#include \ No newline at end of file diff --git a/light/test_common.cc b/light/test_common.cc index 93ce255f..6accb627 100644 --- a/light/test_common.cc +++ b/light/test_common.cc @@ -1,4 +1,4 @@ -#include "gtest/gtest.h" +#include #include #include diff --git a/light/test_entities.cc b/light/test_entities.cc index 81ef8be4..b73256dc 100644 --- a/light/test_entities.cc +++ b/light/test_entities.cc @@ -1,4 +1,4 @@ -#include "gtest/gtest.h" +#include #include #include diff --git a/light/test_light.cc b/light/test_light.cc index e31a8379..37e2ab9f 100644 --- a/light/test_light.cc +++ b/light/test_light.cc @@ -1,4 +1,4 @@ -#include "gtest/gtest.h" +#include #include #include diff --git a/light/test_ltface.cc b/light/test_ltface.cc index 8b8b9bea..37e38563 100644 --- a/light/test_ltface.cc +++ b/light/test_ltface.cc @@ -1,3 +1,3 @@ -#include "gtest/gtest.h" +#include #include diff --git a/qbsp/CMakeLists.txt b/qbsp/CMakeLists.txt index 719d0ebd..e3117657 100644 --- a/qbsp/CMakeLists.txt +++ b/qbsp/CMakeLists.txt @@ -49,11 +49,12 @@ set(QBSP_TEST_SOURCE test_qbsp.cc ${CMAKE_BINARY_DIR}/testmaps.hh) add_executable(testqbsp ${QBSP_TEST_SOURCE}) -target_link_libraries (testqbsp libqbsp common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb gtest gmock fmt::fmt nanobench::nanobench) +target_link_libraries (testqbsp libqbsp common ${CMAKE_THREAD_LIBS_INIT} TBB::tbb Catch2::Catch2 fmt::fmt nanobench::nanobench) # HACK: copy .dll dependencies add_custom_command(TARGET testqbsp POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy_if_different "$" "$") -include(GoogleTest) -gtest_discover_tests(testqbsp) +include(CTest) +include(Catch) +catch_discover_tests(testqbsp) \ No newline at end of file diff --git a/qbsp/test.cc b/qbsp/test.cc index 7b7d6f3d..1a272923 100644 --- a/qbsp/test.cc +++ b/qbsp/test.cc @@ -1,7 +1,2 @@ -#include "gtest/gtest.h" - -int main(int argc, char **argv) -{ - ::testing::InitGoogleTest(&argc, argv); - return RUN_ALL_TESTS(); -} +#define CATCH_CONFIG_MAIN // request a main() +#include diff --git a/qbsp/test_qbsp.cc b/qbsp/test_qbsp.cc index 1b75802b..e85d00f4 100644 --- a/qbsp/test_qbsp.cc +++ b/qbsp/test_qbsp.cc @@ -1,5 +1,4 @@ -#include -#include +#include #include #include @@ -18,8 +17,6 @@ #include #include -using namespace testing; - // FIXME: Clear global data (planes, etc) between each test static const mapface_t *Mapbrush_FirstFaceWithTextureName(const mapbrush_t *brush, const std::string &texname)