aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format/ConfigParseTest.cpp
diff options
context:
space:
mode:
authorOwen Pan <owenpiano@gmail.com>2024-06-16 14:52:03 -0700
committerOwen Pan <owenpiano@gmail.com>2024-06-16 14:56:02 -0700
commit527e7328607ea0a55855e53a59c5030a7d07a554 (patch)
treeea36b5e901b215eefb7df2297c147d25a86c6204 /clang/unittests/Format/ConfigParseTest.cpp
parentfbac6977820a341ab3dd7e1f0a2d8881e0161c49 (diff)
downloadllvm-527e7328607ea0a55855e53a59c5030a7d07a554.zip
llvm-527e7328607ea0a55855e53a59c5030a7d07a554.tar.gz
llvm-527e7328607ea0a55855e53a59c5030a7d07a554.tar.bz2
[clang-format][NFC] Suppress diagnostic noise in GetStyleOfFile test
Diffstat (limited to 'clang/unittests/Format/ConfigParseTest.cpp')
-rw-r--r--clang/unittests/Format/ConfigParseTest.cpp13
1 files changed, 8 insertions, 5 deletions
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index 2513ab39..aded3ed 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());