Jelajahi Sumber

ENH: Refactor Build.xml generation

This divides cmCTestBuildHandler::GenerateDartBuildOutput into three
methods to generate the header, content, and footer components of
Build.xml files.  It will allow the content generation to be replaced
later.
Brad King 16 tahun lalu
induk
melakukan
5f65e04ea2
2 mengubah file dengan 19 tambahan dan 11 penghapusan
  1. 16 7
      Source/CTest/cmCTestBuildHandler.cxx
  2. 3 4
      Source/CTest/cmCTestBuildHandler.h

+ 16 - 7
Source/CTest/cmCTestBuildHandler.cxx

@@ -473,16 +473,14 @@ int cmCTestBuildHandler::ProcessHandler()
       << std::endl);
     return -1;
     }
-  this->GenerateDartBuildOutput(
-    xofs, this->ErrorsAndWarnings, elapsed_build_time);
+  this->GenerateXMLHeader(xofs);
+  this->GenerateXMLLogScraped(xofs);
+  this->GenerateXMLFooter(xofs, elapsed_build_time);
   return retVal;
 }
 
-//----------------------------------------------------------------------
-void cmCTestBuildHandler::GenerateDartBuildOutput(
-  std::ostream& os,
-  std::vector<cmCTestBuildErrorWarning> ew,
-  double elapsed_build_time)
+//----------------------------------------------------------------------------
+void cmCTestBuildHandler::GenerateXMLHeader(std::ostream& os)
 {
   this->CTest->StartXML(os, this->AppendXML);
   os << "<Build>\n"
@@ -494,7 +492,12 @@ void cmCTestBuildHandler::GenerateDartBuildOutput(
      << this->CTest->MakeXMLSafe(
        this->CTest->GetCTestConfiguration("MakeCommand"))
      << "</BuildCommand>" << std::endl;
+}
 
+//----------------------------------------------------------------------------
+void cmCTestBuildHandler::GenerateXMLLogScraped(std::ostream& os)
+{
+  std::vector<cmCTestBuildErrorWarning>& ew = this->ErrorsAndWarnings;
   std::vector<cmCTestBuildErrorWarning>::iterator it;
 
   // only report the first 50 warnings and first 50 errors
@@ -591,6 +594,12 @@ void cmCTestBuildHandler::GenerateDartBuildOutput(
          << std::endl;
       }
     }
+}
+
+//----------------------------------------------------------------------------
+void cmCTestBuildHandler::GenerateXMLFooter(std::ostream& os,
+                                            double elapsed_build_time)
+{
   os << "\t<Log Encoding=\"base64\" Compression=\"/bin/gzip\">\n\t</Log>\n"
      << "\t<EndDateTime>" << this->EndBuild << "</EndDateTime>\n"
      << "\t<EndBuildTime>" << static_cast<unsigned int>(this->EndBuildTime)

+ 3 - 4
Source/CTest/cmCTestBuildHandler.h

@@ -86,10 +86,9 @@ private:
   };
 
   // generate the XML output
-  void GenerateDartBuildOutput(std::ostream& os,
-                               std::vector<cmCTestBuildErrorWarning>,
-                               double elapsed_time);
-
+  void GenerateXMLHeader(std::ostream& os);
+  void GenerateXMLLogScraped(std::ostream& os);
+  void GenerateXMLFooter(std::ostream& os, double elapsed_build_time);
 
   std::string             StartBuild;
   std::string             EndBuild;