From: asl Date: Thu, 7 Sep 2017 06:13:31 +0000 (+0300) Subject: additional information about failed tests X-Git-Tag: v2.1~66^2~27 X-Git-Url: http://git.salome-platform.org/gitweb/?a=commitdiff_plain;h=1e7682bc94c851f895752aa9b36afad3be68c3d4;p=modules%2Fhydro.git additional information about failed tests --- diff --git a/src/HYDRO_tests/TestLib_Listener.cxx b/src/HYDRO_tests/TestLib_Listener.cxx index 593c8d6e..7c79e858 100644 --- a/src/HYDRO_tests/TestLib_Listener.cxx +++ b/src/HYDRO_tests/TestLib_Listener.cxx @@ -18,7 +18,10 @@ #include #include +#include +#include #include +#include #ifdef WIN32 #include @@ -69,7 +72,7 @@ INT64 GetTimeForCurrentThreadInMs() \brief Constructor */ TestLib_Listener::TestLib_Listener() -: myStart( 0 ), myComplete( 0 ) +: myStart( 0 ), myComplete( 0 ), myNbTests( 0 ), myNbSuites( 0 ) { } @@ -122,6 +125,18 @@ void TestLib_Listener::endTest( CppUnit::Test* theTest ) INT64 anExecTimeMS = aCurTime - myStart; myComplete += anExecTimeMS; std::cout << " " << anExecTimeMS << " ms" << std::endl; + + myNbTests++; +} + +int TestLib_Listener::GetNbTests() const +{ + return myNbTests; +} + +int TestLib_Listener::GetNbSuites() const +{ + return myNbSuites; } /** @@ -138,6 +153,7 @@ void TestLib_Listener::startSuite( CppUnit::Test* theTest ) */ void TestLib_Listener::endSuite( CppUnit::Test* theTest ) { + myNbSuites++; } /** @@ -146,5 +162,27 @@ void TestLib_Listener::endSuite( CppUnit::Test* theTest ) */ void TestLib_Listener::addFailure( const CppUnit::TestFailure& theFailure ) { + std::string failedTest = theFailure.failedTest()->getName(); + CppUnit::SourceLine failedLocation = theFailure.sourceLine(); + + QString aFile = QString::fromStdString( failedLocation.fileName() ); + aFile.replace( '\\', '/' ); + QStringList parts = aFile.split( '/' ); + aFile = parts.last(); + std::string cFile = aFile.toStdString(); + + int aLine = failedLocation.lineNumber(); + + static char aBuf[1024]; + sprintf( aBuf, "Failed %s: %s : %i", failedTest.c_str(), cFile.c_str(), aLine ); + + myFailures.push_back( aBuf ); } +void TestLib_Listener::DumpFailures() +{ + int n = (int)myFailures.size(); + printf( "FAILED TESTS: %i\n", n ); + for( int i=0; i +#include +#include typedef long long INT64; ///< the cross-platform type definition for 64-bits integer @@ -34,6 +36,9 @@ public: void Clear(); INT64 GetCompleteTimeInMS() const; + int GetNbTests() const; + int GetNbSuites() const; + void DumpFailures(); virtual void startTest( CppUnit::Test* ); virtual void endTest( CppUnit::Test* ); @@ -46,5 +51,8 @@ public: private: INT64 myStart; ///< start time in milliseconds INT64 myComplete; ///< complete time of all tests execution in milliseconds + int myNbTests; + int myNbSuites; + std::vector myFailures; }; diff --git a/src/HYDRO_tests/test_HYDROData_Main.cxx b/src/HYDRO_tests/test_HYDROData_Main.cxx index fe430bfd..ac9ded23 100644 --- a/src/HYDRO_tests/test_HYDROData_Main.cxx +++ b/src/HYDRO_tests/test_HYDROData_Main.cxx @@ -90,14 +90,24 @@ int main( int argc, char* argv[] ) return 0; } bool isOK = result.wasSuccessful(); + +#ifndef WIN32 DEBTRACE("End of tests"); +#endif + aWindow->close(); aSession.closeSession(); anApp.exit(!isOK); + +#ifndef WIN32 DEBTRACE("--- TODO: exception on exit..."); // TODO: exception on exit... +#endif int ms = progress.GetCompleteTimeInMS(); + printf( "\n\n" ); + printf( "%i TESTS in %i SUITES\n", progress.GetNbTests(), progress.GetNbSuites() ); printf( "COMPLETE TESTS TIME: %i ms\n", ms ); + progress.DumpFailures(); return result.wasSuccessful() ? 0 : 1; }