summaryrefslogtreecommitdiff
path: root/test/buildtool/file_system/file_system_manager.test.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2022-11-17 15:32:30 +0100
committerPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2022-12-21 14:59:04 +0100
commit380e88d8e6863fec8a0209053b529adfb31a9dc0 (patch)
treee9477883d9f67e696cddaf55f3d3bac00774f5bc /test/buildtool/file_system/file_system_manager.test.cpp
parent49c335ae9ccfdbf8c28cc9b97669ef149801f464 (diff)
downloadjustbuild-380e88d8e6863fec8a0209053b529adfb31a9dc0.tar.gz
FS Manager: Add CopyDirectoryImpl method
Diffstat (limited to 'test/buildtool/file_system/file_system_manager.test.cpp')
-rw-r--r--test/buildtool/file_system/file_system_manager.test.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/test/buildtool/file_system/file_system_manager.test.cpp b/test/buildtool/file_system/file_system_manager.test.cpp
index 1ffa858f..8958854d 100644
--- a/test/buildtool/file_system/file_system_manager.test.cpp
+++ b/test/buildtool/file_system/file_system_manager.test.cpp
@@ -590,6 +590,33 @@ TEST_CASE("CreateFileHardlink", "[file_system]") {
}
}
+TEST_CASE("CopyDirectoryImpl", "[file_system]") {
+ std::filesystem::path to{"./tmp-CreateDirCopy/tmp-dir"};
+ REQUIRE(FileSystemManager::CreateDirectory(to.parent_path()));
+
+ CHECK(FileSystemManager::CreateDirectory("a/b/c/d"));
+ CHECK(std::filesystem::exists("a/b/c/d"));
+ CHECK(std::filesystem::is_directory("a/b/c/d"));
+
+ CHECK(FileSystemManager::WriteFile("boo", "a/bb.txt"));
+
+ // Test copy
+ CHECK(FileSystemManager::CopyDirectoryImpl("a", to, true));
+
+ // Result should be in tmp-dir now
+ CHECK(std::filesystem::exists(to));
+ CHECK(std::filesystem::is_directory(to));
+
+ CHECK(std::filesystem::exists(to / "b"));
+ CHECK(std::filesystem::is_directory(to / "b"));
+
+ CHECK(std::filesystem::exists(to / "b/c"));
+ CHECK(std::filesystem::is_directory(to / "b/c"));
+
+ CHECK(std::filesystem::exists(to / "bb.txt"));
+ CHECK(std::filesystem::is_regular_file(to / "bb.txt"));
+}
+
TEST_CASE_METHOD(CopyFileFixture, "CreateFileHardlinkAs", "[file_system]") {
auto set_perm = [&](bool is_executable) {
auto const content = FileSystemManager::ReadFile(from_);