diff options
author | Brad King <brad.king@kitware.com> | 2009-02-02 18:24:26 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-02-02 18:24:26 (GMT) |
commit | cc2092d5bb282dd4010b11a289638a243f7961e2 (patch) | |
tree | 33ce2e212a858631d55e87a68dd3b99d1cab99db /Source/CTest | |
parent | eea054d82c13430bff4eba800f02a73396b73af2 (diff) | |
download | CMake-cc2092d5bb282dd4010b11a289638a243f7961e2.zip CMake-cc2092d5bb282dd4010b11a289638a243f7961e2.tar.gz CMake-cc2092d5bb282dd4010b11a289638a243f7961e2.tar.bz2 |
ENH: Put test labels in MemCheck results
This refactors generation of <Test> element headers and footers in
cmCTestTestHandler and re-uses it in cmCTestMemCheckHandler. The change
removes duplicate code and enables the new <Labels> element for MemCheck
results.
Diffstat (limited to 'Source/CTest')
-rw-r--r-- | Source/CTest/cmCTestMemCheckHandler.cxx | 30 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.cxx | 91 | ||||
-rw-r--r-- | Source/CTest/cmCTestTestHandler.h | 3 |
3 files changed, 59 insertions, 65 deletions
diff --git a/Source/CTest/cmCTestMemCheckHandler.cxx b/Source/CTest/cmCTestMemCheckHandler.cxx index 31af3ce..97a6ee0 100644 --- a/Source/CTest/cmCTestMemCheckHandler.cxx +++ b/Source/CTest/cmCTestMemCheckHandler.cxx @@ -337,30 +337,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) } this->CleanTestOutput(memcheckstr, static_cast<size_t>(this->CustomMaximumFailedTestOutputSize)); - os << "\t<Test Status=\""; - if ( result->Status == cmCTestMemCheckHandler::COMPLETED ) - { - os << "passed"; - } - else if ( result->Status == cmCTestMemCheckHandler::NOT_RUN ) - { - os << "notrun"; - } - else - { - os << "failed"; - } - std::string testPath = result->Path + "/" + result->Name; - os << "\">\n" - << "\t\t<Name>" << cmCTest::MakeXMLSafe(result->Name) << "</Name>\n" - << "\t\t<Path>" << cmCTest::MakeXMLSafe( - this->CTest->GetShortPathToFile(result->Path.c_str())) << "</Path>\n" - << "\t\t<FullName>" << cmCTest::MakeXMLSafe( - this->CTest->GetShortPathToFile(testPath.c_str())) << "</FullName>\n" - << "\t\t<FullCommandLine>" - << cmCTest::MakeXMLSafe(result->FullCommandLine) - << "</FullCommandLine>\n" - << "\t\t<Results>" << std::endl; + this->WriteTestResultHeader(os, result); + os << "\t\t<Results>" << std::endl; for ( kk = 0; cmCTestMemCheckResultLongStrings[kk]; kk ++ ) { if ( memcheckresults[kk] ) @@ -375,8 +353,8 @@ void cmCTestMemCheckHandler::GenerateDartOutput(std::ostream& os) os << "\t\t</Results>\n" << "\t<Log>\n" << memcheckstr << std::endl - << "\t</Log>\n" - << "\t</Test>" << std::endl; + << "\t</Log>\n"; + this->WriteTestResultFooter(os, result); if ( current < cc ) { cmCTestLog(this->CTest, HANDLER_OUTPUT, "#" << std::flush); diff --git a/Source/CTest/cmCTestTestHandler.cxx b/Source/CTest/cmCTestTestHandler.cxx index c04fd9a..5e46c69 100644 --- a/Source/CTest/cmCTestTestHandler.cxx +++ b/Source/CTest/cmCTestTestHandler.cxx @@ -1472,30 +1472,8 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) for ( cc = 0; cc < this->TestResults.size(); cc ++ ) { cmCTestTestResult *result = &this->TestResults[cc]; - os << "\t<Test Status=\""; - if ( result->Status == cmCTestTestHandler::COMPLETED ) - { - os << "passed"; - } - else if ( result->Status == cmCTestTestHandler::NOT_RUN ) - { - os << "notrun"; - } - else - { - os << "failed"; - } - std::string testPath = result->Path + "/" + result->Name; - os << "\">\n" - << "\t\t<Name>" << cmCTest::MakeXMLSafe(result->Name) << "</Name>\n" - << "\t\t<Path>" << cmCTest::MakeXMLSafe( - this->CTest->GetShortPathToFile(result->Path.c_str())) << "</Path>\n" - << "\t\t<FullName>" << cmCTest::MakeXMLSafe( - this->CTest->GetShortPathToFile(testPath.c_str())) << "</FullName>\n" - << "\t\t<FullCommandLine>" - << cmCTest::MakeXMLSafe(result->FullCommandLine) - << "</FullCommandLine>\n" - << "\t\t<Results>" << std::endl; + this->WriteTestResultHeader(os, result); + os << "\t\t<Results>" << std::endl; if ( result->Status != cmCTestTestHandler::NOT_RUN ) { if ( result->Status != cmCTestTestHandler::COMPLETED || @@ -1547,21 +1525,7 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) << "</Value>\n" << "\t\t\t</Measurement>\n" << "\t\t</Results>\n"; - - if(!result->Properties->Labels.empty()) - { - os << "\t\t<Labels>\n"; - std::vector<std::string> const& labels = result->Properties->Labels; - for(std::vector<std::string>::const_iterator li = labels.begin(); - li != labels.end(); ++li) - { - os << "\t\t\t<Label>" << cmCTest::MakeXMLSafe(*li) << "</Label>\n"; - } - os << "\t\t</Labels>\n"; - } - - os - << "\t</Test>" << std::endl; + this->WriteTestResultFooter(os, result); } os << "\t<EndDateTime>" << this->EndTest << "</EndDateTime>\n" @@ -1573,6 +1537,55 @@ void cmCTestTestHandler::GenerateDartOutput(std::ostream& os) this->CTest->EndXML(os); } +//---------------------------------------------------------------------------- +void cmCTestTestHandler::WriteTestResultHeader(std::ostream& os, + cmCTestTestResult* result) +{ + os << "\t<Test Status=\""; + if ( result->Status == cmCTestTestHandler::COMPLETED ) + { + os << "passed"; + } + else if ( result->Status == cmCTestTestHandler::NOT_RUN ) + { + os << "notrun"; + } + else + { + os << "failed"; + } + std::string testPath = result->Path + "/" + result->Name; + os << "\">\n" + << "\t\t<Name>" << cmCTest::MakeXMLSafe(result->Name) << "</Name>\n" + << "\t\t<Path>" << cmCTest::MakeXMLSafe( + this->CTest->GetShortPathToFile(result->Path.c_str())) << "</Path>\n" + << "\t\t<FullName>" << cmCTest::MakeXMLSafe( + this->CTest->GetShortPathToFile(testPath.c_str())) << "</FullName>\n" + << "\t\t<FullCommandLine>" + << cmCTest::MakeXMLSafe(result->FullCommandLine) + << "</FullCommandLine>\n"; +} + +//---------------------------------------------------------------------------- +void cmCTestTestHandler::WriteTestResultFooter(std::ostream& os, + cmCTestTestResult* result) +{ + if(!result->Properties->Labels.empty()) + { + os << "\t\t<Labels>\n"; + std::vector<std::string> const& labels = result->Properties->Labels; + for(std::vector<std::string>::const_iterator li = labels.begin(); + li != labels.end(); ++li) + { + os << "\t\t\t<Label>" << cmCTest::MakeXMLSafe(*li) << "</Label>\n"; + } + os << "\t\t</Labels>\n"; + } + + os + << "\t</Test>" << std::endl; +} + //---------------------------------------------------------------------- int cmCTestTestHandler::ExecuteCommands(std::vector<cmStdString>& vec) { diff --git a/Source/CTest/cmCTestTestHandler.h b/Source/CTest/cmCTestTestHandler.h index a95ae0e..6e90a66 100644 --- a/Source/CTest/cmCTestTestHandler.h +++ b/Source/CTest/cmCTestTestHandler.h @@ -134,6 +134,9 @@ protected: virtual void GenerateTestCommand(std::vector<const char*>& args); int ExecuteCommands(std::vector<cmStdString>& vec); + void WriteTestResultHeader(std::ostream& os, cmCTestTestResult* result); + void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result); + //! Clean test output to specified length bool CleanTestOutput(std::string& output, size_t length); |