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

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

View file

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

View file

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

View file

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

View file

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