Skip to content

Commit

Permalink
[clangd] Fix windows buildbots after ecea721
Browse files Browse the repository at this point in the history
  • Loading branch information
kadircet committed Feb 16, 2021
1 parent f350fe8 commit cdef5a7
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
4 changes: 2 additions & 2 deletions clang-tools-extra/clangd/support/Path.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ bool pathEqual(PathRef A, PathRef B) { return A == B; }

bool pathStartsWith(PathRef Ancestor, PathRef Path,
llvm::sys::path::Style Style) {
assert(llvm::sys::path::is_absolute(Ancestor, Style) &&
llvm::sys::path::is_absolute(Path, Style));
assert(llvm::sys::path::is_absolute(Ancestor) &&
llvm::sys::path::is_absolute(Path));
// If ancestor ends with a separator drop that, so that we can match /foo/ as
// a parent of /foo.
if (llvm::sys::path::is_separator(Ancestor.back(), Style))
Expand Down
21 changes: 11 additions & 10 deletions clang-tools-extra/clangd/unittests/support/PathTests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
//
//===----------------------------------------------------------------------===//

#include "TestFS.h"
#include "support/Path.h"
#include "gmock/gmock.h"
#include "gtest/gtest.h"
Expand All @@ -14,21 +15,21 @@ namespace clang {
namespace clangd {
namespace {
TEST(PathTests, IsAncestor) {
EXPECT_TRUE(pathStartsWith("/foo", "/foo"));
EXPECT_TRUE(pathStartsWith("/foo/", "/foo"));
EXPECT_TRUE(pathStartsWith(testPath("foo"), testPath("foo")));
EXPECT_TRUE(pathStartsWith(testPath("foo/"), testPath("foo")));

EXPECT_FALSE(pathStartsWith("/foo", "/fooz"));
EXPECT_FALSE(pathStartsWith("/foo/", "/fooz"));
EXPECT_FALSE(pathStartsWith(testPath("foo"), testPath("fooz")));
EXPECT_FALSE(pathStartsWith(testPath("foo/"), testPath("fooz")));

EXPECT_TRUE(pathStartsWith("/foo", "/foo/bar"));
EXPECT_TRUE(pathStartsWith("/foo/", "/foo/bar"));
EXPECT_TRUE(pathStartsWith(testPath("foo"), testPath("foo/bar")));
EXPECT_TRUE(pathStartsWith(testPath("foo/"), testPath("foo/bar")));

#ifdef CLANGD_PATH_CASE_INSENSITIVE
EXPECT_TRUE(pathStartsWith("/fOo", "/foo/bar"));
EXPECT_TRUE(pathStartsWith("/foo", "/fOo/bar"));
EXPECT_TRUE(pathStartsWith(testPath("fOo"), testPath("foo/bar")));
EXPECT_TRUE(pathStartsWith(testPath("foo"), testPath("fOo/bar")));
#else
EXPECT_FALSE(pathStartsWith("/fOo", "/foo/bar"));
EXPECT_FALSE(pathStartsWith("/foo", "/fOo/bar"));
EXPECT_FALSE(pathStartsWith(testPath("fOo"), testPath("foo/bar")));
EXPECT_FALSE(pathStartsWith(testPath("foo"), testPath("fOo/bar")));
#endif
}
} // namespace
Expand Down

0 comments on commit cdef5a7

Please sign in to comment.