summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBetsy McPhail <betsy.mcphail@kitware.com>2017-06-23 17:03:05 (GMT)
committerBrad King <brad.king@kitware.com>2017-07-10 20:25:18 (GMT)
commit47b3a57c9bc5c7db608bc3b59b139a902535255f (patch)
tree127d1fc54ab81e5f69848772c74b46af5a15c5ad
parentd385962419ea3109dd21093c2368379f5fb51722 (diff)
downloadCMake-47b3a57c9bc5c7db608bc3b59b139a902535255f.zip
CMake-47b3a57c9bc5c7db608bc3b59b139a902535255f.tar.gz
CMake-47b3a57c9bc5c7db608bc3b59b139a902535255f.tar.bz2
Display subproject timing summary
Use the '--no-subproject-summary' option to disable timing summary.
-rw-r--r--Help/manual/ctest.1.rst7
-rw-r--r--Source/CTest/cmCTestTestHandler.cxx85
-rw-r--r--Source/CTest/cmCTestTestHandler.h2
-rw-r--r--Source/cmCTest.cxx4
-rw-r--r--Source/cmCTest.h3
-rw-r--r--Source/ctest.cxx2
6 files changed, 102 insertions, 1 deletions
diff --git a/Help/manual/ctest.1.rst b/Help/manual/ctest.1.rst
index 16529e2..03466ce 100644
--- a/Help/manual/ctest.1.rst
+++ b/Help/manual/ctest.1.rst
@@ -250,6 +250,13 @@ Options
label associated with the tests run. If there are no labels on the
tests, nothing extra is printed.
+ ``--no-subproject-summary``
+ Disable timing summary information for subprojects.
+
+ This option tells ctest not to print summary information for each
+ subproject associated with the tests run. If there are no subprojects on the
+ tests, nothing extra is printed.
+
``--build-and-test <path-to-source> <path-to-build>``
Configure, build and run a test.
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
*/
diff --git a/Source/cmCTest.cxx b/Source/cmCTest.cxx
index 1eedaf1..dfd7d6b 100644
--- a/Source/cmCTest.cxx
+++ b/Source/cmCTest.cxx
@@ -253,6 +253,7 @@ std::string cmCTest::DecodeURL(const std::string& in)
cmCTest::cmCTest()
{
this->LabelSummary = true;
+ this->SubprojectSummary = true;
this->ParallelLevel = 1;
this->ParallelLevelSetInCli = false;
this->TestLoad = 0;
@@ -1794,6 +1795,9 @@ bool cmCTest::HandleCommandLineArguments(size_t& i,
if (this->CheckArgument(arg, "--no-label-summary")) {
this->LabelSummary = false;
}
+ if (this->CheckArgument(arg, "--no-subproject-summary")) {
+ this->SubprojectSummary = false;
+ }
if (this->CheckArgument(arg, "-Q", "--quiet")) {
this->Quiet = true;
}
diff --git a/Source/cmCTest.h b/Source/cmCTest.h
index 190269a..0d2a903 100644
--- a/Source/cmCTest.h
+++ b/Source/cmCTest.h
@@ -438,7 +438,9 @@ public:
this->StreamErr = err;
}
void AddSiteProperties(cmXMLWriter& xml);
+
bool GetLabelSummary() { return this->LabelSummary; }
+ bool GetSubprojectSummary() { return this->SubprojectSummary; }
std::string GetCostDataFile();
@@ -467,6 +469,7 @@ private:
bool ExtraVerbose;
bool ProduceXML;
bool LabelSummary;
+ bool SubprojectSummary;
bool UseHTTP10;
bool PrintLabels;
bool Failover;
diff --git a/Source/ctest.cxx b/Source/ctest.cxx
index 84e815d..8f9e676 100644
--- a/Source/ctest.cxx
+++ b/Source/ctest.cxx
@@ -83,6 +83,8 @@ static const char* cmDocumentationOptions[][2] = {
{ "--max-width <width>", "Set the max width for a test name to output" },
{ "--interactive-debug-mode [0|1]", "Set the interactive mode to 0 or 1." },
{ "--no-label-summary", "Disable timing summary information for labels." },
+ { "--no-subproject-summary", "Disable timing summary information for "
+ "subprojects." },
{ "--build-and-test", "Configure, build and run a test." },
{ "--build-target", "Specify a specific target to build." },
{ "--build-nocmake", "Run the build without running cmake first." },