[Cmake-commits] [cmake-commits] king committed cmCTestUpdateHandler.cxx 1.62 1.63 cmCTestVC.cxx 1.7 1.8 cmCTestVC.h 1.7 1.8

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Feb 26 09:22:34 EST 2009


Update of /cvsroot/CMake/CMake/Source/CTest
In directory public:/mounts/ram/cvs-serv6094/Source/CTest

Modified Files:
	cmCTestUpdateHandler.cxx cmCTestVC.cxx cmCTestVC.h 
Log Message:
ENH: Refactor initial checkout into cmCTestVC

This adds cmCTestVC::InitialCheckout and uses it in cmCTestUpdateHandler
to run the initial checkout command.  The new implementation logs the
command in the update log consistently with the rest of the new update
implementation.


Index: cmCTestUpdateHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestUpdateHandler.cxx,v
retrieving revision 1.62
retrieving revision 1.63
diff -C 2 -d -r1.62 -r1.63
*** cmCTestUpdateHandler.cxx	25 Feb 2009 19:42:45 -0000	1.62
--- cmCTestUpdateHandler.cxx	26 Feb 2009 14:22:32 -0000	1.63
***************
*** 297,345 ****
  bool cmCTestUpdateHandler::InitialCheckout(std::ostream& ofs)
  {
-   const char* sourceDirectory = this->GetOption("SourceDirectory");
- 
    // Use the user-provided command to create the source tree.
!   const char* initialCheckoutCommand = this->GetOption("InitialCheckout");
!   if ( initialCheckoutCommand )
      {
!     std::string goutput;
!     std::string errors;
!     int retVal = 0;
!     cmCTestLog(this->CTest, HANDLER_OUTPUT,
!       "   First perform the initial checkout: " << initialCheckoutCommand
!       << std::endl);
!     cmStdString parent = cmSystemTools::GetParentDirectory(sourceDirectory);
!     if ( parent.empty() )
!       {
!       cmCTestLog(this->CTest, ERROR_MESSAGE,
!         "Something went wrong when trying "
!         "to determine the parent directory of " << sourceDirectory
!         << std::endl);
!       return false;
!       }
!     cmCTestLog(this->CTest, HANDLER_OUTPUT,
!       "   Perform checkout in directory: " << parent.c_str() << std::endl);
!     if ( !cmSystemTools::MakeDirectory(parent.c_str()) )
        {
-       cmCTestLog(this->CTest, ERROR_MESSAGE,
-         "Cannot create parent directory: " << parent.c_str()
-         << " of the source directory: " << sourceDirectory << std::endl);
        return false;
        }
!     ofs << "* Run initial checkout" << std::endl;
!     ofs << "  Command: " << initialCheckoutCommand << std::endl;
!     cmCTestLog(this->CTest, DEBUG, "   Before: "
!       << initialCheckoutCommand << std::endl);
!     bool retic = this->CTest->RunCommand(initialCheckoutCommand, &goutput,
!       &errors, &retVal, parent.c_str(), 0 /* Timeout */);
!     cmCTestLog(this->CTest, DEBUG, "   After: "
!       << initialCheckoutCommand << std::endl);
!     ofs << "  Output: " << goutput.c_str() << std::endl;
!     ofs << "  Errors: " << errors.c_str() << std::endl;
!     if ( !retic || retVal )
!       {
!       cmCTestLog(this->CTest, ERROR_MESSAGE, "Initial checkout failed:\n"
!                  << goutput << "\n" << errors << "\n");
!       }
      if(!this->CTest->InitializeFromCommand(this->Command))
        {
--- 297,311 ----
  bool cmCTestUpdateHandler::InitialCheckout(std::ostream& ofs)
  {
    // Use the user-provided command to create the source tree.
!   if(const char* command = this->GetOption("InitialCheckout"))
      {
!     // Use a generic VC object to run and log the command.
!     cmCTestVC vc(this->CTest, ofs);
!     vc.SetSourceDirectory(this->GetOption("SourceDirectory"));
!     if(!vc.InitialCheckout(command))
        {
        return false;
        }
! 
      if(!this->CTest->InitializeFromCommand(this->Command))
        {

Index: cmCTestVC.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestVC.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C 2 -d -r1.7 -r1.8
*** cmCTestVC.h	25 Feb 2009 20:45:14 -0000	1.7
--- cmCTestVC.h	26 Feb 2009 14:22:32 -0000	1.8
***************
*** 43,46 ****
--- 43,49 ----
    std::string GetNightlyTime();
  
+   /** Prepare the work tree.  */
+   bool InitialCheckout(const char* command);
+ 
    /** Perform cleanup operations on the work tree.  */
    void Cleanup();

Index: cmCTestVC.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestVC.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -C 2 -d -r1.7 -r1.8
*** cmCTestVC.cxx	25 Feb 2009 19:42:45 -0000	1.7
--- cmCTestVC.cxx	26 Feb 2009 14:22:32 -0000	1.8
***************
*** 18,21 ****
--- 18,22 ----
  
  #include "cmCTest.h"
+ #include "cmSystemTools.h"
  #include "cmXMLSafe.h"
  
***************
*** 51,54 ****
--- 52,96 ----
  
  //----------------------------------------------------------------------------
+ bool cmCTestVC::InitialCheckout(const char* command)
+ {
+   cmCTestLog(this->CTest, HANDLER_OUTPUT,
+              "   First perform the initial checkout: " << command << "\n");
+ 
+   // Make the parent directory in which to perform the checkout.
+   std::string parent = cmSystemTools::GetFilenamePath(this->SourceDirectory);
+   cmCTestLog(this->CTest, HANDLER_OUTPUT,
+              "   Perform checkout in directory: " << parent << "\n");
+   if(!cmSystemTools::MakeDirectory(parent.c_str()))
+     {
+     cmCTestLog(this->CTest, ERROR_MESSAGE,
+                "Cannot create directory: " << parent << std::endl);
+     return false;
+     }
+ 
+   // Construct the initial checkout command line.
+   std::vector<cmStdString> args = cmSystemTools::ParseArguments(command);
+   std::vector<char const*> vc_co;
+   for(std::vector<cmStdString>::const_iterator ai = args.begin();
+       ai != args.end(); ++ai)
+     {
+     vc_co.push_back(ai->c_str());
+     }
+   vc_co.push_back(0);
+ 
+   // Run the initial checkout command and log its output.
+   this->Log << "--- Begin Initial Checkout ---\n";
+   OutputLogger out(this->Log, "co-out> ");
+   OutputLogger err(this->Log, "co-err> ");
+   bool result = this->RunChild(&vc_co[0], &out, &err, parent.c_str());
+   this->Log << "--- End Initial Checkout ---\n";
+   if(!result)
+     {
+     cmCTestLog(this->CTest, ERROR_MESSAGE,
+                "Initial checkout failed!" << std::endl);
+     }
+   return result;
+ }
+ 
+ //----------------------------------------------------------------------------
  bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
                           OutputParser* err, const char* workDir)



More information about the Cmake-commits mailing list