Author: Owen Pan
Date: 2024-06-16T14:56:02-07:00
New Revision: 527e7328607ea0a55855e53a59c5030a7d07a554

URL: 
https://github.com/llvm/llvm-project/commit/527e7328607ea0a55855e53a59c5030a7d07a554
DIFF: 
https://github.com/llvm/llvm-project/commit/527e7328607ea0a55855e53a59c5030a7d07a554.diff

LOG: [clang-format][NFC] Suppress diagnostic noise in GetStyleOfFile test

Added: 
    

Modified: 
    clang/unittests/Format/ConfigParseTest.cpp

Removed: 
    


################################################################################
diff  --git a/clang/unittests/Format/ConfigParseTest.cpp 
b/clang/unittests/Format/ConfigParseTest.cpp
index 2513ab3939595..aded3ed2a6596 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -15,6 +15,7 @@ namespace clang {
 namespace format {
 namespace {
 
+void dropDiagnosticHandler(const llvm::SMDiagnostic &, void *) {}
 FormatStyle getGoogleStyle() { return getGoogleStyle(FormatStyle::LK_Cpp); }
 
 #define EXPECT_ALL_STYLES_EQUAL(Styles)                                        
\
@@ -1240,7 +1241,8 @@ TEST(ConfigParseTest, GetStyleOfFile) {
   llvm::consumeError(Style4.takeError());
 
   // Test 5: error on invalid yaml on command line
-  auto Style5 = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", 
&FS);
+  auto Style5 = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS,
+                         /*AllowUnknownOptions=*/false, dropDiagnosticHandler);
   ASSERT_FALSE((bool)Style5);
   llvm::consumeError(Style5.takeError());
 
@@ -1256,11 +1258,13 @@ TEST(ConfigParseTest, GetStyleOfFile) {
                                                   "InvalidKey: 
InvalidValue")));
   ASSERT_TRUE(
       FS.addFile("/d/test.cpp", 0, llvm::MemoryBuffer::getMemBuffer("int 
i;")));
-  auto Style7a = getStyle("file", "/d/.clang-format", "LLVM", "", &FS);
+  auto Style7a = getStyle("file", "/d/.clang-format", "LLVM", "", &FS,
+                          /*AllowUnknownOptions=*/false, 
dropDiagnosticHandler);
   ASSERT_FALSE((bool)Style7a);
   llvm::consumeError(Style7a.takeError());
 
-  auto Style7b = getStyle("file", "/d/.clang-format", "LLVM", "", &FS, true);
+  auto Style7b = getStyle("file", "/d/.clang-format", "LLVM", "", &FS,
+                          /*AllowUnknownOptions=*/true, dropDiagnosticHandler);
   ASSERT_TRUE((bool)Style7b);
 
   // Test 8: inferred per-language defaults apply.
@@ -1466,8 +1470,7 @@ TEST(ConfigParseTest, GetStyleOutput) {
   // Suppress stderr.
   testing::internal::CaptureStderr();
   Style = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS,
-                   /*AllowUnknownOptions=*/true,
-                   [](const llvm::SMDiagnostic &, void *) {});
+                   /*AllowUnknownOptions=*/true, dropDiagnosticHandler);
   Output = testing::internal::GetCapturedStderr();
   ASSERT_TRUE((bool)Style);
   ASSERT_TRUE(Output.empty());


        
_______________________________________________
cfe-commits mailing list
cfe-commits@lists.llvm.org
https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits

Reply via email to