summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmCTestVC.cxx
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-02-24 17:49:57 (GMT)
committerBrad King <brad.king@kitware.com>2009-02-24 17:49:57 (GMT)
commit4e4f2a3a10327978c8de493fe0f411e656b7d2f9 (patch)
tree6131dc617f4a2c082923bb3287652de51acac64f /Source/CTest/cmCTestVC.cxx
parent1595b8e69eac0d2dbab6ac29663a85d8d486a5cc (diff)
downloadCMake-4e4f2a3a10327978c8de493fe0f411e656b7d2f9.zip
CMake-4e4f2a3a10327978c8de493fe0f411e656b7d2f9.tar.gz
CMake-4e4f2a3a10327978c8de493fe0f411e656b7d2f9.tar.bz2
ENH: Create cmCTestVC::RunChild and parse helpers
This method will help VCS tool subclasses run child processes and log the output while parsing it.
Diffstat (limited to 'Source/CTest/cmCTestVC.cxx')
-rw-r--r--Source/CTest/cmCTestVC.cxx31
1 files changed, 31 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestVC.cxx b/Source/CTest/cmCTestVC.cxx
index 2bacda6..9d9a191 100644
--- a/Source/CTest/cmCTestVC.cxx
+++ b/Source/CTest/cmCTestVC.cxx
@@ -18,6 +18,8 @@
#include "cmCTest.h"
+#include <cmsys/Process.h>
+
//----------------------------------------------------------------------------
cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log): CTest(ct), Log(log)
{
@@ -39,3 +41,32 @@ void cmCTestVC::SetSourceDirectory(std::string const& dir)
{
this->SourceDirectory = dir;
}
+
+//----------------------------------------------------------------------------
+bool cmCTestVC::RunChild(char const* const* cmd, OutputParser* out,
+ OutputParser* err, const char* workDir)
+{
+ this->Log << this->ComputeCommandLine(cmd) << "\n";
+
+ cmsysProcess* cp = cmsysProcess_New();
+ cmsysProcess_SetCommand(cp, cmd);
+ workDir = workDir? workDir : this->SourceDirectory.c_str();
+ cmsysProcess_SetWorkingDirectory(cp, workDir);
+ this->RunProcess(cp, out, err);
+ int result = cmsysProcess_GetExitValue(cp);
+ cmsysProcess_Delete(cp);
+ return result == 0;
+}
+
+//----------------------------------------------------------------------------
+std::string cmCTestVC::ComputeCommandLine(char const* const* cmd)
+{
+ cmOStringStream line;
+ const char* sep = "";
+ for(const char* const* arg = cmd; *arg; ++arg)
+ {
+ line << sep << "\"" << *arg << "\"";
+ sep = " ";
+ }
+ return line.str();
+}