Commit dea11473 authored by Haojian Wu's avatar Haojian Wu
Browse files

[clangd] use SCOPED_TRACE to better trace the testcase in test failure, NFC

Reviewers: kadircet

Subscribers: ilya-biryukov, MaskRay, jkorous, arphaman, usaxena95, cfe-commits

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73463
parent 1b127668
Loading
Loading
Loading
Loading
+9 −5
Original line number Diff line number Diff line
@@ -442,6 +442,7 @@ TEST(RenameTest, WithinFileRename) {
      )cpp",
  };
  for (llvm::StringRef T : Tests) {
    SCOPED_TRACE(T);
    Annotations Code(T);
    auto TU = TestTU::withCode(Code.code());
    TU.ExtraArgs.push_back("-fno-delayed-template-parsing");
@@ -560,6 +561,7 @@ TEST(RenameTest, Renameable) {
  };

  for (const auto& Case : Cases) {
    SCOPED_TRACE(Case.Code);
    Annotations T(Case.Code);
    TestTU TU = TestTU::withCode(T.code());
    TU.HeaderCode = CommonHeader;
@@ -886,6 +888,7 @@ TEST(CrossFileRenameTests, WithUpToDateIndex) {
  };

  for (const auto& T : Cases) {
    SCOPED_TRACE(T.FooH);
    Annotations FooH(T.FooH);
    Annotations FooCC(T.FooCC);
    std::string FooHPath = testPath("foo.h");
@@ -1012,6 +1015,7 @@ TEST(CrossFileRenameTests, adjustRenameRanges) {
  LangOptions LangOpts;
  LangOpts.CPlusPlus = true;
  for (const auto &T : Tests) {
    SCOPED_TRACE(T.DraftCode);
    Annotations Draft(T.DraftCode);
    auto ActualRanges = adjustRenameRanges(
        Draft.code(), "x", Annotations(T.IndexedCode).ranges(), LangOpts);
@@ -1019,8 +1023,7 @@ TEST(CrossFileRenameTests, adjustRenameRanges) {
       EXPECT_THAT(Draft.ranges(), testing::IsEmpty());
    else
      EXPECT_THAT(Draft.ranges(),
                  testing::UnorderedElementsAreArray(*ActualRanges))
          << T.DraftCode;
                  testing::UnorderedElementsAreArray(*ActualRanges));
  }
}

@@ -1127,6 +1130,7 @@ TEST(RangePatchingHeuristic, GetMappedRanges) {
    }
  };
  for (const auto &T : Tests) {
    SCOPED_TRACE(T.IndexedCode);
    auto Lexed = Annotations(T.LexedCode);
    auto LexedRanges = Lexed.ranges();
    std::vector<Range> ExpectedMatches;
@@ -1143,8 +1147,7 @@ TEST(RangePatchingHeuristic, GetMappedRanges) {
    if (!Mapped)
      EXPECT_THAT(ExpectedMatches, IsEmpty());
    else
      EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped))
          << T.IndexedCode;
      EXPECT_THAT(ExpectedMatches, UnorderedElementsAreArray(*Mapped));
  }
}

@@ -1247,13 +1250,14 @@ TEST(CrossFileRenameTests, adjustmentCost) {
    },
  };
  for (const auto &T : Tests) {
    SCOPED_TRACE(T.RangeCode);
    Annotations C(T.RangeCode);
    std::vector<size_t> MappedIndex;
    for (size_t I = 0; I < C.ranges("lex").size(); ++I)
      MappedIndex.push_back(I);
    EXPECT_EQ(renameRangeAdjustmentCost(C.ranges("idx"), C.ranges("lex"),
                                        MappedIndex),
              T.ExpectedCost) << T.RangeCode;
              T.ExpectedCost);
  }
}