[llvm] Add thread-local overrides for `llvm::errs()` and `llvm::outs()`. (PR #90374)

David Blaikie via llvm-commits llvm-commits at lists.llvm.org
Tue Apr 30 18:07:33 PDT 2024


================
@@ -64,4 +64,32 @@ TEST(raw_fd_streamTest, DynCast) {
   }
 }
 
+TEST(raw_fd_streamTest, OverrideOutsAndErrs) {
+  SmallString<64> Path;
+  int FD;
+  ASSERT_FALSE(sys::fs::createTemporaryFile("foo", "bar", FD, Path));
+  FileRemover Cleanup(Path);
+  std::error_code EC;
+  raw_fd_stream OS(Path, EC);
+  ASSERT_TRUE(!EC);
+
+  ScopedOutsAndErrsOverride Overrides(&OS, &OS);
----------------
dwblaikie wrote:

Perhaps a test that demonstrates that these can be nested would be good? (checking that once the nested scope is destroyed, the outer scope's override is restored - rather than reverting straight back to the real stream)

https://github.com/llvm/llvm-project/pull/90374


More information about the llvm-commits mailing list