Progmasoft Git

catch3

Progmasoft Catch3: an independently maintained C++17 test framework with a parallel runner, property checks, snapshots and structured results.

Clonegit clone https://git.progmasoft.com/catch3

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
Commit
359542d53ec142514da8a606ada8d9efd13b9678
Author
Tim Blechmann ·
Committer
Martin Hořeňovský
Parents
dea1a6abd92b

Files · Download .tar.gz

Changes

 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