[clang] [clang-format] Add DiagHandler for getStyle function (PR #91317)
Owen Pan via cfe-commits
cfe-commits at lists.llvm.org
Fri Jun 14 00:49:28 PDT 2024
================
@@ -1452,6 +1452,35 @@ TEST(ConfigParseTest, GetStyleOfSpecificFile) {
ASSERT_EQ(*Style, getGoogleStyle());
}
+TEST(ConfigParseTest, GetStyleOutput) {
+ // With output
+ ::testing::internal::CaptureStderr();
+ llvm::vfs::InMemoryFileSystem FS;
+ auto Style = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS, false);
+
+ const std::string output = ::testing::internal::GetCapturedStderr();
+
+ ASSERT_FALSE((bool)Style);
+ ASSERT_FALSE(output.empty());
+ llvm::consumeError(Style.takeError());
----------------
owenca wrote:
```suggestion
llvm::vfs::InMemoryFileSystem FS;
// Don't suppress output.
testing::internal::CaptureStderr();
auto Style = getStyle("{invalid_key=invalid_value}", "a.h", "LLVM", "", &FS,
/*AllowUnknownOptions=*/true);
const auto output = testing::internal::GetCapturedStderr();
ASSERT_TRUE((bool)Style);
ASSERT_FALSE(output.empty());
```
https://github.com/llvm/llvm-project/pull/91317
More information about the cfe-commits
mailing list