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
|
@ -30,7 +30,7 @@ namespace
|
|||
|
||||
TEST(FilesGetHash, shouldClearErrors)
|
||||
{
|
||||
const auto fileName = temporaryFilePath("fileName");
|
||||
const auto fileName = outputFilePath("fileName");
|
||||
std::string content;
|
||||
std::fill_n(std::back_inserter(content), 1, 'a');
|
||||
std::istringstream stream(content);
|
||||
|
@ -41,7 +41,7 @@ namespace
|
|||
|
||||
TEST_P(FilesGetHash, shouldReturnHashForStringStream)
|
||||
{
|
||||
const auto fileName = temporaryFilePath("fileName");
|
||||
const auto fileName = outputFilePath("fileName");
|
||||
std::string content;
|
||||
std::fill_n(std::back_inserter(content), GetParam().mSize, 'a');
|
||||
std::istringstream stream(content);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <components/misc/strings/conversion.hpp>
|
||||
#include <components/settings/parser.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
@ -24,5 +25,9 @@ int main(int argc, char** argv)
|
|||
Settings::StaticValues::init();
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
const int result = RUN_ALL_TESTS();
|
||||
if (result == 0)
|
||||
std::filesystem::remove_all(TestingOpenMW::outputDir());
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ namespace
|
|||
ShaderManager mManager;
|
||||
ShaderManager::DefineMap mDefines;
|
||||
|
||||
ShaderManagerTest() { mManager.setShaderPath("tests_output"); }
|
||||
ShaderManagerTest() { mManager.setShaderPath(TestingOpenMW::outputDir()); }
|
||||
|
||||
template <class F>
|
||||
void withShaderFile(const std::string& content, F&& f)
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include <components/debug/debugging.hpp>
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
@ -7,5 +8,9 @@ int main(int argc, char* argv[])
|
|||
Log::sMinDebugLevel = Debug::getDebugLevel();
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
const int result = RUN_ALL_TESTS();
|
||||
if (result == 0)
|
||||
std::filesystem::remove_all(TestingOpenMW::outputDir());
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#include <components/misc/strings/conversion.hpp>
|
||||
#include <components/settings/parser.hpp>
|
||||
#include <components/settings/values.hpp>
|
||||
#include <components/testing/util.hpp>
|
||||
|
||||
#include <gtest/gtest.h>
|
||||
|
||||
|
@ -24,5 +25,9 @@ int main(int argc, char* argv[])
|
|||
Settings::StaticValues::init();
|
||||
|
||||
testing::InitGoogleTest(&argc, argv);
|
||||
return RUN_ALL_TESTS();
|
||||
|
||||
const int result = RUN_ALL_TESTS();
|
||||
if (result == 0)
|
||||
std::filesystem::remove_all(TestingOpenMW::outputDir());
|
||||
return result;
|
||||
}
|
||||
|
|
|
@ -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