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

Some reporter refinements

Commit
0f478a5b10b2045eee69c67aad18a576decce1e1
Author
Phil Nash ·
Parents
381fffe07d3a

Files · Download .tar.gz

Changes

 catch_reporter_basic.hpp | 38 ++++++++++++++++++++++++++------------
 1 file changed, 26 insertions(+), 12 deletions(-)

diff --git a/catch_reporter_basic.hpp b/catch_reporter_basic.hpp
index 18a63cdc..b4ca75b7 100644
--- a/catch_reporter_basic.hpp
+++ b/catch_reporter_basic.hpp
@@ -173,7 +173,11 @@ namespace Catch
             StartSpansLazily();
             
             if( !resultInfo.getFilename().empty() )
+#ifndef __GNUG__
                 m_config.stream() << resultInfo.getFilename() << "(" << resultInfo.getLine() << "): ";
+#else                
+                m_config.stream() << resultInfo.getFilename() << ":" << resultInfo.getLine() << ": ";            
+#endif            
             
             if( resultInfo.hasExpression() )
             {
@@ -199,7 +203,7 @@ namespace Catch
                         m_config.stream() << "No exception thrown where one was expected";
                     break;
                 case ResultWas::Info:
-                    m_config.stream() << "info:\n'" << resultInfo.getMessage() << "'";
+                    streamVariableLengthText( "info", resultInfo.getMessage() );
                     break;
                 case ResultWas::Warning:
                     m_config.stream() << "warning:\n'" << resultInfo.getMessage() << "'";
@@ -238,22 +242,13 @@ namespace Catch
             if( !stdOut.empty() )
             {
                 StartSpansLazily();
-                std::string stdOutTrimmed = trim( stdOut );
-                if( stdOutTrimmed.find_first_of( "\r\n" ) == std::string::npos )
-                {
-                    m_config.stream() << "[stdout: " << stdOutTrimmed << "]\n";
-                }
-                else 
-                {
-                    m_config.stream() << "[stdout] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" << stdOutTrimmed << "\n[end of stdout] <<<<<<<<<<<<<<<<<<<<<<<\n";
-                }
-
+                streamVariableLengthText( "stdout", stdOut );
             }
 
             if( !stdErr.empty() )
             {
                 StartSpansLazily();
-                m_config.stream() << "[stderr: " << trim( stdErr ) << "]\n";
+                streamVariableLengthText( "stderr", stdErr );
             }
                 
             if( m_testSpan.emitted )
@@ -311,6 +306,25 @@ namespace Catch
                 }
             }
         }
+
+        ///////////////////////////////////////////////////////////////////////////
+        void streamVariableLengthText
+        (
+            const std::string& prefix,
+            const std::string& text
+        )
+        {
+            std::string trimmed = trim( text );
+            if( trimmed.find_first_of( "\r\n" ) == std::string::npos )
+            {
+                m_config.stream() << "[" << prefix << ": " << trimmed << "]\n";
+            }
+            else 
+            {
+                m_config.stream()   << "\n[" << prefix << "] >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>\n" << trimmed 
+                                    << "\n[end of " << prefix << "] <<<<<<<<<<<<<<<<<<<<<<<<\n";
+            }
+        }
         
     private:
         const IReporterConfig& m_config;