From 3043ddf1445de03556564917e01a4f9748b04d89 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 27 Feb 2009 16:28:07 -0500 Subject: [PATCH] BUG: #8611 add pass fail reasons into log file --- Source/CTest/cmCTestTestHandler.cxx | 60 ++++++++++++++++++++--------- 1 file changed, 42 insertions(+), 18 deletions(-) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 7cd2839e7..a7a4c6f94 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -761,24 +761,7 @@ void cmCTestTestHandler::ProcessOneTest(cmCTestTestProperties *it, clock_finish = cmSystemTools::GetTime(); - if ( this->LogFile ) - { - double ttime = clock_finish - clock_start; - int hours = static_cast(ttime / (60 * 60)); - int minutes = static_cast(ttime / 60) % 60; - int seconds = static_cast(ttime) % 60; - char buffer[100]; - sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds); - *this->LogFile - << "----------------------------------------------------------" - << std::endl - << "\"" << testname.c_str() << "\" end time: " - << this->CTest->CurrentTime() << std::endl - << "\"" << testname.c_str() << "\" time elapsed: " - << buffer << std::endl - << "----------------------------------------------------------" - << std::endl << std::endl; - } + cres.ExecutionTime = (double)(clock_finish - clock_start); cres.FullCommandLine = testCommand; @@ -949,6 +932,47 @@ void cmCTestTestHandler::ProcessOneTest(cmCTestTestProperties *it, } } cres.Reason = reason; + if ( this->LogFile ) + { + bool pass = true; + const char* reasonType = "Test Pass Reason"; + if(cres.Status != cmCTestTestHandler::COMPLETED && + cres.Status != cmCTestTestHandler::NOT_RUN) + { + reasonType = "Test Fail Reason"; + pass = false; + } + double ttime = clock_finish - clock_start; + int hours = static_cast(ttime / (60 * 60)); + int minutes = static_cast(ttime / 60) % 60; + int seconds = static_cast(ttime) % 60; + char buffer[100]; + sprintf(buffer, "%02d:%02d:%02d", hours, minutes, seconds); + *this->LogFile + << "----------------------------------------------------------" + << std::endl; + if(cres.Reason.size()) + { + *this->LogFile << reasonType << ":\n" << cres.Reason << "\n"; + } + else + { + if(pass) + { + *this->LogFile << "Test Passed.\n"; + } + else + { + *this->LogFile << "Test Failed.\n"; + } + } + *this->LogFile << "\"" << testname.c_str() << "\" end time: " + << this->CTest->CurrentTime() << std::endl + << "\"" << testname.c_str() << "\" time elapsed: " + << buffer << std::endl + << "----------------------------------------------------------" + << std::endl << std::endl; + } cres.Output = output; cres.ReturnValue = retVal; cres.CompletionStatus = "Completed";