forked from OSchip/llvm-project
[libcxx] [test] Account for differences in a trailing slash in weakly_canonical
This seems to be a documented quirk in libc++'s implementation of weakly_canonical (in a comment in the weakly_canonical test). Together with a difference between windows and posix regarding whether paths can go through nonexistent dirs, this results in a difference in a trailing slash. Just document this as expected, and degrade the comment from fixme to a note, as MS STL and libstdc++ behave in the same way. Differential Revision: https://reviews.llvm.org/D98642
This commit is contained in:
parent
cfa65f77cb
commit
7a154c3230
|
@ -66,6 +66,17 @@ TEST_CASE(test_exist_not_found)
|
|||
const path p = static_env.DNE;
|
||||
TEST_CHECK(exists(p) == false);
|
||||
|
||||
TEST_CHECK(exists(static_env.Dir) == true);
|
||||
TEST_CHECK(exists(static_env.Dir / "dne") == false);
|
||||
// Whether <dir>/dne/.. is considered to exist or not is not necessarily
|
||||
// something we need to define, but the platform specific behaviour
|
||||
// does affect a few other tests, so clarify the root cause here.
|
||||
#ifdef _WIN32
|
||||
TEST_CHECK(exists(static_env.Dir / "dne" / "..") == true);
|
||||
#else
|
||||
TEST_CHECK(exists(static_env.Dir / "dne" / "..") == false);
|
||||
#endif
|
||||
|
||||
std::error_code ec = GetTestEC();
|
||||
TEST_CHECK(exists(p, ec) == false);
|
||||
TEST_CHECK(!ec);
|
||||
|
|
|
@ -95,7 +95,17 @@ TEST_CASE(test_signature_9) {
|
|||
static_test_env static_env;
|
||||
fs::path p(static_env.SymlinkToDir / "dir2/../dir2/DNE/..");
|
||||
const fs::path output = fs::weakly_canonical(p);
|
||||
// weakly_canonical has a quirk - if the path is considered to exist,
|
||||
// it's returned without a trailing slash, otherwise it's returned with
|
||||
// one (see a note in fs.op.weakly_canonical/weakly_canonical.pass.cpp).
|
||||
// On Windows, a path like existent/nonexistentsubdir/.. is considered
|
||||
// to exist, on posix it's considered to not exist. Therefore, the
|
||||
// result here differs in the trailing slash.
|
||||
#ifdef _WIN32
|
||||
TEST_CHECK(output == fs::path::string_type(static_env.Dir2));
|
||||
#else
|
||||
TEST_CHECK(output == fs::path::string_type(static_env.Dir2 / ""));
|
||||
#endif
|
||||
}
|
||||
|
||||
TEST_CASE(test_signature_10) {
|
||||
|
|
|
@ -46,12 +46,20 @@ int main(int, char**) {
|
|||
{static_env.Dir, static_env.Dir},
|
||||
{static_env.SymlinkToDir, static_env.Dir},
|
||||
{static_env.SymlinkToDir / "dir2/.", static_env.Dir / "dir2"},
|
||||
// FIXME? If the trailing separator occurs in a part of the path that exists,
|
||||
// Note: If the trailing separator occurs in a part of the path that exists,
|
||||
// it is omitted. Otherwise it is added to the end of the result.
|
||||
// MS STL and libstdc++ behave similarly.
|
||||
{static_env.SymlinkToDir / "dir2/./", static_env.Dir / "dir2"},
|
||||
{static_env.SymlinkToDir / "dir2/DNE/./", static_env.Dir / "dir2/DNE/"},
|
||||
{static_env.SymlinkToDir / "dir2", static_env.Dir2},
|
||||
#ifdef _WIN32
|
||||
// On Windows, this path is considered to exist (even though it
|
||||
// passes through a nonexistent directory), and thus is returned
|
||||
// without a trailing slash, see the note above.
|
||||
{static_env.SymlinkToDir / "dir2/../dir2/DNE/..", static_env.Dir2},
|
||||
#else
|
||||
{static_env.SymlinkToDir / "dir2/../dir2/DNE/..", static_env.Dir2 / ""},
|
||||
#endif
|
||||
{static_env.SymlinkToDir / "dir2/dir3/../DNE/DNE2", static_env.Dir2 / "DNE/DNE2"},
|
||||
{static_env.Dir / "../dir1", static_env.Dir},
|
||||
{static_env.Dir / "./.", static_env.Dir},
|
||||
|
|
Loading…
Reference in New Issue