[PATCH] D73613: [clangd][Hover] Make tests hermetic by setting target triplet
Kadir Cetinkaya via Phabricator via cfe-commits
cfe-commits at lists.llvm.org
Wed Jan 29 02:21:49 PST 2020
kadircet created this revision.
kadircet added a reviewer: sammccall.
Herald added subscribers: cfe-commits, usaxena95, arphaman, jkorous, MaskRay, ilya-biryukov.
Herald added a project: clang.
Fixes https://bugs.llvm.org/show_bug.cgi?id=44696
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D73613
Files:
clang-tools-extra/clangd/unittests/HoverTests.cpp
Index: clang-tools-extra/clangd/unittests/HoverTests.cpp
===================================================================
--- clang-tools-extra/clangd/unittests/HoverTests.cpp
+++ clang-tools-extra/clangd/unittests/HoverTests.cpp
@@ -581,6 +581,9 @@
TestTU TU = TestTU::withCode(T.code());
TU.ExtraArgs.push_back("-std=c++17");
TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
+ // Types might be different depending on the target triplet, we chose a
+ // fixed one to make sure tests passes on different platform.
+ TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
auto AST = TU.build();
auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
@@ -1587,6 +1590,26 @@
HI.Parameters = {
{std::string("int"), std::string("x"), llvm::None}};
}},
+ {
+ R"cpp(// sizeof expr
+ void foo() {
+ (void)[[size^of]](char);
+ })cpp",
+ [](HoverInfo &HI) {
+ HI.Name = "expression";
+ HI.Type = "unsigned long";
+ HI.Value = "1";
+ }},
+ {
+ R"cpp(// alignof expr
+ void foo() {
+ (void)[[align^of]](char);
+ })cpp",
+ [](HoverInfo &HI) {
+ HI.Name = "expression";
+ HI.Type = "unsigned long";
+ HI.Value = "1";
+ }},
};
// Create a tiny index, so tests above can verify documentation is fetched.
@@ -1604,6 +1627,9 @@
TestTU TU = TestTU::withCode(T.code());
TU.ExtraArgs.push_back("-std=c++17");
TU.ExtraArgs.push_back("-Wno-gnu-designator");
+ // Types might be different depending on the target triplet, we chose a
+ // fixed one to make sure tests passes on different platform.
+ TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu");
auto AST = TU.build();
auto H = getHover(AST, T.point(), format::getLLVMStyle(), Index.get());
@@ -1836,46 +1862,6 @@
def)pt";
EXPECT_EQ(HI.present().asPlainText(), ExpectedPlaintext);
}
-
-TEST(Hover, ExprTests) {
- struct {
- const char *const Code;
- const std::function<void(HoverInfo &)> ExpectedBuilder;
- } Cases[] = {
- {
- R"cpp(// sizeof expr
- void foo() {
- (void)[[size^of]](char);
- })cpp",
- [](HoverInfo &HI) {
- HI.Name = "expression";
- HI.Type = "unsigned long";
- HI.Value = "1";
- }},
- {
- R"cpp(// alignof expr
- void foo() {
- (void)[[align^of]](char);
- })cpp",
- [](HoverInfo &HI) {
- HI.Name = "expression";
- HI.Type = "unsigned long";
- HI.Value = "1";
- }},
- };
- for (const auto &C : Cases) {
- Annotations T(C.Code);
- TestTU TU = TestTU::withCode(T.code());
- auto AST = TU.build();
- auto H = getHover(AST, T.point(), format::getLLVMStyle(), nullptr);
- ASSERT_TRUE(H);
- HoverInfo ExpectedHover;
- C.ExpectedBuilder(ExpectedHover);
- // We don't check for Type as it might differ on different platforms.
- EXPECT_EQ(H->Name, ExpectedHover.Name);
- EXPECT_EQ(H->Value, ExpectedHover.Value);
- }
-}
} // namespace
} // namespace clangd
} // namespace clang
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D73613.241074.patch
Type: text/x-patch
Size: 3294 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/cfe-commits/attachments/20200129/eeb7de37/attachment-0001.bin>
More information about the cfe-commits
mailing list