[libcxx-commits] [libcxx] d601edf - [libcxx] [test] Fix lexically_normal and lexically_relative_and_proximate for windows

Martin Storsjö via libcxx-commits libcxx-commits at lists.llvm.org
Sat Mar 6 12:48:36 PST 2021


Author: Martin Storsjö
Date: 2021-03-06T22:42:38+02:00
New Revision: d601edf0b053b0df3bea0df16187009b2a0c946b

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

LOG: [libcxx] [test] Fix lexically_normal and lexically_relative_and_proximate for windows

Convert the expected result path to preferred separators, add exceptions
to the test results where needed (due to some cases being interpreted
as a root name).

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

Added: 
    

Modified: 
    libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
    libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp

Removed: 
    


################################################################################
diff  --git a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
index ce784dd8a98d..e2cdb365dd88 100644
--- a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_normal.pass.cpp
@@ -54,10 +54,17 @@ int main(int, char**) {
       {"/a/b/./", "/a/b/"},
       {"/a/b/c/../d", "/a/b/d"},
       {"/a/b/c/../d/", "/a/b/d/"},
+#ifdef _WIN32
+      {"//a/", "//a/"},
+      {"//a/b/", "//a/b/"},
+      {"//a/b/.", "//a/b/"},
+      {"//a/..", "//a/"},
+#else
       {"//a/", "/a/"},
       {"//a/b/", "/a/b/"},
       {"//a/b/.", "/a/b/"},
       {"//a/..", "/"},
+#endif
       ///===---------------------------------------------------------------===//
       /// Tests specifically for the clauses under [fs.path.generic]p6
       ///===---------------------------------------------------------------===//
@@ -125,13 +132,15 @@ int main(int, char**) {
     ++ID;
     fs::path p(TC.input);
     const fs::path output = p.lexically_normal();
-    if (!PathEq(output, TC.expect)) {
+    fs::path expect(TC.expect);
+    expect.make_preferred();
+    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.c_str(), TC.expect.c_str(), output.string().c_str());
+        ID, TC.input.c_str(), expect.string().c_str(), output.string().c_str());
     }
   }
   return Failed;

diff  --git a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp
index 4f9e9b83d4f6..576055763ea0 100644
--- a/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp
+++ b/libcxx/test/std/input.output/filesystems/class.path/path.member/path.gen/lexically_relative_and_proximate.pass.cpp
@@ -36,8 +36,13 @@ int main(int, char**) {
       {"a", "/", ""},
       {"//net", "a", ""},
       {"a", "//net", ""},
+#ifdef _WIN32
+      {"//net/", "//net", ""},
+      {"//net", "//net/", ""},
+#else
       {"//net/", "//net", "."},
       {"//net", "//net/", "."},
+#endif
       {"//base", "a", ""},
       {"a", "a", "."},
       {"a/b", "a/b", "."},
@@ -59,6 +64,8 @@ int main(int, char**) {
     ++ID;
     const fs::path p(TC.input);
     const fs::path output = p.lexically_relative(TC.base);
+    fs::path expect(TC.expect);
+    expect.make_preferred();
     auto ReportErr = [&](const char* Testing, fs::path const& Output,
                                               fs::path const& Expected) {
       Failed = true;
@@ -71,8 +78,8 @@ int main(int, char**) {
         ID, Testing, TC.input.c_str(), TC.base.c_str(),
         Expected.string().c_str(), Output.string().c_str());
     };
-    if (!PathEq(output, TC.expect))
-      ReportErr("path::lexically_relative", output, TC.expect);
+    if (!PathEq(output, expect))
+      ReportErr("path::lexically_relative", output, expect);
     const fs::path proximate_output = p.lexically_proximate(TC.base);
     // [path.gen] lexically_proximate
     // Returns: If the value of lexically_relative(base) is not an empty path,


        


More information about the libcxx-commits mailing list