[Cmake-commits] [cmake-commits] zach.mullen committed cmCTestMultiProcessHandler.cxx 1.14 1.15 cmCTestRunTest.cxx 1.12 1.13 cmCTestRunTest.h 1.7 1.8 cmProcess.cxx 1.6 1.7 cmProcess.h 1.4 1.5
cmake-commits at cmake.org
cmake-commits at cmake.org
Thu Sep 3 15:33:46 EDT 2009
Update of /cvsroot/CMake/CMake/Source/CTest
In directory public:/mounts/ram/cvs-serv30723
Modified Files:
cmCTestMultiProcessHandler.cxx cmCTestRunTest.cxx
cmCTestRunTest.h cmProcess.cxx cmProcess.h
Log Message:
Allowed tests to pull more than one line of output in their quantum. Fixed uninitialized variables in the case that the test process could not start.
Index: cmCTestRunTest.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestRunTest.cxx,v
retrieving revision 1.12
retrieving revision 1.13
diff -C 2 -d -r1.12 -r1.13
*** cmCTestRunTest.cxx 3 Sep 2009 14:47:14 -0000 1.12
--- cmCTestRunTest.cxx 3 Sep 2009 19:33:44 -0000 1.13
***************
*** 39,61 ****
{
std::string out, err;
! int pipe = this->TestProcess->CheckOutput(.1, out, err);
! 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)
{
! cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
! this->GetIndex() << ": " << err << std::endl);
! this->ProcessOutput += err;
! this->ProcessOutput += "\n";
}
}
//---------------------------------------------------------
! bool cmCTestRunTest::EndTest(size_t completed, size_t total)
{
//restore the old environment
--- 39,72 ----
{
std::string out, err;
! int pipe = this->TestProcess->CheckOutput(.1);
! //start our timeout for reading the process output
! double clock_start = cmSystemTools::GetTime();
! while(this->TestProcess->GetNextOutputLine(out, err))
{
!
! 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)
! {
! cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
! this->GetIndex() << ": " << err << std::endl);
! this->ProcessOutput += err;
! this->ProcessOutput += "\n";
! }
! //timeout while reading process output (could denote infinite output)
! if(cmSystemTools::GetTime() - clock_start > .1)
! {
! break;
! }
}
}
//---------------------------------------------------------
! bool cmCTestRunTest::EndTest(size_t completed, size_t total, bool started)
{
//restore the old environment
***************
*** 241,250 ****
<< std::endl << std::endl;
}
! this->TestResult.Output = this->ProcessOutput;
! this->TestResult.ReturnValue = this->TestProcess->GetExitValue();
! this->TestResult.CompletionStatus = "Completed";
! this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime();
! this->TestHandler->TestResults.push_back( this->TestResult );
!
this->MemCheckPostProcess();
--- 252,263 ----
<< std::endl << std::endl;
}
! if(started)
! {
! this->TestResult.Output = this->ProcessOutput;
! this->TestResult.ReturnValue = this->TestProcess->GetExitValue();
! this->TestResult.CompletionStatus = "Completed";
! this->TestResult.ExecutionTime = this->TestProcess->GetTotalTime();
! this->TestHandler->TestResults.push_back( this->TestResult );
! }
this->MemCheckPostProcess();
***************
*** 291,294 ****
--- 304,308 ----
this->TestResult.ExecutionTime = 0;
this->TestResult.ReturnValue = -1;
+ this->TestResult.CompletionStatus = "Not Run";
this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
this->TestResult.TestCount = this->TestProperties->Index;
Index: cmCTestMultiProcessHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestMultiProcessHandler.cxx,v
retrieving revision 1.14
retrieving revision 1.15
diff -C 2 -d -r1.14 -r1.15
*** cmCTestMultiProcessHandler.cxx 3 Sep 2009 15:14:08 -0000 1.14
--- cmCTestMultiProcessHandler.cxx 3 Sep 2009 19:33:44 -0000 1.15
***************
*** 101,105 ****
else
{
! testRun->EndTest(this->Completed, this->Total);
}
}
--- 101,106 ----
else
{
! this->Completed++;
! testRun->EndTest(this->Completed, this->Total, false);
}
}
***************
*** 210,214 ****
int test = p->GetIndex();
! if(p->EndTest(this->Completed, this->Total))
{
this->Passed->push_back(p->GetTestProperties()->Name);
--- 211,215 ----
int test = p->GetIndex();
! if(p->EndTest(this->Completed, this->Total, true))
{
this->Passed->push_back(p->GetTestProperties()->Name);
Index: cmProcess.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmProcess.cxx,v
retrieving revision 1.6
retrieving revision 1.7
diff -C 2 -d -r1.6 -r1.7
*** cmProcess.cxx 14 Jan 2009 18:48:03 -0000 1.6
--- cmProcess.cxx 3 Sep 2009 19:33:44 -0000 1.7
***************
*** 69,79 ****
== cmsysProcess_State_Executing);
}
!
! // return true if there is a new line of data
! // return false if there is no new data
! int cmProcess::CheckOutput(double timeout,
! std::string& stdOutLine,
std::string& stdErrLine)
{
stdOutLine = "";
stdErrLine = "";
--- 69,80 ----
== cmsysProcess_State_Executing);
}
!
! bool cmProcess::GetNextOutputLine(std::string& stdOutLine,
std::string& stdErrLine)
{
+ if(this->StdErrorBuffer.empty() && this->StdOutBuffer.empty())
+ {
+ return false;
+ }
stdOutLine = "";
stdErrLine = "";
***************
*** 82,138 ****
std::vector<char>::iterator erriter =
this->StdErrorBuffer.begin();
! while(1)
{
! // Check for a newline in stdout.
! for(;outiter != this->StdOutBuffer.end(); ++outiter)
{
! if((*outiter == '\r') && ((outiter+1) == this->StdOutBuffer.end()))
{
! break;
}
! else if(*outiter == '\n' || *outiter == '\0')
{
! int length = outiter-this->StdOutBuffer.begin();
! if(length > 1 && *(outiter-1) == '\r')
! {
! --length;
! }
! if(length > 0)
! {
! stdOutLine.append(&this->StdOutBuffer[0], length);
! }
! this->StdOutBuffer.erase(this->StdOutBuffer.begin(), outiter+1);
! this->LastOutputPipe = cmsysProcess_Pipe_STDOUT;
! return this->LastOutputPipe;;
}
}
! // Check for a newline in stderr.
! for(;erriter != this->StdErrorBuffer.end(); ++erriter)
{
! if((*erriter == '\r') && ((erriter+1) == this->StdErrorBuffer.end()))
{
! break;
}
! else if(*erriter == '\n' || *erriter == '\0')
{
! int length = erriter-this->StdErrorBuffer.begin();
! if(length > 1 && *(erriter-1) == '\r')
! {
! --length;
! }
! if(length > 0)
! {
! stdErrLine.append(&this->StdErrorBuffer[0], length);
! }
! this->StdErrorBuffer.erase(this->StdErrorBuffer.begin(), erriter+1);
! this->LastOutputPipe = cmsysProcess_Pipe_STDERR;
! return this->LastOutputPipe;
}
}
! // No newlines found. Wait for more data from the process.
! int length;
! char* data;
int pipe = cmsysProcess_WaitForData(this->Process, &data,
&length, &timeout);
--- 83,146 ----
std::vector<char>::iterator erriter =
this->StdErrorBuffer.begin();
! // Check for a newline in stdout.
! for(;outiter != this->StdOutBuffer.end(); ++outiter)
{
! if((*outiter == '\r') && ((outiter+1) == this->StdOutBuffer.end()))
{
! break;
! }
! else if(*outiter == '\n' || *outiter == '\0')
! {
! int length = outiter-this->StdOutBuffer.begin();
! if(length > 1 && *(outiter-1) == '\r')
{
! --length;
}
! if(length > 0)
{
! stdOutLine.append(&this->StdOutBuffer[0], length);
}
+ this->StdOutBuffer.erase(this->StdOutBuffer.begin(), outiter+1);
+ this->LastOutputPipe = cmsysProcess_Pipe_STDOUT;
+ return true;
}
+ }
! // Check for a newline in stderr.
! for(;erriter != this->StdErrorBuffer.end(); ++erriter)
! {
! if((*erriter == '\r') && ((erriter+1) == this->StdErrorBuffer.end()))
{
! break;
! }
! else if(*erriter == '\n' || *erriter == '\0')
! {
! int length = erriter-this->StdErrorBuffer.begin();
! if(length > 1 && *(erriter-1) == '\r')
{
! --length;
}
! if(length > 0)
{
! stdErrLine.append(&this->StdErrorBuffer[0], length);
}
+ this->StdErrorBuffer.erase(this->StdErrorBuffer.begin(), erriter+1);
+ this->LastOutputPipe = cmsysProcess_Pipe_STDERR;
+ return true;
}
+ }
+ //If we get here, we have stuff waiting in the buffers, but no newline
+ return false;
+ }
+ // return true if there is a new line of data
+ // return false if there is no new data
+ int cmProcess::CheckOutput(double timeout)
+ {
+ // Wait for data from the process.
+ int length;
+ char* data;
! while(1)
! {
int pipe = cmsysProcess_WaitForData(this->Process, &data,
&length, &timeout);
***************
*** 148,152 ****
std::vector<char>::size_type size = this->StdOutBuffer.size();
this->StdOutBuffer.insert(this->StdOutBuffer.end(), data, data+length);
- outiter = this->StdOutBuffer.begin()+size;
}
else if(pipe == cmsysProcess_Pipe_STDERR)
--- 156,159 ----
***************
*** 156,160 ****
this->StdErrorBuffer.insert(this->StdErrorBuffer.end(),
data, data+length);
- erriter = this->StdErrorBuffer.begin()+size;
}
else if(pipe == cmsysProcess_Pipe_None)
--- 163,166 ----
***************
*** 163,170 ****
if(!this->StdOutBuffer.empty())
{
- stdOutLine.append(&this->StdOutBuffer[0],
- outiter-this->StdOutBuffer.begin());
- this->StdOutBuffer.erase(this->StdOutBuffer.begin(),
- this->StdOutBuffer.end());
this->LastOutputPipe = cmsysProcess_Pipe_STDOUT;
return this->LastOutputPipe;
--- 169,172 ----
***************
*** 172,179 ****
else if(!this->StdErrorBuffer.empty())
{
- stdErrLine.append(&this->StdErrorBuffer[0],
- erriter-this->StdErrorBuffer.begin());
- this->StdErrorBuffer.erase(this->StdErrorBuffer.begin(),
- this->StdErrorBuffer.end());
this->LastOutputPipe = cmsysProcess_Pipe_STDERR;
return this->LastOutputPipe;
--- 174,177 ----
***************
*** 188,192 ****
}
-
// return the process status
int cmProcess::GetProcessStatus()
--- 186,189 ----
Index: cmCTestRunTest.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestRunTest.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C 2 -d -r1.7 -r1.8
*** cmCTestRunTest.h 2 Sep 2009 14:08:39 -0000 1.7
--- cmCTestRunTest.h 3 Sep 2009 19:33:44 -0000 1.8
***************
*** 57,61 ****
bool StartTest();
//capture and report the test results
! bool EndTest(size_t completed, size_t total);
//Called by ctest -N to log the command string
void ComputeArguments();
--- 57,61 ----
bool StartTest();
//capture and report the test results
! bool EndTest(size_t completed, size_t total, bool started);
//Called by ctest -N to log the command string
void ComputeArguments();
Index: cmProcess.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmProcess.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C 2 -d -r1.4 -r1.5
*** cmProcess.h 12 Aug 2009 02:02:49 -0000 1.4
--- cmProcess.h 3 Sep 2009 19:33:44 -0000 1.5
***************
*** 42,48 ****
// return process state
! int CheckOutput(double timeout,
! std::string& stdOutLine,
! std::string& stdErrLine);
// return the process status
int GetProcessStatus();
--- 42,46 ----
// return process state
! int CheckOutput(double timeout);
// return the process status
int GetProcessStatus();
***************
*** 55,58 ****
--- 53,57 ----
int GetExitValue() { return this->ExitValue;}
double GetTotalTime() { return this->TotalTime;}
+ bool GetNextOutputLine(std::string& stdOutLine, std::string& stdErrLine);
private:
int LastOutputPipe;
More information about the Cmake-commits
mailing list