[libcxx-commits] [libcxx] 1e5f68d - [libcxx] [test] Add more tests for renaming directories in fs.op.rename

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Fri Apr 9 11:25:04 PDT 2021


Author: Martin Storsjö
Date: 2021-04-09T21:24:34+03:00
New Revision: 1e5f68d80a42ad0e377f6a3197034995bd7a2e16

URL: https://github.com/llvm/llvm-project/commit/1e5f68d80a42ad0e377f6a3197034995bd7a2e16
DIFF: https://github.com/llvm/llvm-project/commit/1e5f68d80a42ad0e377f6a3197034995bd7a2e16.diff

LOG: [libcxx] [test] Add more tests for renaming directories in fs.op.rename

This was requested during the review of D98640.

Differential Revision: https://reviews.llvm.org/D99982

Added: 
    

Modified: 
    libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp
index b6930d8d5fa9..c651bf178582 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.rename/rename.pass.cpp
@@ -127,4 +127,31 @@ TEST_CASE(basic_rename_test)
     }
 }
 
+TEST_CASE(basic_rename_dir_test)
+{
+    static_test_env env;
+    const std::error_code set_ec = std::make_error_code(std::errc::address_in_use);
+    const path new_dir = env.makePath("new_dir");
+    { // dir -> dir (with contents)
+        std::error_code ec = set_ec;
+        rename(env.Dir, new_dir, ec);
+        TEST_CHECK(!ec);
+        TEST_CHECK(!exists(env.Dir));
+        TEST_CHECK(is_directory(new_dir));
+        TEST_CHECK(exists(new_dir / "file1"));
+    }
+#ifdef _WIN32
+    // On Windows, renaming a directory over a file isn't an error (this
+    // case is skipped in test_error_reporting above).
+    { // dir -> file
+        std::error_code ec = set_ec;
+        rename(new_dir, env.NonEmptyFile, ec);
+        TEST_CHECK(!ec);
+        TEST_CHECK(!exists(new_dir));
+        TEST_CHECK(is_directory(env.NonEmptyFile));
+        TEST_CHECK(exists(env.NonEmptyFile / "file1"));
+    }
+#endif
+}
+
 TEST_SUITE_END()


        


More information about the libcxx-commits mailing list