aboutsummaryrefslogtreecommitdiff
path: root/clang/unittests/Format/ConfigParseTest.cpp
diff options
context:
space:
mode:
authorpointhex <1111artem1111@gmail.com>2024-06-16 22:58:26 +0200
committerGitHub <noreply@github.com>2024-06-16 13:58:26 -0700
commitfe9aef05c2dcfbde6e29e2edb2d49e29a54bea4d (patch)
tree99efd2c21730fc3053b39f3d855f1f228640f0d6 /clang/unittests/Format/ConfigParseTest.cpp
parenta106131a34ed87f597c78183ada56f01fd17641d (diff)
downloadllvm-fe9aef05c2dcfbde6e29e2edb2d49e29a54bea4d.zip
llvm-fe9aef05c2dcfbde6e29e2edb2d49e29a54bea4d.tar.gz
llvm-fe9aef05c2dcfbde6e29e2edb2d49e29a54bea4d.tar.bz2
[clang-format] Add DiagHandler parameter to format::getStyle() (#91317)
It allows to control of error output for the function. Closes #94205. --------- Co-authored-by: Owen Pan <owenpiano@gmail.com>
Diffstat (limited to 'clang/unittests/Format/ConfigParseTest.cpp')
-rw-r--r--clang/unittests/Format/ConfigParseTest.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/clang/unittests/Format/ConfigParseTest.cpp b/clang/unittests/Format/ConfigParseTest.cpp
index ff3ced3..2513ab39 100644
--- a/clang/unittests/Format/ConfigParseTest.cpp
+++ b/clang/unittests/Format/ConfigParseTest.cpp
@@ -1452,6 +1452,27 @@ TEST(ConfigParseTest, GetStyleOfSpecificFile) {
ASSERT_EQ(*Style, getGoogleStyle());
}
+TEST(ConfigParseTest, GetStyleOutput) {
+ llvm::vfs::InMemoryFileSystem FS;
+
+ // Don't suppress output.
+ testing::internal::CaptureStderr();
+ auto Style = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS,
+ /*AllowUnknownOptions=*/true);
+ auto Output = testing::internal::GetCapturedStderr();
+ ASSERT_TRUE((bool)Style);
+ ASSERT_FALSE(Output.empty());
+
+ // Suppress stderr.
+ testing::internal::CaptureStderr();
+ Style = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS,
+ /*AllowUnknownOptions=*/true,
+ [](const llvm::SMDiagnostic &, void *) {});
+ Output = testing::internal::GetCapturedStderr();
+ ASSERT_TRUE((bool)Style);
+ ASSERT_TRUE(Output.empty());
+}
+
} // namespace
} // namespace format
} // namespace clang