diff options
author | Betsy McPhail <betsy.mcphail@kitware.com> | 2017-06-23 17:03:05 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2017-07-10 20:25:18 (GMT) |
commit | 47b3a57c9bc5c7db608bc3b59b139a902535255f (patch) | |
tree | 127d1fc54ab81e5f69848772c74b46af5a15c5ad /Source/CTest | |
parent | d385962419ea3109dd21093c2368379f5fb51722 (diff) | |
download | CMake-47b3a57c9bc5c7db608bc3b59b139a902535255f.zip CMake-47b3a57c9bc5c7db608bc3b59b139a902535255f.tar.gz CMake-47b3a57c9bc5c7db608bc3b59b139a902535255f.tar.bz2 |
Display subproject timing summary
Use the '--no-subproject-summary' option to disable timing summary.
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 85 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 2 |
2 files changed, 86 insertions, 1 deletions
diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index b0e799c..63d696f 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -536,9 +536,14 @@ int cmCTestTestHandler::ProcessHandler() << static_cast<int>(percent + .5f) << "% tests passed, " << failed.size() << " tests failed out of " << total << std::endl); - if (this->CTest->GetLabelSummary()) { + + if (!this->CTest->GetLabelsForSubprojects().empty() && + this->CTest->GetSubprojectSummary()) { + this->PrintSubprojectSummary(); + } else if (this->CTest->GetLabelSummary()) { this->PrintLabelSummary(); } + char realBuf[1024]; sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start)); cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, @@ -688,6 +693,84 @@ void cmCTestTestHandler::PrintLabelSummary() } } +void cmCTestTestHandler::PrintSubprojectSummary() +{ + std::vector<std::string> subprojects = + this->CTest->GetLabelsForSubprojects(); + + cmCTestTestHandler::ListOfTests::iterator it = this->TestList.begin(); + std::map<std::string, double> labelTimes; + std::map<std::string, int> labelCounts; + std::set<std::string> labels; + // initialize maps + std::string::size_type maxlen = 0; + for (; it != this->TestList.end(); ++it) { + cmCTestTestProperties& p = *it; + for (std::vector<std::string>::iterator l = p.Labels.begin(); + l != p.Labels.end(); ++l) { + std::vector<std::string>::iterator subproject = + std::find(subprojects.begin(), subprojects.end(), *l); + if (subproject != subprojects.end()) { + if ((*l).size() > maxlen) { + maxlen = (*l).size(); + } + labels.insert(*l); + labelTimes[*l] = 0; + labelCounts[*l] = 0; + } + } + } + cmCTestTestHandler::TestResultsVector::iterator ri = + this->TestResults.begin(); + // fill maps + for (; ri != this->TestResults.end(); ++ri) { + cmCTestTestResult& result = *ri; + cmCTestTestProperties& p = *result.Properties; + for (std::vector<std::string>::iterator l = p.Labels.begin(); + l != p.Labels.end(); ++l) { + std::vector<std::string>::iterator subproject = + std::find(subprojects.begin(), subprojects.end(), *l); + if (subproject != subprojects.end()) { + labelTimes[*l] += result.ExecutionTime; + ++labelCounts[*l]; + } + } + } + // now print times + if (!labels.empty()) { + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, + "\nSubproject Time Summary:", this->Quiet); + } + for (std::set<std::string>::const_iterator i = labels.begin(); + i != labels.end(); ++i) { + std::string label = *i; + label.resize(maxlen + 3, ' '); + + char buf[1024]; + sprintf(buf, "%6.2f sec", labelTimes[*i]); + + std::ostringstream labelCountStr; + labelCountStr << "(" << labelCounts[*i] << " test"; + if (labelCounts[*i] > 1) { + labelCountStr << "s"; + } + labelCountStr << ")"; + + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n" + << label << " = " << buf << " " + << labelCountStr.str(), + this->Quiet); + if (this->LogFile) { + *this->LogFile << "\n" << *i << " = " << buf << "\n"; + } + } + if (!labels.empty()) { + if (this->LogFile) { + *this->LogFile << "\n"; + } + cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "\n", this->Quiet); + } +} void cmCTestTestHandler::CheckLabelFilterInclude(cmCTestTestProperties& it) { // if not using Labels to filter then return diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index a623984..b82e382 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -232,6 +232,8 @@ private: virtual void GenerateDartOutput(cmXMLWriter& xml); void PrintLabelSummary(); + void PrintSubprojectSummary(); + /** * Run the tests for a directory and any subdirectories */ |