[libcxx-commits] [PATCH] D98643: [libcxx] [test] Fix weakly_canonical for windows

Martin Storsjö via Phabricator via libcxx-commits libcxx-commits at lists.llvm.org
Mon Mar 15 10:51:46 PDT 2021


mstorsjo created this revision.
mstorsjo requested review of this revision.
Herald added a project: libc++.
Herald added a reviewer: libc++.

Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D98643

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


Index: libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
===================================================================
--- libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
+++ libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
@@ -27,6 +27,7 @@
 
   static_test_env static_env;
 
+  fs::path root = fs::current_path().root_path();
   // clang-format off
   struct {
     fs::path input;
@@ -34,10 +35,10 @@
   } TestCases[] = {
       {"", fs::current_path()},
       {".", fs::current_path()},
-      {"/", "/"},
-      {"/foo", "/foo"},
-      {"/.", "/"},
-      {"/./", "/"},
+      {"/", root},
+      {"/foo", root / "foo"},
+      {"/.", root},
+      {"/./", root},
       {"a/b", fs::current_path() / "a/b"},
       {"a", fs::current_path() / "a"},
       {"a/b/", fs::current_path() / "a/b/"},
@@ -69,14 +70,16 @@
   for (auto& TC : TestCases) {
     ++ID;
     fs::path p(TC.input);
+    fs::path expect(TC.expect);
+    expect.make_preferred();
     const fs::path output = fs::weakly_canonical(p);
-    if (!PathEq(output, TC.expect)) {
+    if (!PathEq(output, expect)) {
       Failed = true;
       std::fprintf(stderr, "TEST CASE #%d FAILED:\n"
                   "  Input: '%s'\n"
                   "  Expected: '%s'\n"
                   "  Output: '%s'\n",
-        ID, TC.input.string().c_str(), TC.expect.string().c_str(),
+        ID, TC.input.string().c_str(), expect.string().c_str(),
         output.string().c_str());
     }
   }


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D98643.330729.patch
Type: text/x-patch
Size: 1620 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libcxx-commits/attachments/20210315/7dfa81be/attachment.bin>


More information about the libcxx-commits mailing list