diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index f212e5f5..4d52293a 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -3,5 +3,66 @@ set(CMAKE_CXX_FLAGS "${COLOBOT_CXX_FLAGS} ${COLOBOT_GTEST_CXX_FLAGS}") set(CMAKE_CXX_FLAGS_RELEASE ${COLOBOT_CXX_FLAGS_RELEASE}) set(CMAKE_CXX_FLAGS_DEBUG ${COLOBOT_CXX_FLAGS_DEBUG}) -# Unit tests -add_subdirectory(unit) +# Unit test data +set(TEST_FILES + data/colobot.json +) + +file(COPY ${TEST_FILES} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) + +# Targets +add_definitions(-DGTEST_HAS_TR1_TUPLE=0) + +add_executable(Colobot-UnitTests + src/main.cpp + + src/app/app_test.cpp + + src/CBot/CBot_test.cpp + src/CBot/CBotFileUtils_test.cpp + src/CBot/CBotToken_test.cpp + + src/common/config_file_test.cpp + src/common/stringutils_test.cpp + src/common/timeutils_test.cpp + + #src/graphics/engine/lightman_test.cpp + + src/math/func_test.cpp + src/math/geometry_test.cpp + src/math/matrix_test.cpp + src/math/vector_test.cpp +) + +target_include_directories(Colobot-UnitTests PRIVATE + src/common + src/math + ${CMAKE_CURRENT_SOURCE_DIR} + ${CMAKE_CURRENT_BINARY_DIR} + ${COLOBOT_LOCAL_INCLUDES} +) + +if(MSVC) + target_compile_options(Colobot-UnitTests PRIVATE /utf-8) +endif() + +target_link_libraries(Colobot-UnitTests PRIVATE + GTest::GTest + hippomocks + Colobot-Base +) + +gtest_discover_tests(Colobot-UnitTests + WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} + DISCOVERY_MODE PRE_TEST +) + +# GoogleTest isn't compatible with -Wsuggest-override -Werror: +# see https://github.com/google/googletest/issues/1063 +if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) + target_compile_options(Colobot-UnitTests PRIVATE "-Wno-suggest-override") +endif() + +if(COLOBOT_LINT_BUILD) + add_fake_header_sources("test/unit" Colobot-UnitTests) +endif() diff --git a/test/unit/common/colobot.json b/test/data/colobot.json similarity index 100% rename from test/unit/common/colobot.json rename to test/data/colobot.json diff --git a/test/unit/CBot/CBotFileUtils_test.cpp b/test/src/CBot/CBotFileUtils_test.cpp similarity index 100% rename from test/unit/CBot/CBotFileUtils_test.cpp rename to test/src/CBot/CBotFileUtils_test.cpp diff --git a/test/unit/CBot/CBotToken_test.cpp b/test/src/CBot/CBotToken_test.cpp similarity index 100% rename from test/unit/CBot/CBotToken_test.cpp rename to test/src/CBot/CBotToken_test.cpp diff --git a/test/unit/CBot/CBot_test.cpp b/test/src/CBot/CBot_test.cpp similarity index 100% rename from test/unit/CBot/CBot_test.cpp rename to test/src/CBot/CBot_test.cpp diff --git a/test/unit/app/app_test.cpp b/test/src/app/app_test.cpp similarity index 100% rename from test/unit/app/app_test.cpp rename to test/src/app/app_test.cpp diff --git a/test/unit/common/config_file_test.cpp b/test/src/common/config_file_test.cpp similarity index 100% rename from test/unit/common/config_file_test.cpp rename to test/src/common/config_file_test.cpp diff --git a/test/unit/common/stringutils_test.cpp b/test/src/common/stringutils_test.cpp similarity index 100% rename from test/unit/common/stringutils_test.cpp rename to test/src/common/stringutils_test.cpp diff --git a/test/unit/common/timeutils_test.cpp b/test/src/common/timeutils_test.cpp similarity index 100% rename from test/unit/common/timeutils_test.cpp rename to test/src/common/timeutils_test.cpp diff --git a/test/unit/graphics/engine/lightman_test.cpp b/test/src/graphics/engine/lightman_test.cpp similarity index 100% rename from test/unit/graphics/engine/lightman_test.cpp rename to test/src/graphics/engine/lightman_test.cpp diff --git a/test/unit/main.cpp b/test/src/main.cpp similarity index 100% rename from test/unit/main.cpp rename to test/src/main.cpp diff --git a/test/unit/math/func_test.cpp b/test/src/math/func_test.cpp similarity index 100% rename from test/unit/math/func_test.cpp rename to test/src/math/func_test.cpp diff --git a/test/unit/math/gendata.m b/test/src/math/gendata.m similarity index 100% rename from test/unit/math/gendata.m rename to test/src/math/gendata.m diff --git a/test/unit/math/geometry_test.cpp b/test/src/math/geometry_test.cpp similarity index 100% rename from test/unit/math/geometry_test.cpp rename to test/src/math/geometry_test.cpp diff --git a/test/unit/math/matrix_test.cpp b/test/src/math/matrix_test.cpp similarity index 100% rename from test/unit/math/matrix_test.cpp rename to test/src/math/matrix_test.cpp diff --git a/test/unit/math/vector_test.cpp b/test/src/math/vector_test.cpp similarity index 100% rename from test/unit/math/vector_test.cpp rename to test/src/math/vector_test.cpp diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt deleted file mode 100644 index 80f32ab2..00000000 --- a/test/unit/CMakeLists.txt +++ /dev/null @@ -1,53 +0,0 @@ -set(TEST_FILES - common/colobot.json -) - -file(COPY ${TEST_FILES} DESTINATION ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) - -# Targets - -add_definitions(-DGTEST_HAS_TR1_TUPLE=0) - -add_executable(Colobot-UnitTests - main.cpp - app/app_test.cpp - CBot/CBot_test.cpp - CBot/CBotFileUtils_test.cpp - CBot/CBotToken_test.cpp - common/config_file_test.cpp - common/stringutils_test.cpp - common/timeutils_test.cpp - #graphics/engine/lightman_test.cpp - math/func_test.cpp - math/geometry_test.cpp - math/matrix_test.cpp - math/vector_test.cpp) - -target_include_directories(Colobot-UnitTests PRIVATE - common - math - ${CMAKE_CURRENT_SOURCE_DIR} - ${CMAKE_CURRENT_BINARY_DIR} - ${COLOBOT_LOCAL_INCLUDES} -) - -if(MSVC) - target_compile_options(Colobot-UnitTests PRIVATE /utf-8) -endif() - -target_link_libraries(Colobot-UnitTests PRIVATE GTest::GTest hippomocks Colobot-Base) - -gtest_discover_tests(Colobot-UnitTests - WORKING_DIRECTORY ${CMAKE_RUNTIME_OUTPUT_DIRECTORY} - DISCOVERY_MODE PRE_TEST -) - -# GoogleTest isn't compatible with -Wsuggest-override -Werror: -# see https://github.com/google/googletest/issues/1063 -if(CMAKE_CXX_COMPILER_ID MATCHES "GNU" AND NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0) - target_compile_options(Colobot-UnitTests PRIVATE "-Wno-suggest-override") -endif() - -if(COLOBOT_LINT_BUILD) - add_fake_header_sources("test/unit" Colobot-UnitTests) -endif()