From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 56260 invoked by alias); 20 Dec 2018 18:12:26 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 52068 invoked by uid 89); 20 Dec 2018 18:12:24 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_HELO_PASS,TIME_LIMIT_EXCEEDED autolearn=unavailable version=3.3.2 spammy=string_view X-HELO: mx1.redhat.com Received: from mx1.redhat.com (HELO mx1.redhat.com) (209.132.183.28) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Thu, 20 Dec 2018 18:12:14 +0000 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id BC46F8AE77; Thu, 20 Dec 2018 18:12:13 +0000 (UTC) Received: from localhost (unknown [10.33.36.24]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DF5F18223; Thu, 20 Dec 2018 18:12:13 +0000 (UTC) Date: Thu, 20 Dec 2018 19:28:00 -0000 From: Jonathan Wakely To: libstdc++@gcc.gnu.org, gcc-patches@gcc.gnu.org Subject: [PATCH] Fix filesystem::path tests that fail on Windows Message-ID: <20181220181212.GA12647@redhat.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="LZvS9be/3tNcYl/X" Content-Disposition: inline X-Clacks-Overhead: GNU Terry Pratchett User-Agent: Mutt/1.10.1 (2018-07-13) X-SW-Source: 2018-12/txt/msg01487.txt.bz2 --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii; format=flowed Content-Disposition: inline Content-length: 262 * testsuite/27_io/filesystem/operations/proximate.cc: Fix test for MinGW. * testsuite/27_io/filesystem/path/append/source.cc: Likewise. * testsuite/27_io/filesystem/path/compare/lwg2936.cc: Likewise. Tested x86_64-linux and mingw-w64, committed to trunk. --LZvS9be/3tNcYl/X Content-Type: text/plain; charset=us-ascii Content-Disposition: attachment; filename="patch.txt" Content-length: 5051 commit 2ca9c650bb91616a8c24ece0df1fdd812d785a21 Author: Jonathan Wakely Date: Thu Dec 20 17:57:31 2018 +0000 Fix filesystem::path tests that fail on Windows * testsuite/27_io/filesystem/operations/proximate.cc: Fix test for MinGW. * testsuite/27_io/filesystem/path/append/source.cc: Likewise. * testsuite/27_io/filesystem/path/compare/lwg2936.cc: Likewise. diff --git a/libstdc++-v3/testsuite/27_io/filesystem/operations/proximate.cc b/libstdc++-v3/testsuite/27_io/filesystem/operations/proximate.cc index 457cd2d0641..980161c9ead 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/operations/proximate.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/operations/proximate.cc @@ -26,15 +26,27 @@ using std::filesystem::proximate; using __gnu_test::compare_paths; +// Normalize directory-separators +std::string operator""_norm(const char* s, std::size_t n) +{ + std::string str(s, n); +#if defined(__MING32__) || defined(__MINGW64__) + for (auto& c : str) + if (c == '/') + c = '\\'; +#endif + return str; +} + void test01() { - compare_paths( proximate("/a/d", "/a/b/c"), "../../d" ); - compare_paths( proximate("/a/b/c", "/a/d"), "../b/c" ); - compare_paths( proximate("a/b/c", "a"), "b/c" ); - compare_paths( proximate("a/b/c", "a/b/c/x/y"), "../.." ); + compare_paths( proximate("/a/d", "/a/b/c"), "../../d"_norm ); + compare_paths( proximate("/a/b/c", "/a/d"), "../b/c"_norm ); + compare_paths( proximate("a/b/c", "a"), "b/c"_norm ); + compare_paths( proximate("a/b/c", "a/b/c/x/y"), "../.."_norm ); compare_paths( proximate("a/b/c", "a/b/c"), "." ); - compare_paths( proximate("a/b", "c/d"), "../../a/b" ); + compare_paths( proximate("a/b", "c/d"), "../../a/b"_norm ); } void @@ -42,22 +54,22 @@ test02() { const std::error_code bad_ec = make_error_code(std::errc::invalid_argument); std::error_code ec = bad_ec; - compare_paths( proximate("/a/d", "/a/b/c", ec), "../../d" ); + compare_paths( proximate("/a/d", "/a/b/c", ec), "../../d"_norm ); VERIFY( !ec ); ec = bad_ec; - compare_paths( proximate("/a/b/c", "/a/d", ec), "../b/c" ); + compare_paths( proximate("/a/b/c", "/a/d", ec), "../b/c"_norm ); VERIFY( !ec ); ec = bad_ec; - compare_paths( proximate("a/b/c", "a", ec), "b/c" ); + compare_paths( proximate("a/b/c", "a", ec), "b/c"_norm ); VERIFY( !ec ); ec = bad_ec; - compare_paths( proximate("a/b/c", "a/b/c/x/y", ec), "../.." ); + compare_paths( proximate("a/b/c", "a/b/c/x/y", ec), "../.."_norm ); VERIFY( !ec ); ec = bad_ec; compare_paths( proximate("a/b/c", "a/b/c", ec), "." ); VERIFY( !ec ); ec = bad_ec; - compare_paths( proximate("a/b", "c/d", ec), "../../a/b" ); + compare_paths( proximate("a/b", "c/d", ec), "../../a/b"_norm ); VERIFY( !ec ); } diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/append/source.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/append/source.cc index 21ae6be3d97..578d1350178 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/append/source.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/append/source.cc @@ -120,24 +120,31 @@ test05() path p = "0/1/2/3/4/5/6"; // The string_view aliases the path's internal string: s = p.native(); + path::string_type expected(s); + expected += path::preferred_separator; + expected += s; // Append that string_view, which must work correctly even though the // internal string will be reallocated during the operation: p /= s; - VERIFY( p.string() == "0/1/2/3/4/5/6/0/1/2/3/4/5/6" ); + compare_paths(p, expected); // Same again with a trailing slash: path p2 = "0/1/2/3/4/5/"; s = p2.native(); + expected = s; + expected += s; p2 /= s; - VERIFY( p2.string() == "0/1/2/3/4/5/0/1/2/3/4/5/" ); + compare_paths(p2, expected); // And aliasing one of the components of the path: path p3 = "0/123456789/a"; path::iterator second = std::next(p3.begin()); s = second->native(); + expected = p3.native() + path::preferred_separator; + expected += s; p3 /= s; - VERIFY( p3.string() == "0/123456789/a/123456789" ); - } + compare_paths(p3, expected); +} void test06() diff --git a/libstdc++-v3/testsuite/27_io/filesystem/path/compare/lwg2936.cc b/libstdc++-v3/testsuite/27_io/filesystem/path/compare/lwg2936.cc index 8a11043f143..a62f01c3fb6 100644 --- a/libstdc++-v3/testsuite/27_io/filesystem/path/compare/lwg2936.cc +++ b/libstdc++-v3/testsuite/27_io/filesystem/path/compare/lwg2936.cc @@ -60,7 +60,11 @@ test01() check("c:", "d:", -1); check("c:", "c:/", -1); check("d:", "c:/", +1); +#if defined(__MING32__) || defined(__MINGW64__) + check("c:/a/b", "c:a/b", +1); +#else check("c:/a/b", "c:a/b", -1); +#endif // These are root names on Cygwin (just relative paths elsewhere) check("", "//c", -1); @@ -68,6 +72,7 @@ test01() check("//c", "//c/", -1); check("//d", "//c/", +1); + check("a", "/", -1); check("/a", "/b", -1); check("a", "/b", -1); check("/b", "b", +1); --LZvS9be/3tNcYl/X--