Author: Kadir Cetinkaya Date: 2020-01-29T12:20:41+01:00 New Revision: 9a174549742aae9e5bc9ab099cad849b0282f0e3
URL: https://github.com/llvm/llvm-project/commit/9a174549742aae9e5bc9ab099cad849b0282f0e3 DIFF: https://github.com/llvm/llvm-project/commit/9a174549742aae9e5bc9ab099cad849b0282f0e3.diff LOG: [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 (cherry picked from commit 55b0e9c9d5de7c5d70552ac9ca9ffc14097e983b) Added: Modified: clang-tools-extra/clangd/unittests/HoverTests.cpp Removed: ################################################################################ diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 04b9415c687f..bdac5be0ac35 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 diff erent depending on the target triplet, we chose a + // fixed one to make sure tests passes on diff erent platform. + TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu"); auto AST = TU.build(); ASSERT_TRUE(AST.getDiagnostics().empty()); @@ -1590,6 +1595,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. @@ -1607,6 +1632,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 diff erent depending on the target triplet, we chose a + // fixed one to make sure tests passes on diff erent platform. + TU.ExtraArgs.push_back("--target=x86_64-pc-linux-gnu"); auto AST = TU.build(); for (const auto &D : AST.getDiagnostics()) ADD_FAILURE() << D; @@ -1854,49 +1882,6 @@ Value = val 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(); - for (const auto &D : AST.getDiagnostics()) - ADD_FAILURE() << D; - - 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 diff er on diff erent platforms. - EXPECT_EQ(H->Name, ExpectedHover.Name); - EXPECT_EQ(H->Value, ExpectedHover.Value); - } -} } // namespace } // namespace clangd } // namespace clang _______________________________________________ llvm-branch-commits mailing list llvm-branch-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/llvm-branch-commits