make sure we can run on all systems; but require that it run in the same directory as the binary we wish to test

cxxopts_mwiniimporter
Bret Curtis 1 year ago
parent 8505768736
commit 70465c5346

@ -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

@ -1,14 +1,9 @@
#include <components/misc/strings/conversion.hpp>
#include <filesystem>
#include <fstream>
#include <gtest/gtest.h>
#include <sstream>
#include <vector>
#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<char8_t> 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

Loading…
Cancel
Save