mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-03-10 07:13:53 +00:00
Merge branch 'std-filesystem-hotfix' into 'master'
Use std::filesystem for unit tests temporary files path. See merge request OpenMW/openmw!2402
This commit is contained in:
commit
9a9c7fa7cf
@ -109,8 +109,8 @@ file(DOWNLOAD
|
|||||||
)
|
)
|
||||||
|
|
||||||
target_compile_definitions(openmw_test_suite
|
target_compile_definitions(openmw_test_suite
|
||||||
PRIVATE OPENMW_DATA_DIR="${CMAKE_CURRENT_BINARY_DIR}/data"
|
PRIVATE OPENMW_DATA_DIR=u8"${CMAKE_CURRENT_BINARY_DIR}/data"
|
||||||
OPENMW_TEST_SUITE_SOURCE_DIR="${CMAKE_CURRENT_SOURCE_DIR}")
|
OPENMW_TEST_SUITE_SOURCE_DIR=u8"${CMAKE_CURRENT_SOURCE_DIR}")
|
||||||
|
|
||||||
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
|
if (CMAKE_VERSION VERSION_GREATER_EQUAL 3.16 AND MSVC)
|
||||||
target_precompile_headers(openmw_test_suite PRIVATE
|
target_precompile_headers(openmw_test_suite PRIVATE
|
||||||
|
@ -39,7 +39,7 @@ namespace
|
|||||||
{
|
{
|
||||||
static constexpr std::size_t sInitialOffset = 324;
|
static constexpr std::size_t sInitialOffset = 324;
|
||||||
static constexpr std::size_t sSkip = 100;
|
static constexpr std::size_t sSkip = 100;
|
||||||
const Files::PathContainer mDataDirs {{std::string(OPENMW_DATA_DIR)}};
|
const Files::PathContainer mDataDirs {{std::filesystem::path{OPENMW_DATA_DIR}}};
|
||||||
const Files::Collections mFileCollections {mDataDirs, true};
|
const Files::Collections mFileCollections {mDataDirs, true};
|
||||||
const std::string mContentFile = "template.omwgame";
|
const std::string mContentFile = "template.omwgame";
|
||||||
const std::filesystem::path mContentFilePath = mFileCollections.getCollection(".omwgame").getPath(mContentFile);
|
const std::filesystem::path mContentFilePath = mFileCollections.getCollection(".omwgame").getPath(mContentFile);
|
||||||
|
@ -25,7 +25,7 @@ namespace
|
|||||||
|
|
||||||
struct EsmLoaderTest : Test
|
struct EsmLoaderTest : Test
|
||||||
{
|
{
|
||||||
const Files::PathContainer mDataDirs {{std::string(OPENMW_DATA_DIR)}};
|
const Files::PathContainer mDataDirs {{std::filesystem::path{OPENMW_DATA_DIR}}};
|
||||||
const Files::Collections mFileCollections {mDataDirs, true};
|
const Files::Collections mFileCollections {mDataDirs, true};
|
||||||
const std::vector<std::string> mContentFiles {{"template.omwgame"}};
|
const std::vector<std::string> mContentFiles {{"template.omwgame"}};
|
||||||
};
|
};
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
#include <components/to_utf8/to_utf8.hpp>
|
#include <components/to_utf8/to_utf8.hpp>
|
||||||
|
#include <components/misc/strings/conversion.hpp>
|
||||||
|
|
||||||
#include <gtest/gtest.h>
|
#include <gtest/gtest.h>
|
||||||
|
|
||||||
#include <fstream>
|
#include <fstream>
|
||||||
|
#include <filesystem>
|
||||||
|
|
||||||
#ifndef OPENMW_TEST_SUITE_SOURCE_DIR
|
#ifndef OPENMW_TEST_SUITE_SOURCE_DIR
|
||||||
#define OPENMW_TEST_SUITE_SOURCE_DIR ""
|
#define OPENMW_TEST_SUITE_SOURCE_DIR ""
|
||||||
@ -24,7 +26,7 @@ namespace
|
|||||||
{
|
{
|
||||||
std::ifstream file;
|
std::ifstream file;
|
||||||
file.exceptions(std::ios::failbit | std::ios::badbit);
|
file.exceptions(std::ios::failbit | std::ios::badbit);
|
||||||
file.open(std::string(OPENMW_TEST_SUITE_SOURCE_DIR) + "/toutf8/data/" + fileName);
|
file.open(std::filesystem::path{ OPENMW_TEST_SUITE_SOURCE_DIR } / "toutf8" / "data" / Misc::StringUtils::stringToU8String(fileName));
|
||||||
std::stringstream buffer;
|
std::stringstream buffer;
|
||||||
buffer << file.rdbuf();
|
buffer << file.rdbuf();
|
||||||
return buffer.str();
|
return buffer.str();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user