Investigate D110386 Windows failures

Add more information for test failures inspection.
This commit is contained in:
Kirill Bobyrev 2021-09-28 09:50:45 +02:00
parent 9fb57c8c1d
commit 7394d3ba27
3 changed files with 18 additions and 8 deletions

View File

@ -20,6 +20,7 @@
#include "clang/Lex/PPCallbacks.h"
#include "clang/Tooling/Inclusions/HeaderIncludes.h"
#include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/StringExtras.h"
#include "llvm/ADT/StringRef.h"
#include "llvm/ADT/StringSet.h"
#include "llvm/Support/Error.h"
@ -141,6 +142,11 @@ public:
std::vector<Inclusion> MainFileIncludes;
std::string dump() {
return "RealPathNames: " +
llvm::join(RealPathNames.begin(), RealPathNames.end(), ", ");
}
private:
std::vector<std::string> RealPathNames; // In HeaderID order.
// HeaderID maps the FileEntry::Name to the internal representation.

View File

@ -165,7 +165,8 @@ TEST_F(HeadersTest, CollectRewrittenAndResolved) {
AllOf(Written("\"sub/bar.h\""), Resolved(BarHeader))));
EXPECT_THAT(Includes.includeDepth(getID(MainFile, Includes)),
UnorderedElementsAre(Distance(getID(MainFile, Includes), 0u),
Distance(getID(BarHeader, Includes), 1u)));
Distance(getID(BarHeader, Includes), 1u)))
<< Includes.dump();
}
TEST_F(HeadersTest, OnlyCollectInclusionsInMain) {
@ -179,17 +180,19 @@ TEST_F(HeadersTest, OnlyCollectInclusionsInMain) {
#include "bar.h"
)cpp";
auto Includes = collectIncludes();
EXPECT_THAT(Includes.MainFileIncludes,
UnorderedElementsAre(
AllOf(Written("\"bar.h\""), Resolved(BarHeader))));
EXPECT_THAT(
Includes.MainFileIncludes,
UnorderedElementsAre(AllOf(Written("\"bar.h\""), Resolved(BarHeader))));
EXPECT_THAT(Includes.includeDepth(getID(MainFile, Includes)),
UnorderedElementsAre(Distance(getID(MainFile, Includes), 0u),
Distance(getID(BarHeader, Includes), 1u),
Distance(getID(BazHeader, Includes), 2u)));
Distance(getID(BazHeader, Includes), 2u)))
<< Includes.dump();
// includeDepth() also works for non-main files.
EXPECT_THAT(Includes.includeDepth(getID(BarHeader, Includes)),
UnorderedElementsAre(Distance(getID(BarHeader, Includes), 0u),
Distance(getID(BazHeader, Includes), 1u)));
Distance(getID(BazHeader, Includes), 1u)))
<< Includes.dump();
}
TEST_F(HeadersTest, PreambleIncludesPresentOnce) {
@ -240,7 +243,7 @@ TEST_F(HeadersTest, IncludedFilesGraph) {
{getID(BarHeader, Includes), getID(FooHeader, Includes)}},
{getID(FooHeader, Includes),
{getID(BarHeader, Includes), getID(BazHeader, Includes)}}};
EXPECT_EQ(Includes.IncludeChildren, Expected);
EXPECT_EQ(Includes.IncludeChildren, Expected) << Includes.dump();
}
TEST_F(HeadersTest, IncludeDirective) {

View File

@ -519,7 +519,8 @@ TEST(ParsedASTTest, PatchesAdditionalIncludes) {
auto AuxFE = FM.getFile(testPath("sub/aux.h"));
ASSERT_TRUE(AuxFE);
auto AuxID = Includes.getID(*AuxFE);
EXPECT_THAT(Includes.IncludeChildren[*MainID], Contains(*AuxID));
EXPECT_THAT(Includes.IncludeChildren[*MainID], Contains(*AuxID))
<< Includes.dump();
}
TEST(ParsedASTTest, PatchesDeletedIncludes) {