mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-04-28 12:58:00 +03:00
Use temporary directory for tests output
This commit is contained in:
parent
87a2f776b7
commit
7112217adc
6 changed files with 42 additions and 15 deletions
|
@ -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:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue