This is an automated email from the ASF dual-hosted git repository. bmahler pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/mesos.git
commit 8dabbbdecdba75c775c2e9c02574faafbcd62b11 Author: Benjamin Mahler <[email protected]> AuthorDate: Thu Mar 5 18:06:47 2020 -0500 Fixed the broken PathTest.Relative on Windows. This test uses only linux style paths and fails on windows. This happened because this code was introduced recently but there was no testing or CI running on windows to catch it. Review: https://reviews.apache.org/r/72201 --- 3rdparty/stout/tests/path_tests.cpp | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/3rdparty/stout/tests/path_tests.cpp b/3rdparty/stout/tests/path_tests.cpp index d418d1b..1ae80d0 100644 --- a/3rdparty/stout/tests/path_tests.cpp +++ b/3rdparty/stout/tests/path_tests.cpp @@ -354,27 +354,50 @@ TEST(PathTest, IsAbsolute) } +// TODO(bmahler): This needs to test more valid path cases on windows. TEST(PathTest, Relative) { +#ifdef __WINDOWS__ + // Check that relative paths can only be computed between paths + // which are either both absolute or both relative. + EXPECT_ERROR(path::relative("a", "C:\\a")); + EXPECT_ERROR(path::relative("C:\\a", "a")); + + // Check that a path relative to itself is an empty path. + EXPECT_SOME_EQ(".", path::relative("C:\\a\\b\\c", "C:\\a\\b\\c")); + EXPECT_SOME_EQ(".", path::relative("a\\b\\c", "a\\b\\c")); + + // Check for relative paths which do not require going up in the filesystem. + EXPECT_SOME_EQ("b", path::relative("C:\\a\\b", "C:\\a")); + EXPECT_SOME_EQ("b", path::relative("a\\b", "a")); + + // Check for relative paths which do require going up in the filesystem. + EXPECT_SOME_EQ("..\\..\\d\\e", path::relative("C:\\a\\d\\e", "C:\\a\\b\\c")); + EXPECT_SOME_EQ("..\\..\\d\\e", path::relative("a\\d\\e", "a\\b\\c")); + + // Check for behavior of not normalized paths. + EXPECT_SOME_EQ(".", path::relative("C:\\a\\.\\b", "C:\\a\\b")); +#else // Check that relative paths can only be computed between paths // which are either both absolute or both relative. EXPECT_ERROR(path::relative("a", "/a")); EXPECT_ERROR(path::relative("/a", "a")); // Check that a path relative to itself is an empty path. - ASSERT_SOME_EQ(".", path::relative("/a/b/c", "/a/b/c")); - ASSERT_SOME_EQ(".", path::relative("a/b/c", "a/b/c")); + EXPECT_SOME_EQ(".", path::relative("/a/b/c", "/a/b/c")); + EXPECT_SOME_EQ(".", path::relative("a/b/c", "a/b/c")); // Check for relative paths which do not require going up in the filesystem. - ASSERT_SOME_EQ("b", path::relative("/a/b", "/a")); - ASSERT_SOME_EQ("b", path::relative("a/b", "a")); + EXPECT_SOME_EQ("b", path::relative("/a/b", "/a")); + EXPECT_SOME_EQ("b", path::relative("a/b", "a")); // Check for relative paths which do require going up in the filesystem. - ASSERT_SOME_EQ("../../d/e", path::relative("/a/d/e", "/a/b/c")); - ASSERT_SOME_EQ("../../d/e", path::relative("a/d/e", "a/b/c")); + EXPECT_SOME_EQ("../../d/e", path::relative("/a/d/e", "/a/b/c")); + EXPECT_SOME_EQ("../../d/e", path::relative("a/d/e", "a/b/c")); // Check for behavior of not normalized paths. - ASSERT_SOME_EQ(".", path::relative("/a/./b", "/a/b")); + EXPECT_SOME_EQ(".", path::relative("/a/./b", "/a/b")); +#endif // __WINDOWS__ }
