[clang-tools-extra] 55b0e9c - [clangd][Hover] Make tests hermetic by setting target triplet

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Wed Jan 29 03:17:15 PST 2020


Author: Kadir Cetinkaya
Date: 2020-01-29T12:12:45+01:00
New Revision: 55b0e9c9d5de7c5d70552ac9ca9ffc14097e983b

URL: https://github.com/llvm/llvm-project/commit/55b0e9c9d5de7c5d70552ac9ca9ffc14097e983b
DIFF: https://github.com/llvm/llvm-project/commit/55b0e9c9d5de7c5d70552ac9ca9ffc14097e983b.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

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 758c64208fd8..5f8f0560a3ee 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();
 
     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 
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();
 
     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<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 
diff er on 
diff erent platforms.
-    EXPECT_EQ(H->Name, ExpectedHover.Name);
-    EXPECT_EQ(H->Value, ExpectedHover.Value);
-  }
-}
 } // namespace
 } // namespace clangd
 } // namespace clang


        


More information about the cfe-commits mailing list