mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-11-04 14:09:33 +01:00 
			
		
		
		
	stdout retained for all sections
Fixed issue where stdout was dropped between sections
This commit is contained in:
		@@ -1,4 +1,4 @@
 | 
			
		||||
/*
 | 
			
		||||
 /*
 | 
			
		||||
 *  catch_runner.hpp
 | 
			
		||||
 *  Catch
 | 
			
		||||
 *
 | 
			
		||||
@@ -45,7 +45,7 @@ namespace Catch
 | 
			
		||||
        ~StreamRedirect
 | 
			
		||||
        ()
 | 
			
		||||
        {
 | 
			
		||||
            m_targetString = m_oss.str();
 | 
			
		||||
            m_targetString += m_oss.str();
 | 
			
		||||
            m_stream.rdbuf( m_prevBuf );
 | 
			
		||||
        }
 | 
			
		||||
        
 | 
			
		||||
 
 | 
			
		||||
@@ -74,7 +74,6 @@ namespace Catch
 | 
			
		||||
                if( testSpec.matches( it->getName() ) )
 | 
			
		||||
                {
 | 
			
		||||
                    testList.push_back( *it );
 | 
			
		||||
                    std::cout << it->getName() << std::endl;
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            return testList;
 | 
			
		||||
 
 | 
			
		||||
@@ -49,3 +49,29 @@ TEST_CASE( "./failing/message/fail", "FAIL aborts the test" )
 | 
			
		||||
{
 | 
			
		||||
    FAIL( "This is a " << "failure" );    // This should output the message and abort
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE( "./failing/message/sections", "Output from all sections is reported" )
 | 
			
		||||
{
 | 
			
		||||
    SECTION( "one", "" )
 | 
			
		||||
    {
 | 
			
		||||
        FAIL( "Message from section one" );
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    SECTION( "two", "" )
 | 
			
		||||
    {
 | 
			
		||||
        FAIL( "Message from section two" );
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
TEST_CASE( "./succeeding/message/sections/stdout", "Output from all sections is reported" )
 | 
			
		||||
{
 | 
			
		||||
    SECTION( "one", "" )
 | 
			
		||||
    {
 | 
			
		||||
        std::cout << "Message from section one" << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
    
 | 
			
		||||
    SECTION( "two", "" )
 | 
			
		||||
    {
 | 
			
		||||
        std::cout << "Message from section two" << std::endl;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -56,7 +56,7 @@ TEST_CASE( "selftest/main", "Runs all Catch self tests and checks their results"
 | 
			
		||||
        {
 | 
			
		||||
            runner.runMatching( "./failing/*" );        
 | 
			
		||||
            CHECK( runner.getSuccessCount() == 0 );
 | 
			
		||||
            CHECK( runner.getFailureCount() == 62 );
 | 
			
		||||
            CHECK( runner.getFailureCount() == 64 );
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,5 @@
 | 
			
		||||
<?xml version="1.0" encoding="UTF-8"?>
 | 
			
		||||
<Bucket
 | 
			
		||||
   type = "1"
 | 
			
		||||
   version = "1.0">
 | 
			
		||||
</Bucket>
 | 
			
		||||
@@ -55,6 +55,12 @@
 | 
			
		||||
            ReferencedContainer = "container:CatchSelfTest.xcodeproj">
 | 
			
		||||
         </BuildableReference>
 | 
			
		||||
      </BuildableProductRunnable>
 | 
			
		||||
      <CommandLineArguments>
 | 
			
		||||
         <CommandLineArgument
 | 
			
		||||
            argument = "-t ./succeeding/message/sections/stdout"
 | 
			
		||||
            isEnabled = "NO">
 | 
			
		||||
         </CommandLineArgument>
 | 
			
		||||
      </CommandLineArguments>
 | 
			
		||||
      <AdditionalOptions>
 | 
			
		||||
      </AdditionalOptions>
 | 
			
		||||
   </LaunchAction>
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user