[clang-tools-extra] 778a1f2 - [include-cleaner] Fix windows buildbots after 64d9713637ab9

Kadir Cetinkaya via cfe-commits cfe-commits at lists.llvm.org
Tue Aug 13 04:29:27 PDT 2024


Author: Kadir Cetinkaya
Date: 2024-08-13T13:28:07+02:00
New Revision: 778a1f29fc29bb184634eae14db1b39f70b7bc45

URL: https://github.com/llvm/llvm-project/commit/778a1f29fc29bb184634eae14db1b39f70b7bc45
DIFF: https://github.com/llvm/llvm-project/commit/778a1f29fc29bb184634eae14db1b39f70b7bc45.diff

LOG: [include-cleaner] Fix windows buildbots after 64d9713637ab9

Added: 
    

Modified: 
    clang-tools-extra/include-cleaner/unittests/RecordTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
index bcb9f8982c461a..715d95eb573464 100644
--- a/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
+++ b/clang-tools-extra/include-cleaner/unittests/RecordTest.cpp
@@ -10,6 +10,7 @@
 #include "clang-include-cleaner/Types.h"
 #include "clang/AST/Decl.h"
 #include "clang/Basic/Diagnostic.h"
+#include "clang/Basic/FileEntry.h"
 #include "clang/Basic/LLVM.h"
 #include "clang/Basic/SourceLocation.h"
 #include "clang/Frontend/CompilerInvocation.h"
@@ -24,6 +25,7 @@
 #include "llvm/ADT/StringRef.h"
 #include "llvm/Support/Error.h"
 #include "llvm/Support/MemoryBuffer.h"
+#include "llvm/Support/Path.h"
 #include "llvm/Support/VirtualFileSystem.h"
 #include "llvm/Support/raw_ostream.h"
 #include "llvm/Testing/Annotations/Annotations.h"
@@ -53,8 +55,8 @@ MATCHER_P(named, N, "") {
 }
 
 MATCHER_P(FileNamed, N, "") {
-  llvm::StringRef ActualName = arg.getName();
-  ActualName.consume_front("./");
+  llvm::StringRef ActualName =
+      llvm::sys::path::remove_leading_dotslash(arg.getName());
   if (ActualName == N)
     return true;
   *result_listener << ActualName.str();
@@ -319,7 +321,8 @@ class PragmaIncludeTest : public ::testing::Test {
   }
 
   TestAST build(bool ResetPragmaIncludes = true) {
-    if (ResetPragmaIncludes) PI = PragmaIncludes();
+    if (ResetPragmaIncludes)
+      PI = PragmaIncludes();
     return TestAST(Inputs);
   }
 
@@ -537,16 +540,33 @@ TEST_F(PragmaIncludeTest, IWYUExportBlock) {
   TestAST Processed = build();
   auto &FM = Processed.fileManager();
 
-  EXPECT_THAT(PI.getExporters(FM.getFile("private1.h").get(), FM),
-              testing::UnorderedElementsAre(FileNamed("export1.h"),
-                                            FileNamed("normal.h")));
-  EXPECT_THAT(PI.getExporters(FM.getFile("private2.h").get(), FM),
-              testing::UnorderedElementsAre(FileNamed("export1.h")));
-  EXPECT_THAT(PI.getExporters(FM.getFile("private3.h").get(), FM),
-              testing::UnorderedElementsAre(FileNamed("export1.h")));
-
-  EXPECT_TRUE(PI.getExporters(FM.getFile("foo.h").get(), FM).empty());
-  EXPECT_TRUE(PI.getExporters(FM.getFile("bar.h").get(), FM).empty());
+  auto GetNames = [](llvm::ArrayRef<FileEntryRef> FEs) {
+    std::string Result;
+    llvm::raw_string_ostream OS(Result);
+    for (auto &FE : FEs) {
+      OS << FE.getName() << " ";
+    }
+    OS.flush();
+    return Result;
+  };
+  auto Exporters = PI.getExporters(FM.getFile("private1.h").get(), FM);
+  EXPECT_THAT(Exporters, testing::UnorderedElementsAre(FileNamed("export1.h"),
+                                                       FileNamed("normal.h")))
+      << GetNames(Exporters);
+
+  Exporters = PI.getExporters(FM.getFile("private2.h").get(), FM);
+  EXPECT_THAT(Exporters, testing::UnorderedElementsAre(FileNamed("export1.h")))
+      << GetNames(Exporters);
+
+  Exporters = PI.getExporters(FM.getFile("private3.h").get(), FM);
+  EXPECT_THAT(Exporters, testing::UnorderedElementsAre(FileNamed("export1.h")))
+      << GetNames(Exporters);
+
+  Exporters = PI.getExporters(FM.getFile("foo.h").get(), FM);
+  EXPECT_TRUE(Exporters.empty()) << GetNames(Exporters);
+
+  Exporters = PI.getExporters(FM.getFile("bar.h").get(), FM);
+  EXPECT_TRUE(Exporters.empty()) << GetNames(Exporters);
 }
 
 TEST_F(PragmaIncludeTest, SelfContained) {


        


More information about the cfe-commits mailing list