From 8b57548de9836fce3663b99d0140146f12668e8c Mon Sep 17 00:00:00 2001 From: Maksim Denisov Date: Thu, 17 Apr 2025 16:56:57 +0200 Subject: FileSystemManager: Always remove directories recursively --- .../execution_engine/executor/executor_api.test.hpp | 8 ++++---- .../graph_traverser/graph_traverser_remote.test.cpp | 2 +- test/utils/archive/archive_usage.test.cpp | 13 ++++--------- 3 files changed, 9 insertions(+), 14 deletions(-) (limited to 'test') diff --git a/test/buildtool/execution_engine/executor/executor_api.test.hpp b/test/buildtool/execution_engine/executor/executor_api.test.hpp index 2043da88..ff4c4999 100644 --- a/test/buildtool/execution_engine/executor/executor_api.test.hpp +++ b/test/buildtool/execution_engine/executor/executor_api.test.hpp @@ -479,7 +479,7 @@ static inline void TestUploadAndDownloadTrees( CHECK(FileSystemManager::IsNonUpwardsSymlink(tmpdir / "b")); CHECK(*FileSystemManager::ReadFile(tmpdir / "a") == "foo"); CHECK(*FileSystemManager::ReadSymlink(tmpdir / "b") == "bar"); - REQUIRE(FileSystemManager::RemoveDirectory(tmpdir, true)); + REQUIRE(FileSystemManager::RemoveDirectory(tmpdir)); } SECTION("Subdir in tree path") { @@ -496,7 +496,7 @@ static inline void TestUploadAndDownloadTrees( CHECK(FileSystemManager::IsNonUpwardsSymlink(tmpdir / "b" / "a")); CHECK(*FileSystemManager::ReadFile(tmpdir / "a") == "foo"); CHECK(*FileSystemManager::ReadSymlink(tmpdir / "b" / "a") == "bar"); - REQUIRE(FileSystemManager::RemoveDirectory(tmpdir, true)); + REQUIRE(FileSystemManager::RemoveDirectory(tmpdir)); } SECTION("Nested trees") { @@ -517,7 +517,7 @@ static inline void TestUploadAndDownloadTrees( CHECK(FileSystemManager::IsNonUpwardsSymlink(tmpdir / "b" / "a")); CHECK(*FileSystemManager::ReadFile(tmpdir / "a") == "foo"); CHECK(*FileSystemManager::ReadSymlink(tmpdir / "b" / "a") == "bar"); - REQUIRE(FileSystemManager::RemoveDirectory(tmpdir, true)); + REQUIRE(FileSystemManager::RemoveDirectory(tmpdir)); } SECTION("Dot-path tree as action input") { @@ -550,7 +550,7 @@ static inline void TestUploadAndDownloadTrees( CHECK(FileSystemManager::IsNonUpwardsSymlink(tmpdir / "b" / "a")); CHECK(*FileSystemManager::ReadFile(tmpdir / "a") == "foo"); CHECK(*FileSystemManager::ReadSymlink(tmpdir / "b" / "a") == "bar"); - REQUIRE(FileSystemManager::RemoveDirectory(tmpdir, true)); + REQUIRE(FileSystemManager::RemoveDirectory(tmpdir)); } SECTION("Dot-path non-tree as action input") { diff --git a/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp b/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp index f2b2d852..a611caab 100644 --- a/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp +++ b/test/buildtool/graph_traverser/graph_traverser_remote.test.cpp @@ -35,7 +35,7 @@ [[nodiscard]] static auto CreateStorageConfig( RemoteExecutionConfig const& remote_config) -> StorageConfig { auto cache_dir = FileSystemManager::GetCurrentDirectory() / "cache"; - if (not FileSystemManager::RemoveDirectory(cache_dir, true) or + if (not FileSystemManager::RemoveDirectory(cache_dir) or not FileSystemManager::CreateDirectoryExclusive(cache_dir)) { Logger::Log(LogLevel::Error, "failed to create a test-local cache dir {}", diff --git a/test/utils/archive/archive_usage.test.cpp b/test/utils/archive/archive_usage.test.cpp index 030cd223..ddf71353 100644 --- a/test/utils/archive/archive_usage.test.cpp +++ b/test/utils/archive/archive_usage.test.cpp @@ -339,8 +339,7 @@ TEST_CASE("Read-write archives", "[archive_read_write]") { auto const& scenario = kTestScenarios[test_index]; // perform the test - REQUIRE(FileSystemManager::RemoveDirectory(scenario.test_dir, - /*recursively=*/true)); + REQUIRE(FileSystemManager::RemoveDirectory(scenario.test_dir)); REQUIRE(FileSystemManager::CreateDirectory(scenario.test_dir)); auto anchor = FileSystemManager::ChangeDirectory(scenario.test_dir); @@ -395,8 +394,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") { std::optional res{std::nullopt}; SECTION(std::string("Write ") + scenario.test_name) { - REQUIRE(FileSystemManager::RemoveDirectory(scenario.test_dir, - /*recursively=*/true)); + REQUIRE(FileSystemManager::RemoveDirectory(scenario.test_dir)); REQUIRE(FileSystemManager::CreateDirectory(scenario.test_dir)); create_files(scenario.test_dir); @@ -408,8 +406,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") { } SECTION(std::string("Extract ") + scenario.test_name + " to disk") { - REQUIRE(FileSystemManager::RemoveDirectory(scenario.test_dir, - /*recursively=*/true)); + REQUIRE(FileSystemManager::RemoveDirectory(scenario.test_dir)); REQUIRE(FileSystemManager::CreateDirectory(scenario.test_dir)); res = ArchiveOps::ExtractArchive( scenario.type, scenario.filename, "."); @@ -430,9 +427,7 @@ TEST_CASE("ArchiveOps", "[archive_ops]") { path = std::string{env_path} + ":" + path; } SECTION("Extract via system tools") { - REQUIRE( - FileSystemManager::RemoveDirectory(scenario.test_dir, - /*recursively=*/true)); + REQUIRE(FileSystemManager::RemoveDirectory(scenario.test_dir)); REQUIRE(FileSystemManager::CreateDirectory(scenario.test_dir)); REQUIRE(system(("export PATH=" + path + " && " + scenario.cmd + " " + scenario.filename) -- cgit v1.2.3