[Cmake-commits] [cmake-commits] king committed cmCTestUpdateHandler.cxx 1.55 1.56 cmCTestUpdateHandler.h 1.9 1.10
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Feb 24 09:09:17 EST 2009
Update of /cvsroot/CMake/CMake/Source/CTest
In directory public:/mounts/ram/cvs-serv27029/Source/CTest
Modified Files:
cmCTestUpdateHandler.cxx cmCTestUpdateHandler.h
Log Message:
ENH: Factor out initial checkout method
This moves the initial checkout code from the monolithic
cmCTestUpdateHandler::ProcessHandler to a separate method
cmCTestUpdateHandler::InitialCheckout.
Index: cmCTestUpdateHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestUpdateHandler.cxx,v
retrieving revision 1.55
retrieving revision 1.56
diff -C 2 -d -r1.55 -r1.56
*** cmCTestUpdateHandler.cxx 23 Feb 2009 20:59:39 -0000 1.55
--- cmCTestUpdateHandler.cxx 24 Feb 2009 14:09:14 -0000 1.56
***************
*** 290,294 ****
int updateType = e_CVS;
std::string::size_type cc, kk;
- bool updateProducedError = false;
std::string goutput;
std::string errors;
--- 290,293 ----
***************
*** 298,302 ****
static_cast<void>(fixLocale);
- std::string checkoutErrorMessages;
int retVal = 0;
--- 297,300 ----
***************
*** 320,375 ****
"Updating the repository" << std::endl);
! const char* initialCheckoutCommand = this->GetOption("InitialCheckout");
! if ( initialCheckoutCommand )
{
! 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 -1;
! }
! 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 -1;
! }
! 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 )
! {
! cmOStringStream ostr;
! ostr << "Problem running initial checkout Output [" << goutput
! << "] Errors [" << errors << "]";
! cmCTestLog(this->CTest, ERROR_MESSAGE, ostr.str().c_str() << std::endl);
! checkoutErrorMessages += ostr.str();
! updateProducedError = true;
! }
! if(!this->CTest->InitializeFromCommand(this->Command))
! {
! cmCTestLog(this->CTest, HANDLER_OUTPUT,
! " Fatal Error in initialize: "
! << std::endl);
! cmSystemTools::SetFatalErrorOccured();
! return -1;
! }
}
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Updating the repository: "
<< sourceDirectory << std::endl);
--- 318,327 ----
"Updating the repository" << std::endl);
! // Make sure the source directory exists.
! if(!this->InitialCheckout(ofs))
{
! return -1;
}
+
cmCTestLog(this->CTest, HANDLER_OUTPUT, " Updating the repository: "
<< sourceDirectory << std::endl);
***************
*** 637,645 ****
}
}
! if ( !res || retVal )
! {
! updateProducedError = true;
! checkoutErrorMessages += " " + goutput;
! }
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
--- 589,593 ----
}
}
! bool updateProducedError = !res || retVal;
os << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
***************
*** 1090,1094 ****
{
os << "Update error: ";
- os << cmXMLSafe(checkoutErrorMessages);
cmCTestLog(this->CTest, ERROR_MESSAGE, " Update with command: "
<< command << " failed" << std::endl);
--- 1038,1041 ----
***************
*** 1106,1107 ****
--- 1053,1114 ----
return count;
}
+
+ //----------------------------------------------------------------------
+ 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))
+ {
+ cmCTestLog(this->CTest, HANDLER_OUTPUT,
+ " Fatal Error in initialize: "
+ << std::endl);
+ cmSystemTools::SetFatalErrorOccured();
+ return false;
+ }
+ }
+ return true;
+ }
Index: cmCTestUpdateHandler.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestUpdateHandler.h,v
retrieving revision 1.9
retrieving revision 1.10
diff -C 2 -d -r1.9 -r1.10
*** cmCTestUpdateHandler.h 17 Feb 2009 16:37:18 -0000 1.9
--- cmCTestUpdateHandler.h 24 Feb 2009 14:09:14 -0000 1.10
***************
*** 63,66 ****
--- 63,68 ----
// Determine the type of version control
int DetermineType(const char* cmd, const char* type);
+
+ bool InitialCheckout(std::ostream& ofs);
};
More information about the Cmake-commits
mailing list