diff options
author | Brad King <brad.king@kitware.com> | 2009-02-26 14:22:32 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2009-02-26 14:22:32 (GMT) |
commit | 3829be4ca66e79310ef19750e877634169c64431 (patch) | |
tree | 18aa87c67be3653ad6f33327676423cda0c7955c /Source/CTest/cmCTestVC.cxx | |
parent | 7960f7541ce3d8d03ce68b0e5a37e67019bbe557 (diff) | |
download | CMake-3829be4ca66e79310ef19750e877634169c64431.zip CMake-3829be4ca66e79310ef19750e877634169c64431.tar.gz CMake-3829be4ca66e79310ef19750e877634169c64431.tar.bz2 |
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.
Diffstat (limited to 'Source/CTest/cmCTestVC.cxx')
-rw-r--r-- | Source/CTest/cmCTestVC.cxx | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx index 642a59a..9f079af 100644 --- a/Source/CTest/cmCTestVC.cxx +++ b/Source/CTest/cmCTestVC.cxx @@ -17,6 +17,7 @@ #include "cmCTestVC.h" #include "cmCTest.h" +#include "cmSystemTools.h" #include "cmXMLSafe.h" #include <cmsys/Process.h> @@ -50,6 +51,47 @@ void cmCTestVC::SetSourceDirectory(std::string const& dir) } //---------------------------------------------------------------------------- +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) { |