From ceff6d4755899399fa258d8755d1f6f74eea7e64 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=ABl=20Lamotte=20=28Klaim=29?= Date: Wed, 1 Jun 2022 15:03:19 +0200 Subject: [PATCH] Fixed filesystem tests data cleanup otherwise some tests lead to false negatives --- libmamba/tests/test_filesystem.cpp | 6 ++++++ 1 file changed, 6 insertions(+) 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); }