[PATCH] D58133: [clangd] Testcase for bug 39811
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Tue Feb 12 08:50:33 PST 2019
kadircet created this revision.
Herald added subscribers: cfe-commits, jdoerfert, arphaman, jkorous, MaskRay, ioeric, ilya-biryukov.
Herald added a project: clang.
Repository:
rCTE Clang Tools Extra
https://reviews.llvm.org/D58133
Files:
unittests/clangd/XRefsTests.cpp
Index: unittests/clangd/XRefsTests.cpp
===================================================================
--- unittests/clangd/XRefsTests.cpp
+++ unittests/clangd/XRefsTests.cpp
@@ -1389,6 +1389,35 @@
}
}
+TEST(GoTo, WithSysRoot) {
+ const char *CustoomRoot = "/sys/root/";
+ Annotations Main(R"cpp(
+ #include "header.h"
+ int main() {
+ return f^oo();
+ })cpp");
+ Annotations Header("int [[foo]](){return 42;}");
+
+ MockCompilationDatabase CDB;
+ CDB.ExtraClangFlags = {"--sysroot", CustoomRoot};
+ IgnoreDiagnostics DiagConsumer;
+ MockFSProvider FS;
+ ClangdServer Server(CDB, FS, DiagConsumer, ClangdServer::optsForTest());
+
+ // Fill the filesystem.
+ auto FooCpp = testPath("foo.cpp");
+ FS.Files[FooCpp] = Main.code();
+ auto HeaderPath = (llvm::StringRef(CustoomRoot) + "include/header.h").str();
+ FS.Files[HeaderPath] = Header.code();
+
+ runAddDocument(Server, FooCpp, Main.code());
+
+ // Go to a definition in main source file.
+ auto Locations = runLocateSymbolAt(Server, FooCpp, Main.point());
+ EXPECT_TRUE(bool(Locations)) << "findDefinitions returned an error";
+ EXPECT_THAT(*Locations, ElementsAre(Sym("foo", Header.range())));
+}
+
} // namespace
} // namespace clangd
} // namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D58133.186488.patch
Type: text/x-patch
Size: 1265 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20190212/478e5b1d/attachment-0001.bin>
More information about the cfe-commits
mailing list