From 359542d53ec142514da8a606ada8d9efd13b9678 Mon Sep 17 00:00:00 2001 From: Tim Blechmann Date: Sat, 10 Sep 2022 12:18:19 +0800 Subject: [PATCH] FileStream: enable automatic flushing when a test executable is killed by a signal (e.g. when executed by ctest with timeout), the reporter files are not flushed. this can lead to incomplete (or empty) report files. to avoid this we enable automatic flushing via `std::unitbuf` compare #663 --- src/catch2/internal/catch_istream.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/catch2/internal/catch_istream.cpp b/src/catch2/internal/catch_istream.cpp index 4cd35058..6d1fa94b 100644 --- a/src/catch2/internal/catch_istream.cpp +++ b/src/catch2/internal/catch_istream.cpp @@ -78,6 +78,7 @@ namespace Detail { FileStream( std::string const& filename ) { m_ofs.open( filename.c_str() ); CATCH_ENFORCE( !m_ofs.fail(), "Unable to open file: '" << filename << '\'' ); + m_ofs << std::unitbuf; } ~FileStream() override = default; public: // IStream