2
0
mirror of https://github.com/Laupetin/OpenAssetTools.git synced 2025-12-27 12:31:50 +00:00

chore: add system test to make sure reusing global assets is safe

This commit is contained in:
Jan Laupetin
2025-12-25 14:58:19 +01:00
parent 6711cf0afe
commit 2442d7160c
11 changed files with 725 additions and 2 deletions

View File

@@ -1,12 +1,23 @@
#include "Utils/Logging/Log.h"
#include <catch2/catch_session.hpp>
#include <cstdlib>
#include <filesystem>
#include <format>
#include <iostream>
namespace fs = std::filesystem;
namespace
{
bool ShouldClearTempFolder()
{
auto* envVar = std::getenv("OAT_KEEP_TMP_DIR");
return !envVar || !envVar[0] || (envVar[0] == '0' && !envVar[1]);
}
} // namespace
int main(const int argc, char* argv[])
{
con::init();
@@ -46,8 +57,16 @@ int main(const int argc, char* argv[])
const auto result = Catch::Session().run(argc, argv);
const auto tempDir = expectedBuildDir / ".tmp";
if (fs::is_directory(tempDir))
fs::remove_all(tempDir);
if (ShouldClearTempFolder())
{
con::info("Clearing tmp folder. Define env var OAT_KEEP_TMP_DIR=1 to keep it.");
if (fs::is_directory(tempDir))
fs::remove_all(tempDir);
}
else
{
con::info("Kept tmp dir {} on disk.", tempDir.string());
}
return result;
}