Skip to content

Commit

Permalink
Bug Fix: Tests
Browse files Browse the repository at this point in the history
The `test_asset` directory changed location; update the tests.

Also enable the tests at the parent level so it will always be
available.
  • Loading branch information
BenjamenMeyer committed Oct 13, 2024
1 parent 47d2e9d commit 0b2cf6a
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 15 deletions.
12 changes: 12 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,18 @@ SET(CMAKE_C_STANDARD 11)
SET(CMAKE_C_STANDARD_REQUIRED TRUE)
SET(CMAKE_C_EXTENSIONS ON)

# Should we install gtest?
OPTION(INSTALL_GTEST "Should we download and install GTest?" ON)

# Should we run gtest?
OPTION(USE_GTEST "Should we build and run the unit tests using GTest?" ON)

IF (USE_GTEST)
ENABLE_TESTING()

SET(TEST_NAME ${PROJECT_NAME}_tests)
ENDIF (USE_GTEST)

SET(VS_SUBDIRECTORIES "engine")
FOREACH(VS_SUBDIR IN LISTS VS_SUBDIRECTORIES)
ADD_SUBDIRECTORY(${VS_SUBDIR})
Expand Down
12 changes: 1 addition & 11 deletions engine/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -106,12 +106,6 @@ ELSE ()
ENDIF ()
MESSAGE("** OpenGL_GL_PREFERENCE: ${OpenGL_GL_PREFERENCE}")

# Should we install gtest?
OPTION(INSTALL_GTEST "Should we download and install GTest?" ON)

# Should we run gtest?
OPTION(USE_GTEST "Should we build and run the unit tests using GTest?" ON)

SET(DATADIR "" CACHE STRING "Default vegastrike data directory")

# Hide our temporary variable and initialize it to empty
Expand Down Expand Up @@ -1540,10 +1534,6 @@ IF (INSTALL_GTEST)
ENDIF (INSTALL_GTEST)

IF (USE_GTEST)
ENABLE_TESTING()

SET(TEST_NAME ${PROJECT_NAME}_tests)

ADD_EXECUTABLE(
${TEST_NAME}
src/cmd/tests/csv_tests.cpp
Expand All @@ -1562,7 +1552,7 @@ IF (USE_GTEST)
src/components/tests/balancing_tests.cpp
)
TARGET_INCLUDE_DIRECTORIES(${TEST_NAME} PUBLIC ${VS_INCLUDE_DIRS})
SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR})
SET_TARGET_PROPERTIES(${TEST_NAME} PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${Vega_Strike_BINARY_DIR}/)

ADD_LIBRARY(vegastrike-testing
${LIBCONFIG}
Expand Down
2 changes: 1 addition & 1 deletion engine/src/configuration/tests/configuration_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ TEST(LoadConfig, Sanity) {
EXPECT_EQ(default_escaped_string, "#00FF00Hi\r\nthere!#000000");

// Read the configuration from the config file
const std::string filename = "test_assets/vegastrike.config";
const std::string filename = "../test_assets/vegastrike.config";
vega_config::GetGameConfig().LoadGameConfig(filename);

// Test again
Expand Down
6 changes: 3 additions & 3 deletions engine/src/resource/tests/python_tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,10 @@ TEST(Python, Call_Function) {
boost::filesystem::path full_path(boost::filesystem::current_path());
std::cout << full_path << std::endl;

bool exists = boost::filesystem::exists("test_assets/python_tests.py");
bool exists = boost::filesystem::exists("../test_assets/python_tests.py");
std::cout << "python_tests.py exists " << exists << std::endl;

boost::filesystem::current_path(full_path.concat("/test_assets"));
boost::filesystem::current_path(full_path.concat("/../test_assets"));
full_path = boost::filesystem::current_path();
std::cout << full_path << std::endl;

Expand Down Expand Up @@ -140,4 +140,4 @@ TEST(Python, Call_Function) {

// Uncomment to see prints
//EXPECT_FALSE(true);
}
}

0 comments on commit 0b2cf6a

Please sign in to comment.