summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZach Mullen <zach.mullen@kitware.com>2009-09-04 17:50:06 (GMT)
committerZach Mullen <zach.mullen@kitware.com>2009-09-04 17:50:06 (GMT)
commit5517e17bf936ad243536e793dc792f4dfccf2497 (patch)
tree8b1a924324656d3bfa0151d64b71c1c3ac6c3d9f
parent7d190a65ca3fb717e4889de7604ac8ef3484c593 (diff)
downloadCMake-5517e17bf936ad243536e793dc792f4dfccf2497.zip
CMake-5517e17bf936ad243536e793dc792f4dfccf2497.tar.gz
CMake-5517e17bf936ad243536e793dc792f4dfccf2497.tar.bz2
Fixed ctest output processing. Should now display output as it occurs, as well as be able to consume multiple lines if they exist within the timeout.
-rw-r--r--Source/CTest/cmCTestRunTest.cxx40
-rw-r--r--Source/CTest/cmProcess.cxx32
-rw-r--r--Source/CTest/cmProcess.h5
3 files changed, 46 insertions, 31 deletions
diff --git a/Source/CTest/cmCTestRunTest.cxx b/Source/CTest/cmCTestRunTest.cxx
index 85e8601..d471c6c 100644
--- a/Source/CTest/cmCTestRunTest.cxx
+++ b/Source/CTest/cmCTestRunTest.cxx
@@ -38,26 +38,36 @@ bool cmCTestRunTest::IsRunning()
void cmCTestRunTest::CheckOutput()
{
std::string out, err;
- int pipe = this->TestProcess->CheckOutput(.1);
+ this->TestProcess->CheckOutput(.1);
//start our timeout for reading the process output
double clock_start = cmSystemTools::GetTime();
- while(this->TestProcess->GetNextOutputLine(out, err))
+ int pipe;
+ bool gotStdOut = false;
+ bool gotStdErr = false;
+ while((pipe = this->TestProcess->
+ GetNextOutputLine(out, err, gotStdOut, gotStdErr) )
+ != cmsysProcess_Pipe_Timeout)
{
-
- if(pipe == cmsysProcess_Pipe_STDOUT)
- {
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- this->GetIndex() << ": " << out << std::endl);
- this->ProcessOutput += out;
- this->ProcessOutput += "\n";
- }
- else if(pipe == cmsysProcess_Pipe_STDERR)
+ if(pipe == cmsysProcess_Pipe_STDOUT ||
+ pipe == cmsysProcess_Pipe_STDERR)
{
- cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
- this->GetIndex() << ": " << err << std::endl);
- this->ProcessOutput += err;
- this->ProcessOutput += "\n";
+ if(gotStdErr)
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ this->GetIndex() << ": " << err << std::endl);
+ this->ProcessOutput += err;
+ this->ProcessOutput += "\n";
+ }
+ if(gotStdOut)
+ {
+ cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
+ this->GetIndex() << ": " << out << std::endl);
+ this->ProcessOutput += out;
+ this->ProcessOutput += "\n";
+ }
}
+ gotStdOut = false;
+ gotStdErr = false;
//timeout while reading process output (could denote infinite output)
if(cmSystemTools::GetTime() - clock_start > .1)
{
diff --git a/Source/CTest/cmProcess.cxx b/Source/CTest/cmProcess.cxx
index 8f5b112..ed1c531 100644
--- a/Source/CTest/cmProcess.cxx
+++ b/Source/CTest/cmProcess.cxx
@@ -74,15 +74,19 @@ bool cmProcess::StartProcess()
== cmsysProcess_State_Executing);
}
-bool cmProcess::GetNextOutputLine(std::string& stdOutLine,
- std::string& stdErrLine)
+int cmProcess::GetNextOutputLine(std::string& stdOutLine,
+ std::string& stdErrLine,
+ bool& gotStdOut,
+ bool& gotStdErr)
{
if(this->StdErrorBuffer.empty() && this->StdOutBuffer.empty())
{
- return false;
+ return cmsysProcess_Pipe_Timeout;
}
stdOutLine = "";
stdErrLine = "";
+
+ this->LastOutputPipe = cmsysProcess_Pipe_Timeout;
std::vector<char>::iterator outiter =
this->StdOutBuffer.begin();
std::vector<char>::iterator erriter =
@@ -107,7 +111,8 @@ bool cmProcess::GetNextOutputLine(std::string& stdOutLine,
}
this->StdOutBuffer.erase(this->StdOutBuffer.begin(), outiter+1);
this->LastOutputPipe = cmsysProcess_Pipe_STDOUT;
- return true;
+ gotStdOut = true;
+ break;
}
}
@@ -131,15 +136,16 @@ bool cmProcess::GetNextOutputLine(std::string& stdOutLine,
}
this->StdErrorBuffer.erase(this->StdErrorBuffer.begin(), erriter+1);
this->LastOutputPipe = cmsysProcess_Pipe_STDERR;
- return true;
+ gotStdErr = true;
+ break;
}
}
//If we get here, we have stuff waiting in the buffers, but no newline
- return false;
+ return this->LastOutputPipe;
}
// return true if there is a new line of data
// return false if there is no new data
-int cmProcess::CheckOutput(double timeout)
+void cmProcess::CheckOutput(double timeout)
{
// Wait for data from the process.
int length;
@@ -153,14 +159,13 @@ int cmProcess::CheckOutput(double timeout)
{
// Timeout has been exceeded.
this->LastOutputPipe = pipe;
- return pipe;
+ return;
}
else if(pipe == cmsysProcess_Pipe_STDOUT)
{
- // Append to the stdout buffer.
+ // Append to the stdout buffer.
this->StdOutBuffer.insert(this->StdOutBuffer.end(), data, data+length);
this->LastOutputPipe = pipe;
- return pipe;
}
else if(pipe == cmsysProcess_Pipe_STDERR)
{
@@ -168,7 +173,6 @@ int cmProcess::CheckOutput(double timeout)
this->StdErrorBuffer.insert(this->StdErrorBuffer.end(),
data, data+length);
this->LastOutputPipe = pipe;
- return pipe;
}
else if(pipe == cmsysProcess_Pipe_None)
{
@@ -176,17 +180,17 @@ int cmProcess::CheckOutput(double timeout)
if(!this->StdOutBuffer.empty())
{
this->LastOutputPipe = cmsysProcess_Pipe_STDOUT;
- return this->LastOutputPipe;
+ return;
}
else if(!this->StdErrorBuffer.empty())
{
this->LastOutputPipe = cmsysProcess_Pipe_STDERR;
- return this->LastOutputPipe;
+ return;
}
else
{
this->LastOutputPipe = cmsysProcess_Pipe_None;
- return this->LastOutputPipe;
+ return;
}
}
}
diff --git a/Source/CTest/cmProcess.h b/Source/CTest/cmProcess.h
index 9def390..2d11e61 100644
--- a/Source/CTest/cmProcess.h
+++ b/Source/CTest/cmProcess.h
@@ -41,7 +41,7 @@ public:
bool StartProcess();
// return process state
- int CheckOutput(double timeout);
+ void CheckOutput(double timeout);
// return the process status
int GetProcessStatus();
// return true if the process is running
@@ -52,7 +52,8 @@ public:
void SetId(int id) { this->Id = id;}
int GetExitValue() { return this->ExitValue;}
double GetTotalTime() { return this->TotalTime;}
- bool GetNextOutputLine(std::string& stdOutLine, std::string& stdErrLine);
+ int GetNextOutputLine(std::string& stdOutLine, std::string& stdErrLine,
+ bool& gotStdOut, bool& gotStdErr);
private:
int LastOutputPipe;
double Timeout;