Skip to content

Commit

Permalink
Add CMake stuff for new tests after rebase.
Browse files Browse the repository at this point in the history
  • Loading branch information
Holt59 committed Jul 14, 2024
1 parent e63eb30 commit 1f90041
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 5 deletions.
2 changes: 1 addition & 1 deletion test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()

Expand Down
11 changes: 11 additions & 0 deletions test/gtest_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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})
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
File renamed without changes.
5 changes: 4 additions & 1 deletion test/test_utils/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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})
22 changes: 22 additions & 0 deletions test/usvfs_global_test_runner/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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_runner
usvfs_global_test_fixture.cpp
usvfs_global_test_fixture.h
usvfs_global_test_runner.cpp
)
usvfs_set_test_properties(usvfs_global_test_runner FOLDER usvfs_global_test)
usvfs_target_link_usvfs(usvfs_global_test_runner)
target_link_libraries(usvfs_global_test_runner
PRIVATE test_utils gtest_utils GTest::gtest_main)
add_dependencies(usvfs_global_test_runner usvfs_global_test)
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
#include <gtest/gtest.h>

#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#include <filesystem>
#include <fstream>

#include "../usvfs_global_test_runner/gtest_utils.h"
#include <gtest_utils.h>

// anonymous class that allow tests to access parameters (currently only where the
// virtualized data folder is)
Expand Down
2 changes: 1 addition & 1 deletion test/usvfs_global_test_runner/usvfs_global_test_runner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@

#include <test_helpers.h>
#include <usvfs.h>
#include <gtest_utils.h>

#include "gtest_utils.h"
#include "usvfs_global_test_fixture.h"

TEST_F(UsvfsGlobalTest, BasicTest)
Expand Down

0 comments on commit 1f90041

Please sign in to comment.