From: Kadir Cetinkaya Date: Wed, 29 Jan 2020 10:17:45 +0000 (+0100) Subject: [clangd][Hover] Make tests hermetic by setting target triplet X-Git-Tag: llvmorg-12-init~16488 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=55b0e9c9d5de7c5d70552ac9ca9ffc14097e983b;p=platform%2Fupstream%2Fllvm.git [clangd][Hover] Make tests hermetic by setting target triplet Summary: Fixes https://bugs.llvm.org/show_bug.cgi?id=44696 Reviewers: sammccall Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits Tags: #clang Differential Revision: https://reviews.llvm.org/D73613 --- diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 758c642..5f8f056 100644 --- a/clang-tools-extra/clangd/unittests/HoverTests.cpp +++ b/clang-tools-extra/clangd/unittests/HoverTests.cpp @@ -580,7 +580,12 @@ class Foo {})cpp"; Annotations T(Case.Code); TestTU TU = TestTU::withCode(T.code()); TU.ExtraArgs.push_back("-std=c++17"); + // FIXME: This is no longer necessary, as the default behavior is no delayed + // parsing in the triplet below. 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 +1592,26 @@ TEST(Hover, All) { 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 +1629,9 @@ TEST(Hover, All) { 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 +1864,6 @@ Value = val def)pt"; EXPECT_EQ(HI.present().asPlainText(), ExpectedPlaintext); } - -TEST(Hover, ExprTests) { - struct { - const char *const Code; - const std::function 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