[libcxx-commits] [PATCH] D93026: [libc++] [P1164] Add tests for create_directories. NFC.

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


This revision was automatically updated to reflect the committed changes.
curdeius marked an inline comment as done.
Closed by commit rG59c72a701215: [libc++] [P1164] Add tests for create_directories. NFC. (authored by curdeius).

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D93026/new/

https://reviews.llvm.org/D93026

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


Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.create_directories/create_directories.pass.cpp
+++ 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 @@
     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(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()


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D93026.311602.patch
Type: text/x-patch
Size: 2255 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201214/51f3456f/attachment-0001.bin>


More information about the libcxx-commits mailing list