Add label summary times to ctest default output. Also, remove parallel time output. Add flag to disable label summary.

This commit is contained in:
Bill Hoffman 2009-09-11 13:34:35 -04:00
parent 6a7eae7184
commit 8a690289c2
4 changed files with 43 additions and 20 deletions

View File

@ -589,25 +589,15 @@ int cmCTestTestHandler::ProcessHandler()
<< static_cast<int>(percent + .5) << "% tests passed, " << static_cast<int>(percent + .5) << "% tests passed, "
<< failed.size() << " tests failed out of " << failed.size() << " tests failed out of "
<< total << std::endl); << total << std::endl);
double totalTestTime = 0; if(this->CTest->GetLabelSummary())
for(cmCTestTestHandler::TestResultsVector::size_type cc = 0;
cc < this->TestResults.size(); cc ++ )
{ {
cmCTestTestResult *result = &this->TestResults[cc]; this->PrintLabelSummary();
totalTestTime += result->ExecutionTime;
} }
char realBuf[1024]; char realBuf[1024];
sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start)); sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start));
cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time (real) = " cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time (real) = "
<< realBuf << "\n" ); << 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()) if (failed.size())
{ {
cmGeneratedFileStream ofs; cmGeneratedFileStream ofs;
@ -672,6 +662,7 @@ void cmCTestTestHandler::PrintLabelSummary()
std::map<cmStdString, double> labelTimes; std::map<cmStdString, double> labelTimes;
std::set<cmStdString> labels; std::set<cmStdString> labels;
// initialize maps // initialize maps
std::string::size_type maxlen = 0;
for(; it != this->TestList.end(); ++it) for(; it != this->TestList.end(); ++it)
{ {
cmCTestTestProperties& p = *it; cmCTestTestProperties& p = *it;
@ -680,6 +671,10 @@ void cmCTestTestHandler::PrintLabelSummary()
for(std::vector<std::string>::iterator l = p.Labels.begin(); for(std::vector<std::string>::iterator l = p.Labels.begin();
l != p.Labels.end(); ++l) l != p.Labels.end(); ++l)
{ {
if((*l).size() > maxlen)
{
maxlen = (*l).size();
}
labels.insert(*l); labels.insert(*l);
labelTimes[*l] = 0; labelTimes[*l] = 0;
} }
@ -696,23 +691,40 @@ void cmCTestTestHandler::PrintLabelSummary()
{ {
for(std::vector<std::string>::iterator l = p.Labels.begin(); for(std::vector<std::string>::iterator l = p.Labels.begin();
l != p.Labels.end(); ++l) l != p.Labels.end(); ++l)
{ {
labelTimes[*l] += result.ExecutionTime; labelTimes[*l] += result.ExecutionTime;
} }
} }
} }
// now print times // now print times
if(labels.size())
{
cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nLabel Time Summary:");
}
for(std::set<cmStdString>::const_iterator i = labels.begin(); for(std::set<cmStdString>::const_iterator i = labels.begin();
i != labels.end(); ++i) i != labels.end(); ++i)
{ {
cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTime in " std::string label = *i;
<< *i << " = " << labelTimes[*i] << " sec" ); 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 ) if ( this->LogFile )
{ {
*this->LogFile << "\nTime in " << *i << " = " *this->LogFile << "\n" << *i << " = "
<< labelTimes[*i] << " sec" << std::endl; << buf << "\n";
} }
} }
if(labels.size())
{
if(this->LogFile)
{
*this->LogFile << "\n";
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, "\n");
}
} }
//---------------------------------------------------------------------- //----------------------------------------------------------------------

View File

@ -208,6 +208,7 @@ std::string cmCTest::DecodeURL(const std::string& in)
//---------------------------------------------------------------------- //----------------------------------------------------------------------
cmCTest::cmCTest() cmCTest::cmCTest()
{ {
this->LabelSummary = true;
this->ParallelLevel = 1; this->ParallelLevel = 1;
this->SubmitIndex = 0; this->SubmitIndex = 0;
this->Failover = false; this->Failover = false;
@ -1738,6 +1739,10 @@ void cmCTest::HandleCommandLineArguments(size_t &i,
{ {
this->ShowLineNumbers = true; this->ShowLineNumbers = true;
} }
if(this->CheckArgument(arg, "--no-label-summary"))
{
this->LabelSummary = false;
}
if(this->CheckArgument(arg, "-Q", "--quiet")) if(this->CheckArgument(arg, "-Q", "--quiet"))
{ {
this->Quiet = true; this->Quiet = true;

View File

@ -376,11 +376,13 @@ public:
void SetStreams(std::ostream* out, std::ostream* err) void SetStreams(std::ostream* out, std::ostream* err)
{ this->StreamOut = out; this->StreamErr = err; } { this->StreamOut = out; this->StreamErr = err; }
void AddSiteProperties(std::ostream& ); void AddSiteProperties(std::ostream& );
bool GetLabelSummary() { return this->LabelSummary;}
private: private:
std::string ConfigType; std::string ConfigType;
bool Verbose; bool Verbose;
bool ExtraVerbose; bool ExtraVerbose;
bool ProduceXML; bool ProduceXML;
bool LabelSummary;
bool Failover; bool Failover;
bool BatchJobs; bool BatchJobs;

View File

@ -156,6 +156,10 @@ static const char * cmDocumentationOptions[][3] =
"When just running tests not for a dashboard the default is to allow " "When just running tests not for a dashboard the default is to allow "
"popups and interactive " "popups and interactive "
"debugging."}, "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.", {"--build-and-test", "Configure, build and run a test.",
"This option tells ctest to configure (i.e. run cmake on), build, and or " "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 " "execute a test. The configure and test steps are optional. The arguments "