diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 4314802..3881d9c 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -58,7 +58,7 @@ foreach(directory ${directories}) add_subdirectory(${directory}) get_filename_component(dirname ${directory} NAME) - if(dirname STREQUAL "test_utils") + if((dirname STREQUAL "test_utils") OR (dirname STREQUAL "gtest_utils")) continue() endif() diff --git a/test/gtest_utils/CMakeLists.txt b/test/gtest_utils/CMakeLists.txt new file mode 100644 index 0000000..8dcda70 --- /dev/null +++ b/test/gtest_utils/CMakeLists.txt @@ -0,0 +1,11 @@ +cmake_minimum_required(VERSION 3.16) + +find_package(GTest CONFIG REQUIRED) + +add_library(gtest_utils STATIC + gtest_utils.cpp + gtest_utils.h +) +set_target_properties(gtest_utils PROPERTIES FOLDER tests) +target_link_libraries(gtest_utils PUBLIC GTest::gtest) +target_include_directories(gtest_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/test/usvfs_global_test_runner/gtest_utils.cpp b/test/gtest_utils/gtest_utils.cpp similarity index 98% rename from test/usvfs_global_test_runner/gtest_utils.cpp rename to test/gtest_utils/gtest_utils.cpp index 6b439d2..33be670 100644 --- a/test/usvfs_global_test_runner/gtest_utils.cpp +++ b/test/gtest_utils/gtest_utils.cpp @@ -105,7 +105,7 @@ ::testing::AssertionResult AssertContentEquals(std::string_view expected, const std::filesystem::path& path, bool trim) { - const auto content = read_content(path); + const auto content = read_content(path, trim); if (!content) { return ::testing::AssertionFailure() diff --git a/test/usvfs_global_test_runner/gtest_utils.h b/test/gtest_utils/gtest_utils.h similarity index 100% rename from test/usvfs_global_test_runner/gtest_utils.h rename to test/gtest_utils/gtest_utils.h diff --git a/test/test_utils/CMakeLists.txt b/test/test_utils/CMakeLists.txt index cdb86d9..88c75d6 100644 --- a/test/test_utils/CMakeLists.txt +++ b/test/test_utils/CMakeLists.txt @@ -2,7 +2,10 @@ cmake_minimum_required(VERSION 3.16) find_package(GTest CONFIG REQUIRED) -add_library(test_utils STATIC test_helpers.cpp test_helpers.h) +add_library(test_utils STATIC + test_helpers.cpp + test_helpers.h +) set_target_properties(test_utils PROPERTIES FOLDER tests) target_link_libraries(test_utils PUBLIC shared) target_include_directories(test_utils PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}) diff --git a/test/usvfs_global_test_runner/CMakeLists.txt b/test/usvfs_global_test_runner/CMakeLists.txt new file mode 100644 index 0000000..a964a16 --- /dev/null +++ b/test/usvfs_global_test_runner/CMakeLists.txt @@ -0,0 +1,22 @@ +cmake_minimum_required(VERSION 3.16) + +find_package(GTest CONFIG REQUIRED) + +# other executables +add_executable(usvfs_global_test + usvfs_global_test/usvfs_global_test.cpp +) +usvfs_set_test_properties(usvfs_global_test FOLDER usvfs_global_test) +target_link_libraries(usvfs_global_test PRIVATE gtest_utils GTest::gtest_main) + +# actual test executable +add_executable(usvfs_global_test_runer + usvfs_global_test_fixture.cpp + usvfs_global_test_fixture.h + usvfs_global_test_runner.cpp +) +usvfs_set_test_properties(usvfs_global_test_runer FOLDER usvfs_global_test) +usvfs_target_link_usvfs(usvfs_global_test_runer) +target_link_libraries(usvfs_global_test_runer + PRIVATE test_utils gtest_utils GTest::gtest_main) +add_dependencies(usvfs_global_test_runer usvfs_global_test) diff --git a/test/usvfs_global_test/usvfs_global_test.cpp b/test/usvfs_global_test_runner/usvfs_global_test/usvfs_global_test.cpp similarity index 98% rename from test/usvfs_global_test/usvfs_global_test.cpp rename to test/usvfs_global_test_runner/usvfs_global_test/usvfs_global_test.cpp index 6ab9436..7de2f60 100644 --- a/test/usvfs_global_test/usvfs_global_test.cpp +++ b/test/usvfs_global_test_runner/usvfs_global_test/usvfs_global_test.cpp @@ -1,9 +1,12 @@ #include +#define WIN32_LEAN_AND_MEAN +#include + #include #include -#include "../usvfs_global_test_runner/gtest_utils.h" +#include // anonymous class that allow tests to access parameters (currently only where the // virtualized data folder is) diff --git a/test/usvfs_global_test_runner/usvfs_global_test_runner.cpp b/test/usvfs_global_test_runner/usvfs_global_test_runner.cpp index 9be08cc..afe219e 100644 --- a/test/usvfs_global_test_runner/usvfs_global_test_runner.cpp +++ b/test/usvfs_global_test_runner/usvfs_global_test_runner.cpp @@ -2,8 +2,8 @@ #include #include +#include -#include "gtest_utils.h" #include "usvfs_global_test_fixture.h" TEST_F(UsvfsGlobalTest, BasicTest)