[Cmake-commits] [cmake-commits] zach.mullen committed cmCTestRunTest.cxx 1.15 1.16 cmProcess.cxx 1.11 1.12 cmProcess.h 1.6 1.7

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Sep 8 10:16:19 EDT 2009


Update of /cvsroot/CMake/CMake/Source/CTest
In directory public:/mounts/ram/cvs-serv19501

Modified Files:
	cmCTestRunTest.cxx cmProcess.cxx cmProcess.h 
Log Message:
BUG: Fixed issue where ctest would hang if a process terminated with output in its buffers but no newline


Index: cmProcess.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmProcess.cxx,v
retrieving revision 1.11
retrieving revision 1.12
diff -C 2 -d -r1.11 -r1.12
*** cmProcess.cxx	4 Sep 2009 17:50:06 -0000	1.11
--- cmProcess.cxx	8 Sep 2009 14:16:16 -0000	1.12
***************
*** 78,82 ****
                              std::string& stdErrLine,
                              bool& gotStdOut,
!                             bool& gotStdErr)
  {
    if(this->StdErrorBuffer.empty() && this->StdOutBuffer.empty())
--- 78,83 ----
                              std::string& stdErrLine,
                              bool& gotStdOut,
!                             bool& gotStdErr,
!                             bool running)
  {
    if(this->StdErrorBuffer.empty() && this->StdOutBuffer.empty())
***************
*** 92,95 ****
--- 93,117 ----
    std::vector<char>::iterator erriter = 
      this->StdErrorBuffer.begin();
+ 
+   //If process terminated, flush the buffer
+   if(!running)
+     {
+     if(!this->StdErrorBuffer.empty())
+       {
+       gotStdErr = true;
+       stdErrLine.append(&this->StdErrorBuffer[0], this->StdErrorBuffer.size());
+       this->StdErrorBuffer.erase(this->StdErrorBuffer.begin(), 
+         this->StdErrorBuffer.end());
+       }
+     if(!this->StdOutBuffer.empty())
+       {
+       gotStdOut = true;
+       stdOutLine.append(&this->StdOutBuffer[0], this->StdOutBuffer.size());
+       this->StdOutBuffer.erase(this->StdOutBuffer.begin(),
+         this->StdOutBuffer.end());
+       }
+     return cmsysProcess_Pipe_None;
+     }
+ 
    // Check for a newline in stdout.
    for(;outiter != this->StdOutBuffer.end(); ++outiter)
***************
*** 146,150 ****
  // return true if there is a new line of data
  // return false if there is no new data
! void cmProcess::CheckOutput(double timeout)
  {
    // Wait for data from the process.
--- 168,172 ----
  // return true if there is a new line of data
  // return false if there is no new data
! bool cmProcess::CheckOutput(double timeout)
  {
    // Wait for data from the process.
***************
*** 160,164 ****
        // Timeout has been exceeded.
        this->LastOutputPipe = pipe;
!       return;
        }
      else if(pipe == cmsysProcess_Pipe_STDOUT)
--- 182,186 ----
        // Timeout has been exceeded.
        this->LastOutputPipe = pipe;
!       return true;
        }
      else if(pipe == cmsysProcess_Pipe_STDOUT)
***************
*** 181,195 ****
          {
          this->LastOutputPipe = cmsysProcess_Pipe_STDOUT;
!         return;
          }
        else if(!this->StdErrorBuffer.empty())
          {
          this->LastOutputPipe = cmsysProcess_Pipe_STDERR;
!         return;
          }
        else
          {
          this->LastOutputPipe = cmsysProcess_Pipe_None;
!         return;
          }
        }
--- 203,217 ----
          {
          this->LastOutputPipe = cmsysProcess_Pipe_STDOUT;
!         return false;
          }
        else if(!this->StdErrorBuffer.empty())
          {
          this->LastOutputPipe = cmsysProcess_Pipe_STDERR;
!         return false;
          }
        else
          {
          this->LastOutputPipe = cmsysProcess_Pipe_None;
!         return false;
          }
        }

Index: cmCTestRunTest.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestRunTest.cxx,v
retrieving revision 1.15
retrieving revision 1.16
diff -C 2 -d -r1.15 -r1.16
*** cmCTestRunTest.cxx	7 Sep 2009 14:26:10 -0000	1.15
--- cmCTestRunTest.cxx	8 Sep 2009 14:16:15 -0000	1.16
***************
*** 39,43 ****
  {
    std::string out, err;
!   this->TestProcess->CheckOutput(.1);
    //start our timeout for reading the process output
    double clock_start = cmSystemTools::GetTime();
--- 39,43 ----
  {
    std::string out, err;
!   bool running = this->TestProcess->CheckOutput(.1);
    //start our timeout for reading the process output
    double clock_start = cmSystemTools::GetTime();
***************
*** 46,54 ****
    bool gotStdErr = false;
    while((pipe = this->TestProcess->
!         GetNextOutputLine(out, err, gotStdOut, gotStdErr) )
          != cmsysProcess_Pipe_Timeout)
      {
      if(pipe == cmsysProcess_Pipe_STDOUT ||
!        pipe == cmsysProcess_Pipe_STDERR)
        {
        if(gotStdErr)
--- 46,55 ----
    bool gotStdErr = false;
    while((pipe = this->TestProcess->
!         GetNextOutputLine(out, err, gotStdOut, gotStdErr, running) )
          != cmsysProcess_Pipe_Timeout)
      {
      if(pipe == cmsysProcess_Pipe_STDOUT ||
!        pipe == cmsysProcess_Pipe_STDERR ||
!        pipe == cmsysProcess_Pipe_None)
        {
        if(gotStdErr)
***************
*** 66,69 ****
--- 67,74 ----
          this->ProcessOutput += "\n";
          }
+       if(pipe == cmsysProcess_Pipe_None)
+         {
+         break;
+         }
        }
      gotStdOut = false;

Index: cmProcess.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmProcess.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -C 2 -d -r1.6 -r1.7
*** cmProcess.h	4 Sep 2009 17:50:06 -0000	1.6
--- cmProcess.h	8 Sep 2009 14:16:16 -0000	1.7
***************
*** 41,46 ****
    bool StartProcess();
    
!   // return process state
!   void CheckOutput(double timeout);
    // return the process status
    int GetProcessStatus();
--- 41,46 ----
    bool StartProcess();
    
!   // return false if process has exited, true otherwise
!   bool CheckOutput(double timeout);
    // return the process status
    int GetProcessStatus();
***************
*** 54,58 ****
    double GetTotalTime() { return this->TotalTime;}
    int GetNextOutputLine(std::string& stdOutLine, std::string& stdErrLine,
!                         bool& gotStdOut, bool& gotStdErr);
  private:
    int LastOutputPipe;
--- 54,58 ----
    double GetTotalTime() { return this->TotalTime;}
    int GetNextOutputLine(std::string& stdOutLine, std::string& stdErrLine,
!                         bool& gotStdOut, bool& gotStdErr, bool running);
  private:
    int LastOutputPipe;



More information about the Cmake-commits mailing list