From 70465c534620c7ca192435aadbc1c17d12312467 Mon Sep 17 00:00:00 2001 From: Bret Curtis Date: Sat, 29 Apr 2023 21:26:51 +0200 Subject: [PATCH] make sure we can run on all systems; but require that it run in the same directory as the binary we wish to test --- apps/mwiniimporter_tests/CMakeLists.txt | 3 --- apps/mwiniimporter_tests/main.cpp | 12 ++++-------- 2 files changed, 4 insertions(+), 11 deletions(-) diff --git a/apps/mwiniimporter_tests/CMakeLists.txt b/apps/mwiniimporter_tests/CMakeLists.txt index eb6a191cd3..6692c6021d 100644 --- a/apps/mwiniimporter_tests/CMakeLists.txt +++ b/apps/mwiniimporter_tests/CMakeLists.txt @@ -9,9 +9,6 @@ openmw_add_executable(openmw-iniimporter-tests ${INIIMPORTER_TESTS_SRC_FILES}) target_include_directories(openmw-iniimporter-tests SYSTEM PRIVATE ${GTEST_INCLUDE_DIRS}) target_include_directories(openmw-iniimporter-tests SYSTEM PRIVATE ${GMOCK_INCLUDE_DIRS}) -#add_definitions(-DCMAKE_BINARY_DIR="${CMAKE_BINARY_DIR}") -target_compile_definitions(openmw-iniimporter-tests PRIVATE CMAKE_BINARY_DIR=u8"${CMAKE_BINARY_DIR}") - target_link_libraries(openmw-iniimporter-tests PRIVATE GTest::GTest GMock::GMock diff --git a/apps/mwiniimporter_tests/main.cpp b/apps/mwiniimporter_tests/main.cpp index f6cd2d2b37..bd68c27306 100644 --- a/apps/mwiniimporter_tests/main.cpp +++ b/apps/mwiniimporter_tests/main.cpp @@ -1,14 +1,9 @@ -#include #include #include #include #include #include -#ifndef CMAKE_BINARY_DIR -#define CMAKE_BINARY_DIR "." /* default to current directory */ -#endif - struct TestParam { std::string name; @@ -35,11 +30,12 @@ Archive 1=game2.bsa tempFile << iniData; tempFile.close(); std::filesystem::path tempCfgFile = std::filesystem::temp_directory_path() / (param.fileName + ".cfg"); + std::filesystem::path binaryPath = std::filesystem::current_path() / "openmw-iniimporter"; - std::basic_stringstream cmd; - cmd << CMAKE_BINARY_DIR << u8"/openmw-iniimporter -i " << tempIniFile << u8" -c " << tempCfgFile; + std::stringstream cmd; + cmd << binaryPath << " -i " << tempIniFile << " -c " << tempCfgFile; - int ret = std::system(Misc::StringUtils::u8StringToString(std::u8string(cmd.str())).c_str()); + int ret = std::system(cmd.str().c_str()); ASSERT_EQ(ret, 0); // Verify the cfg file was created and has the expected contents