Skip to content

Commit

Permalink
[clangd] use SCOPED_TRACE to better trace the testcase in test failur…
Browse files Browse the repository at this point in the history
…e, NFC

Reviewers: kadircet

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

Tags: #clang

Differential Revision: https://reviews.llvm.org/D73463
  • Loading branch information
hokein committed Jan 28, 2020
1 parent 1b12766 commit dea1147
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions clang-tools-extra/clangd/unittests/RenameTests.cpp
Expand Up @@ -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");
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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");
Expand Down Expand Up @@ -1012,15 +1015,15 @@ 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);
if (!ActualRanges)
EXPECT_THAT(Draft.ranges(), testing::IsEmpty());
else
EXPECT_THAT(Draft.ranges(),
testing::UnorderedElementsAreArray(*ActualRanges))
<< T.DraftCode;
testing::UnorderedElementsAreArray(*ActualRanges));
}
}

Expand Down Expand Up @@ -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;
Expand All @@ -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));
}
}

Expand Down Expand Up @@ -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);
}
}

Expand Down

0 comments on commit dea1147

Please sign in to comment.