[libcxx-commits] [libcxx] 2ec9239 - [libcxx] [test] Fix weakly_canonical for windows

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Fri Mar 19 07:12:58 PDT 2021


Author: Martin Storsjö
Date: 2021-03-19T16:12:24+02:00
New Revision: 2ec9239a7b1faf880a130d6e5146883b48c85681

URL: https://github.com/llvm/llvm-project/commit/2ec9239a7b1faf880a130d6e5146883b48c85681
DIFF: https://github.com/llvm/llvm-project/commit/2ec9239a7b1faf880a130d6e5146883b48c85681.diff

LOG: [libcxx] [test] Fix weakly_canonical for windows

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

Added: 
    

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

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
index 08d963fe6652..983ad7bf0137 100644
--- a/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/fs.op.funcs/fs.op.weakly_canonical/weakly_canonical.pass.cpp
@@ -27,6 +27,7 @@ int main(int, char**) {
 
   static_test_env static_env;
 
+  fs::path root = fs::current_path().root_path();
   // clang-format off
   struct {
     fs::path input;
@@ -34,10 +35,10 @@ int main(int, char**) {
   } 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/"},
@@ -61,15 +62,17 @@ int main(int, char**) {
   bool Failed = false;
   for (auto& TC : TestCases) {
     ++ID;
-    fs::path p(TC.input);
+    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());
     }
   }


        


More information about the libcxx-commits mailing list