mirror of
				https://github.com/catchorg/Catch2.git
				synced 2025-10-31 20:27:11 +01:00 
			
		
		
		
	Merge branch 'master' into dev-modernize
This commit is contained in:
		| @@ -90,7 +90,7 @@ namespace Catch { | ||||
|             if( lastDot != std::string::npos ) | ||||
|                 filename = filename.substr( 0, lastDot ); | ||||
|  | ||||
|             tags.push_back( "#" + filename ); | ||||
|             tags.push_back( '#' + filename ); | ||||
|             setTags( testCase, tags ); | ||||
|         } | ||||
|     } | ||||
|   | ||||
| @@ -18,6 +18,19 @@ namespace Catch { | ||||
|         m_stream.rdbuf(m_prevBuf); | ||||
|     } | ||||
|  | ||||
|     StdErrRedirect::StdErrRedirect(std::string & targetString) | ||||
|         :m_cerrBuf(cerr().rdbuf()), m_clogBuf(clog().rdbuf()), | ||||
|         m_targetString(targetString) { | ||||
|         cerr().rdbuf(m_oss.rdbuf()); | ||||
|         clog().rdbuf(m_oss.rdbuf()); | ||||
|     } | ||||
|  | ||||
|     StdErrRedirect::~StdErrRedirect() { | ||||
|         m_targetString += m_oss.str(); | ||||
|         cerr().rdbuf(m_cerrBuf); | ||||
|         clog().rdbuf(m_clogBuf); | ||||
|     } | ||||
|  | ||||
|     RunContext::RunContext(IConfigPtr const& _config, IStreamingReporterPtr&& reporter) | ||||
|         : m_runInfo(_config->name()), | ||||
|         m_context(getCurrentMutableContext()), | ||||
| @@ -256,7 +269,7 @@ namespace Catch { | ||||
|             timer.start(); | ||||
|             if (m_reporter->getPreferences().shouldRedirectStdOut) { | ||||
|                 StreamRedirect coutRedir(cout(), redirectedCout); | ||||
|                 StreamRedirect cerrRedir(cerr(), redirectedCerr); | ||||
|                 StdErrRedirect errRedir(redirectedCerr); | ||||
|                 invokeActiveTestCase(); | ||||
|             } else { | ||||
|                 invokeActiveTestCase(); | ||||
| @@ -318,5 +331,4 @@ namespace Catch { | ||||
|         else | ||||
|             CATCH_INTERNAL_ERROR("No result capture instance"); | ||||
|     } | ||||
|  | ||||
| } | ||||
| @@ -40,6 +40,20 @@ namespace Catch { | ||||
|         std::string& m_targetString; | ||||
|     }; | ||||
|  | ||||
|     // StdErr has two constituent streams in C++, std::cerr and std::clog | ||||
|     // This means that we need to redirect 2 streams into 1 to keep proper | ||||
|     // order of writes and cannot use StreamRedirect on its own | ||||
|     class StdErrRedirect { | ||||
|     public: | ||||
|         StdErrRedirect(std::string& targetString); | ||||
|         ~StdErrRedirect(); | ||||
|     private: | ||||
|         std::streambuf* m_cerrBuf; | ||||
|         std::streambuf* m_clogBuf; | ||||
|         std::ostringstream m_oss; | ||||
|         std::string& m_targetString; | ||||
|     }; | ||||
|  | ||||
|     /////////////////////////////////////////////////////////////////////////// | ||||
|  | ||||
|     class RunContext : public IResultCapture, public IRunner { | ||||
|   | ||||
| @@ -20,6 +20,7 @@ namespace Catch { | ||||
|  | ||||
|     std::ostream& cout(); | ||||
|     std::ostream& cerr(); | ||||
|     std::ostream& clog(); | ||||
|  | ||||
|  | ||||
|     struct IStream { | ||||
|   | ||||
| @@ -101,6 +101,9 @@ namespace Catch { | ||||
|     std::ostream& cerr() { | ||||
|         return std::cerr; | ||||
|     } | ||||
|     std::ostream& clog() { | ||||
|         return std::clog; | ||||
|     } | ||||
| #endif | ||||
| } | ||||
|  | ||||
|   | ||||
| @@ -51,7 +51,7 @@ struct AutoReg : NonCopyable { | ||||
|     #define INTERNAL_CATCH_TESTCASE2( TestName, ... ) \ | ||||
|         static void TestName(); \ | ||||
|         CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ | ||||
|         namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, "", Catch::NameAndTags{ __VA_ARGS__ } ); } \ | ||||
|         namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &TestName ), CATCH_INTERNAL_LINEINFO, "", Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ | ||||
|         CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ | ||||
|         static void TestName() | ||||
|     #define INTERNAL_CATCH_TESTCASE( ... ) \ | ||||
| @@ -60,7 +60,7 @@ struct AutoReg : NonCopyable { | ||||
|     /////////////////////////////////////////////////////////////////////////////// | ||||
|     #define INTERNAL_CATCH_METHOD_AS_TEST_CASE( QualifiedMethod, ... ) \ | ||||
|         CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ | ||||
|         namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } \ | ||||
|         namespace{ Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar )( Catch::makeTestInvoker( &QualifiedMethod ), CATCH_INTERNAL_LINEINFO, "&" #QualifiedMethod, Catch::NameAndTags{ __VA_ARGS__ } ); } /* NOLINT */ \ | ||||
|         CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS | ||||
|  | ||||
|     /////////////////////////////////////////////////////////////////////////////// | ||||
| @@ -70,7 +70,7 @@ struct AutoReg : NonCopyable { | ||||
|             struct TestName : ClassName{ \ | ||||
|                 void test(); \ | ||||
|             }; \ | ||||
|             Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); \ | ||||
|             Catch::AutoReg INTERNAL_CATCH_UNIQUE_NAME( autoRegistrar ) ( Catch::makeTestInvoker( &TestName::test ), CATCH_INTERNAL_LINEINFO, #ClassName, Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ | ||||
|         } \ | ||||
|         CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS \ | ||||
|         void TestName::test() | ||||
| @@ -80,7 +80,7 @@ struct AutoReg : NonCopyable { | ||||
|     /////////////////////////////////////////////////////////////////////////////// | ||||
|     #define INTERNAL_CATCH_REGISTER_TESTCASE( Function, ... ) \ | ||||
|         CATCH_INTERNAL_SUPPRESS_ETD_WARNINGS \ | ||||
|         Catch::AutoReg( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, "", Catch::NameAndTags{ __VA_ARGS__ } ); \ | ||||
|         Catch::AutoReg( Catch::makeTestInvoker( Function ), CATCH_INTERNAL_LINEINFO, "", Catch::NameAndTags{ __VA_ARGS__ } ); /* NOLINT */ \ | ||||
|         CATCH_INTERNAL_UNSUPPRESS_ETD_WARNINGS | ||||
|  | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 Martin Hořeňovský
					Martin Hořeňovský