Clean up gaussian splat test runtime roots

This commit is contained in:
2026-04-27 19:38:27 +08:00
parent c0b670b052
commit 0a830ab17d
3 changed files with 52 additions and 9 deletions

View File

@@ -15,6 +15,7 @@
#include <fstream>
#include <memory>
#include <string>
#include <system_error>
#include <vector>
using namespace XCEngine::Math;
@@ -402,9 +403,28 @@ GaussianSplat BuildSampleGaussianSplat(const char* artifactPath) {
return gaussianSplat;
}
std::filesystem::path CreateTestProjectRoot(const char* folderName) {
return std::filesystem::current_path() / "__xc_gaussian_splat_cache_test_runtime" / folderName;
}
class ScopedTestProjectRoot final {
public:
explicit ScopedTestProjectRoot(const char* folderName)
: m_runtimeRoot(std::filesystem::temp_directory_path() / "xcengine_gaussian_splat_cache_test_runtime")
, m_projectRoot(m_runtimeRoot / folderName) {
std::error_code ec;
std::filesystem::remove_all(m_projectRoot, ec);
}
~ScopedTestProjectRoot() {
std::error_code ec;
std::filesystem::remove_all(m_runtimeRoot, ec);
}
const std::filesystem::path& GetPath() const {
return m_projectRoot;
}
private:
std::filesystem::path m_runtimeRoot;
std::filesystem::path m_projectRoot;
};
TEST(RenderResourceCacheTest, GetOrCreateGaussianSplatUploadsStructuredSectionsAndReusesEntry) {
GaussianSplat gaussianSplat = BuildSampleGaussianSplat("sample.xcgsplat");
@@ -507,7 +527,8 @@ TEST(RenderResourceCacheTest, GetOrCreateGaussianSplatSupportsArtifactRuntimeLoa
TEST(RenderResourceCacheTest, GetOrCreateGaussianSplatSupportsSourceAssetImportPath) {
namespace fs = std::filesystem;
const fs::path projectRoot = CreateTestProjectRoot("source_asset_import");
const ScopedTestProjectRoot testProjectRoot("source_asset_import");
const fs::path projectRoot = testProjectRoot.GetPath();
const fs::path assetsDir = projectRoot / "Assets";
const fs::path sourcePath = assetsDir / "sample.ply";