summaryrefslogtreecommitdiffstats
path: root/Source/CTest/cmProcess.h
diff options
context:
space:
mode:
authorBrad King <brad.king@kitware.com>2009-09-11 16:26:41 (GMT)
committerBrad King <brad.king@kitware.com>2009-09-11 16:26:41 (GMT)
commit6a7eae718457e8ad9a91729f4c02a666e6ceba98 (patch)
tree511cd299523a20559c4c4a085dd30ec1d0739c81 /Source/CTest/cmProcess.h
parentb6c26cded2965d566ad1ad874f9dac146af4ceac (diff)
downloadCMake-6a7eae718457e8ad9a91729f4c02a666e6ceba98.zip
CMake-6a7eae718457e8ad9a91729f4c02a666e6ceba98.tar.gz
CMake-6a7eae718457e8ad9a91729f4c02a666e6ceba98.tar.bz2
Rewrite CTest child output handling
This commit fixes cmCTestRunTest and cmProcess to more efficiently handle child output. We now use the buffer for each child output pipe to hold at most a partial line plus one new block of data at a time. All complete lines are scanned in-place, and then only the partial line at the end of the buffer is moved back to the beginning before appending new data. We also simplify the cmProcess interface by making GetNextOutputLine the only method that needs to be called while the process is running. This simplifies cmCTestRunTest so that CheckOutput can be called until it returns false when the process is done.
Diffstat (limited to 'Source/CTest/cmProcess.h')
-rw-r--r--Source/CTest/cmProcess.h33
1 files changed, 23 insertions, 10 deletions
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index 08ce733..31481dd 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -39,29 +39,42 @@ public:
void SetTimeout(double t) { this->Timeout = t;}
// Return true if the process starts
bool StartProcess();
-
- // return false if process has exited, true otherwise
- bool CheckOutput(double timeout);
+
// return the process status
int GetProcessStatus();
- // return true if the process is running
- bool IsRunning();
// Report the status of the program
int ReportStatus();
int GetId() { return this->Id; }
void SetId(int id) { this->Id = id;}
int GetExitValue() { return this->ExitValue;}
double GetTotalTime() { return this->TotalTime;}
- int GetNextOutputLine(std::string& stdOutLine, std::string& stdErrLine,
- bool& gotStdOut, bool& gotStdErr, bool running);
+
+ /**
+ * Read one line of output but block for no more than timeout.
+ * Returns:
+ * cmsysProcess_Pipe_None = Process terminated and all output read
+ * cmsysProcess_Pipe_STDOUT = Line came from stdout
+ * cmsysProcess_Pipe_STDOUT = Line came from stderr
+ * cmsysProcess_Pipe_Timeout = Timeout expired while waiting
+ */
+ int GetNextOutputLine(std::string& line, double timeout);
private:
- int LastOutputPipe;
double Timeout;
double StartTime;
double TotalTime;
cmsysProcess* Process;
- std::vector<char> StdErrorBuffer;
- std::vector<char> StdOutBuffer;
+ class Buffer: public std::vector<char>
+ {
+ // Half-open index range of partial line already scanned.
+ size_type First;
+ size_type Last;
+ public:
+ Buffer(): First(0), Last(0) {}
+ bool GetLine(std::string& line);
+ bool GetLast(std::string& line);
+ };
+ Buffer StdErr;
+ Buffer StdOut;
std::string Command;
std::string WorkingDirectory;
std::vector<std::string> Arguments;