[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 02:44:10 PST 2020


curdeius updated this revision to Diff 311533.
curdeius added a comment.

- Check exact error codes.


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
@@ -75,12 +75,12 @@
     std::error_code ec = GetTestEC();
     TEST_CHECK(create_directories(target, ec) == false);
     TEST_CHECK(ec);
+    TEST_CHECK(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 +97,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(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(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(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.311533.patch
Type: text/x-patch
Size: 2012 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20201214/8914179a/attachment.bin>


More information about the libcxx-commits mailing list