test: swap GTest out in favour of Catch2

This commit is contained in:
Eric Wasylishen 2022-05-15 11:51:35 -06:00
parent 254310dc2c
commit 9fe42ef6c7
16 changed files with 31 additions and 49 deletions

6
.gitmodules vendored
View File

@ -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

View File

@ -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)

1
3rdparty/Catch2 vendored Submodule

@ -0,0 +1 @@
Subproject commit 62fd660583d3ae7a7886930b413c3c570e89786c

1
3rdparty/googletest vendored

@ -1 +0,0 @@
Subproject commit e2239ee6043f73722e7aa812a459f54a28552929

View File

@ -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/

View File

@ -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_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:testcommon>")
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)

View File

@ -1,4 +1,6 @@
#include "gtest/gtest.h"
#define CATCH_CONFIG_MAIN // request a main()
#include <Catch2/catch.hpp>
#include "common/settings.hh"
#include <type_traits>
@ -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();
}

View File

@ -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)

View File

@ -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 <Catch2/catch.hpp>

View File

@ -1,4 +1,4 @@
#include "gtest/gtest.h"
#include <Catch2/catch.hpp>
#include <filesystem>
#include <string>

View File

@ -1,4 +1,4 @@
#include "gtest/gtest.h"
#include <Catch2/catch.hpp>
#include <light/entities.hh>
#include <vector>

View File

@ -1,4 +1,4 @@
#include "gtest/gtest.h"
#include <Catch2/catch.hpp>
#include <light/light.hh>
#include <light/entities.hh>

View File

@ -1,3 +1,3 @@
#include "gtest/gtest.h"
#include <Catch2/catch.hpp>
#include <light/ltface.hh>

View File

@ -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 "$<TARGET_FILE:TBB::tbb>" "$<TARGET_FILE_DIR:testqbsp>")
include(GoogleTest)
gtest_discover_tests(testqbsp)
include(CTest)
include(Catch)
catch_discover_tests(testqbsp)

View File

@ -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 <Catch2/catch.hpp>

View File

@ -1,5 +1,4 @@
#include <gmock/gmock.h>
#include <gtest/gtest.h>
#include <Catch2/catch.hpp>
#include <qbsp/brush.hh>
#include <qbsp/qbsp.hh>
@ -18,8 +17,6 @@
#include <stdexcept>
#include <map>
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)