[libcxx-commits] [libcxx] 59c72a7 - [libc++] [P1164] Add tests for create_directories. NFC.

Marek Kurdej via libcxx-commits libcxx-commits at lists.llvm.org
Mon Dec 14 08:27:28 PST 2020


Author: Marek Kurdej
Date: 2020-12-14T17:27:18+01:00
New Revision: 59c72a70121567f7aee347e96b4ac8f3cfe9f4b2

URL: https://github.com/llvm/llvm-project/commit/59c72a70121567f7aee347e96b4ac8f3cfe9f4b2
DIFF: https://github.com/llvm/llvm-project/commit/59c72a70121567f7aee347e96b4ac8f3cfe9f4b2.diff

LOG: [libc++] [P1164] Add tests for create_directories. NFC.

That's a follow-up patch after D92769.

Reviewed By: ldionne, #libc

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
index 3098f33342b0..9ce450a0e48d 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
@@ -8,6 +8,9 @@
 
 // UNSUPPORTED: c++03
 
+// This test requires the dylib support introduced in D92769.
+// XFAIL: with_system_cxx_lib=macosx10.15
+
 // <filesystem>
 
 // bool create_directories(const path& p);
@@ -75,12 +78,12 @@ TEST_CASE(create_directory_symlinks) {
     std::error_code ec = GetTestEC();
     TEST_CHECK(create_directories(target, ec) == false);
     TEST_CHECK(ec);
+    TEST_CHECK(ErrorIs(ec, std::errc::file_exists));
     TEST_CHECK(!exists(sym_dest_dead));
     TEST_CHECK(!exists(dead_sym));
   }
 }
 
-
 TEST_CASE(create_directory_through_symlinks) {
   scoped_test_env env;
   const path root = env.create_dir("dir");
@@ -97,4 +100,42 @@ TEST_CASE(create_directory_through_symlinks) {
   }
 }
 
+TEST_CASE(dest_is_file)
+{
+    scoped_test_env env;
+    const path file = env.create_file("file", 42);
+    std::error_code ec = GetTestEC();
+    TEST_CHECK(fs::create_directories(file, ec) == false);
+    TEST_CHECK(ec);
+    TEST_CHECK(ErrorIs(ec, std::errc::file_exists));
+    TEST_CHECK(is_regular_file(file));
+}
+
+TEST_CASE(dest_part_is_file)
+{
+    scoped_test_env env;
+    const path file = env.create_file("file");
+    const path dir = env.make_env_path("file/dir1");
+    std::error_code ec = GetTestEC();
+    TEST_CHECK(fs::create_directories(dir, ec) == false);
+    TEST_CHECK(ec);
+    TEST_CHECK(ErrorIs(ec, std::errc::not_a_directory));
+    TEST_CHECK(is_regular_file(file));
+    TEST_CHECK(!exists(dir));
+}
+
+TEST_CASE(dest_final_part_is_file)
+{
+    scoped_test_env env;
+    env.create_dir("dir");
+    const path file = env.create_file("dir/file");
+    const path dir = env.make_env_path("dir/file/dir1");
+    std::error_code ec = GetTestEC();
+    TEST_CHECK(fs::create_directories(dir, ec) == false);
+    TEST_CHECK(ec);
+    TEST_CHECK(ErrorIs(ec, std::errc::not_a_directory));
+    TEST_CHECK(is_regular_file(file));
+    TEST_CHECK(!exists(dir));
+}
+
 TEST_SUITE_END()


        


More information about the libcxx-commits mailing list