From 3c34d0440c8c83124d991850535e69af6ccc684e Mon Sep 17 00:00:00 2001 From: Bill Hoffman Date: Tue, 18 Aug 2009 13:34:05 -0400 Subject: If labels are found on the tests, then print a time summary for all the tests run with each label. --- Source/CTest/cmCTestTestHandler.cxx | 49 ++++++++++++++++++++++++++++++++++++- Source/CTest/cmCTestTestHandler.h | 1 + 2 files changed, 49 insertions(+), 1 deletion(-) diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index 3407048..37de4f9 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -589,7 +589,7 @@ int cmCTestTestHandler::ProcessHandler() cmCTestTestResult *result = &this->TestResults[cc]; totalTestTime += result->ExecutionTime; } - + this->PrintLabelSummary(); char buf[1024]; sprintf(buf, "%6.2f sec", totalTestTime); cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time = " @@ -657,6 +657,53 @@ int cmCTestTestHandler::ProcessHandler() } //---------------------------------------------------------------------- +void cmCTestTestHandler::PrintLabelSummary() +{ + cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin(); + cmCTestTestHandler::TestResultsVector::iterator ri = + this->TestResults.begin(); + std::map labelTimes; + std::set labels; + // initialize maps + for(; it != this->TestList.end(); ++it) + { + cmCTestTestProperties& p = *it; + if(p.Labels.size() != 0) + { + for(std::vector::iterator l = p.Labels.begin(); + l != p.Labels.end(); ++l) + { + labels.insert(*l); + labelTimes[*l] = 0; + } + } + } + it = this->TestList.begin(); + ri = this->TestResults.begin(); + // fill maps + for(; it != this->TestList.end(); ++it, ++ri) + { + cmCTestTestProperties& p = *it; + cmCTestTestResult &result = *ri; + if(p.Labels.size() != 0) + { + for(std::vector::iterator l = p.Labels.begin(); + l != p.Labels.end(); ++l) + { + labelTimes[*l] += result.ExecutionTime; + } + } + } + // now print times + for(std::set::const_iterator i = labels.begin(); + i != labels.end(); ++i) + { + cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTime in " + << *i << " = " << labelTimes[*i] << " sec" ); + } +} + +//---------------------------------------------------------------------- void cmCTestTestHandler::ProcessOneTest(cmCTestTestProperties *it, std::vector &passed, std::vector &failed, diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index e5ee5dc..b0188e1 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -185,6 +185,7 @@ private: */ virtual void GenerateDartOutput(std::ostream& os); + void PrintLabelSummary(); /** * Run the tests for a directory and any subdirectories */ -- cgit v0.12