[Cmake-commits] [cmake-commits] king committed cmCTestVC.cxx 1.1 1.2 cmCTestVC.h 1.1 1.2
cmake-commits at cmake.org
cmake-commits at cmake.org
Tue Feb 24 12:49:59 EST 2009
Update of /cvsroot/CMake/CMake/Source/CTest
In directory public:/mounts/ram/cvs-serv25819/Source/CTest
Modified Files:
cmCTestVC.cxx cmCTestVC.h
Log Message:
ENH: Create cmCTestVC::RunChild and parse helpers
This method will help VCS tool subclasses run child processes and log
the output while parsing it.
Index: cmCTestVC.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestVC.h,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** cmCTestVC.h 24 Feb 2009 15:39:28 -0000 1.1
--- cmCTestVC.h 24 Feb 2009 17:49:57 -0000 1.2
***************
*** 18,22 ****
#define cmCTestVC_h
! #include "cmStandardIncludes.h"
class cmCTest;
--- 18,22 ----
#define cmCTestVC_h
! #include "cmProcessTools.h"
class cmCTest;
***************
*** 26,30 ****
*
*/
! class cmCTestVC
{
public:
--- 26,30 ----
*
*/
! class cmCTestVC: public cmProcessTools
{
public:
***************
*** 42,45 ****
--- 42,52 ----
protected:
+ /** Convert a list of arguments to a human-readable command line. */
+ static std::string ComputeCommandLine(char const* const* cmd);
+
+ /** Run a command line and send output to given parsers. */
+ bool RunChild(char const* const* cmd, OutputParser* out,
+ OutputParser* err, const char* workDir = 0);
+
// Instance of cmCTest running the script.
cmCTest* CTest;
Index: cmCTestVC.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestVC.cxx,v
retrieving revision 1.1
retrieving revision 1.2
diff -C 2 -d -r1.1 -r1.2
*** cmCTestVC.cxx 24 Feb 2009 15:39:28 -0000 1.1
--- cmCTestVC.cxx 24 Feb 2009 17:49:57 -0000 1.2
***************
*** 19,22 ****
--- 19,24 ----
#include "cmCTest.h"
+ #include <cmsys/Process.h>
+
//----------------------------------------------------------------------------
cmCTestVC::cmCTestVC(cmCTest* ct, std::ostream& log): CTest(ct), Log(log)
***************
*** 40,41 ****
--- 42,72 ----
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();
+ }
More information about the Cmake-commits
mailing list