Use temporary directory for tests output

This commit is contained in:
elsid 2025-03-22 14:36:55 +01:00
parent 87a2f776b7
commit 7112217adc
No known key found for this signature in database
GPG key ID: B845CB9FEE18AB40
6 changed files with 42 additions and 15 deletions

View file

@ -1,6 +1,7 @@
#ifndef OPENMW_COMPONENTS_TESTING_UTIL_H
#define OPENMW_COMPONENTS_TESTING_UTIL_H
#include <chrono>
#include <filesystem>
#include <initializer_list>
#include <memory>
@ -14,26 +15,37 @@
namespace TestingOpenMW
{
inline std::filesystem::path outputFilePath(const std::string name)
inline std::filesystem::path outputDir()
{
std::filesystem::path dir("tests_output");
std::filesystem::create_directory(dir);
static const std::string run
= std::to_string(std::chrono::system_clock::to_time_t(std::chrono::system_clock::now()));
std::filesystem::path dir = std::filesystem::temp_directory_path() / "openmw" / "tests" / run;
std::filesystem::create_directories(dir);
return dir;
}
inline std::filesystem::path outputFilePath(std::string_view name)
{
std::filesystem::path dir = outputDir();
return dir / Misc::StringUtils::stringToU8String(name);
}
inline std::filesystem::path outputDirPath(const std::filesystem::path& subpath)
{
std::filesystem::path path = outputDir();
path /= subpath;
std::filesystem::create_directories(path);
return path;
}
inline std::filesystem::path outputFilePathWithSubDir(const std::filesystem::path& subpath)
{
std::filesystem::path path("tests_output");
std::filesystem::path path = outputDir();
path /= subpath;
std::filesystem::create_directories(path.parent_path());
return path;
}
inline std::filesystem::path temporaryFilePath(const std::string name)
{
return std::filesystem::temp_directory_path() / name;
}
class VFSTestFile : public VFS::File
{
public: