From 8a690289c205da90133e704439dc6f7ef1a08680 Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Fri, 11 Sep 2009 13:34:35 -0400 Subject: [PATCH] Add label summary times to ctest default output. Also, remove parallel time output. Add flag to disable label summary. --- Source/CTest/cmCTestTestHandler.cxx | 52 ++++++++++++++++++----------- Source/cmCTest.cxx | 5 +++ Source/cmCTest.h | 2 ++ Source/ctest.cxx | 4 +++ 4 files changed, 43 insertions(+), 20 deletions(-) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index c6af20d76f..6e718dab1c 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -589,25 +589,15 @@ int cmCTestTestHandler::ProcessHandler() << static_cast(percent + .5) << "% tests passed, " << failed.size() << " tests failed out of " << total << std::endl); - double totalTestTime = 0; - - for(cmCTestTestHandler::TestResultsVector::size_type cc = 0; - cc < this->TestResults.size(); cc ++ ) + if(this->CTest->GetLabelSummary()) { - cmCTestTestResult *result = &this->TestResults[cc]; - totalTestTime += result->ExecutionTime; + this->PrintLabelSummary(); } - char realBuf[1024]; sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start)); cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time (real) = " << realBuf << "\n" ); - char totalBuf[1024]; - sprintf(totalBuf, "%6.2f sec", totalTestTime); - cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time (parallel) = " - << totalBuf << "\n" ); - if (failed.size()) { cmGeneratedFileStream ofs; @@ -672,6 +662,7 @@ void cmCTestTestHandler::PrintLabelSummary() std::map labelTimes; std::set labels; // initialize maps + std::string::size_type maxlen = 0; for(; it != this->TestList.end(); ++it) { cmCTestTestProperties& p = *it; @@ -680,6 +671,10 @@ void cmCTestTestHandler::PrintLabelSummary() for(std::vector::iterator l = p.Labels.begin(); l != p.Labels.end(); ++l) { + if((*l).size() > maxlen) + { + maxlen = (*l).size(); + } labels.insert(*l); labelTimes[*l] = 0; } @@ -696,23 +691,40 @@ void cmCTestTestHandler::PrintLabelSummary() { for(std::vector::iterator l = p.Labels.begin(); l != p.Labels.end(); ++l) - { + { labelTimes[*l] += result.ExecutionTime; } } } - // now print times + // now print times + if(labels.size()) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:"); + } for(std::set::const_iterator i = labels.begin(); i != labels.end(); ++i) { - cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTime in " - << *i << " = " << labelTimes[*i] << " sec" ); + std::string label = *i; + label.resize(maxlen +3, ' '); + char buf[1024]; + sprintf(buf, "%6.2f sec", labelTimes[*i]); + cmCTestLog(this->CTest, HANDLER_OUTPUT, "\n" + << label << " = " << buf ); if ( this->LogFile ) - { - *this->LogFile << "\nTime in " << *i << " = " - << labelTimes[*i] << " sec" << std::endl; - } + { + *this->LogFile << "\n" << *i << " = " + << buf << "\n"; + } } + if(labels.size()) + { + if(this->LogFile) + { + *this->LogFile << "\n"; + } + cmCTestLog(this->CTest, HANDLER_OUTPUT, "\n"); + } + } //---------------------------------------------------------------------- diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx index d06a4a74f3..a8086b69e8 100644 --- a/Source/cmCTest.cxx +++ b/Source/cmCTest.cxx @@ -208,6 +208,7 @@ std::string cmCTest::DecodeURL(const std::string& in) //---------------------------------------------------------------------- cmCTest::cmCTest() { + this->LabelSummary = true; this->ParallelLevel = 1; this->SubmitIndex = 0; this->Failover = false; @@ -1738,6 +1739,10 @@ void cmCTest::HandleCommandLineArguments(size_t &i, { this->ShowLineNumbers = true; } + if(this->CheckArgument(arg, "--no-label-summary")) + { + this->LabelSummary = false; + } if(this->CheckArgument(arg, "-Q", "--quiet")) { this->Quiet = true; diff --git a/Source/cmCTest.h b/Source/cmCTest.h index 8ee837f02f..77bce1a6c6 100644 --- a/Source/cmCTest.h +++ b/Source/cmCTest.h @@ -376,11 +376,13 @@ public: void SetStreams(std::ostream* out, std::ostream* err) { this->StreamOut = out; this->StreamErr = err; } void AddSiteProperties(std::ostream& ); + bool GetLabelSummary() { return this->LabelSummary;} private: std::string ConfigType; bool Verbose; bool ExtraVerbose; bool ProduceXML; + bool LabelSummary; bool Failover; bool BatchJobs; diff --git a/Source/ctest.cxx b/Source/ctest.cxx index 9cb0aab0aa..763e9bd45e 100644 --- a/Source/ctest.cxx +++ b/Source/ctest.cxx @@ -156,6 +156,10 @@ static const char * cmDocumentationOptions[][3] = "When just running tests not for a dashboard the default is to allow " "popups and interactive " "debugging."}, + {"--no-label-summary", "Disable timing summary information for labels.", + "This option tells ctest to not print summary information for each label " + "associated with the tests run. If there are no labels on the " + "tests, nothing extra is printed."}, {"--build-and-test", "Configure, build and run a test.", "This option tells ctest to configure (i.e. run cmake on), build, and or " "execute a test. The configure and test steps are optional. The arguments "