diff --git a/libmamba/tests/test_filesystem.cpp b/libmamba/tests/test_filesystem.cpp index e5e2d298cb..72616a7175 100644 --- a/libmamba/tests/test_filesystem.cpp +++ b/libmamba/tests/test_filesystem.cpp @@ -4,6 +4,7 @@ #include "mamba/core/mamba_fs.hpp" #include "mamba/core/util.hpp" +#include "mamba/core/util_scope.hpp" namespace mamba { @@ -60,9 +61,13 @@ namespace mamba TEST(u8path, directory_iteration) { const auto tmp_dir = fs::temp_directory_path() / "mamba_fs_iteration"; + mamba::on_scope_exit _([&] { fs::remove_all(tmp_dir); }); // Cleanup if not debugging. const auto file_dir = tmp_dir / "kikoo" / "lol" / u8"日本語"; const auto file_path = file_dir / u8"joël"; + + fs::remove_all(tmp_dir); // Make sure it's not existing from the start. fs::create_directories(file_dir); + { std::ofstream file(file_path.std_path(), std::ios::binary | std::ios::trunc); file << u8"日本語"; @@ -119,6 +124,7 @@ namespace mamba for (int i = 0; i < 42; ++i) long_path /= u8"some_very_long_prefix"; + mamba::on_scope_exit _([&] { fs::remove_all(long_path); }); fs::create_directories(long_path); }