diff options
author | Kadir Cetinkaya <kadircet@google.com> | 2020-01-29 11:17:45 +0100 |
---|---|---|
committer | Kadir Cetinkaya <kadircet@google.com> | 2020-01-29 12:20:41 +0100 |
commit | 9a174549742aae9e5bc9ab099cad849b0282f0e3 (patch) | |
tree | b6a899f792955856e980e6cb1828e5b28ecc41d1 | |
parent | 684c216d73cdcd64fc0186b533870cb79dc03810 (diff) | |
download | bcm5719-llvm-9a174549742aae9e5bc9ab099cad849b0282f0e3.tar.gz bcm5719-llvm-9a174549742aae9e5bc9ab099cad849b0282f0e3.zip |
[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)
-rw-r--r-- | clang-tools-extra/clangd/unittests/HoverTests.cpp | 71 |
1 files changed, 28 insertions, 43 deletions
diff --git a/clang-tools-extra/clangd/unittests/HoverTests.cpp b/clang-tools-extra/clangd/unittests/HoverTests.cpp index 04b9415c687..bdac5be0ac3 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(); 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 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(); 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 differ on different platforms. - EXPECT_EQ(H->Name, ExpectedHover.Name); - EXPECT_EQ(H->Value, ExpectedHover.Value); - } -} } // namespace } // namespace clangd } // namespace clang |