[Cmake-commits] [cmake-commits] zach.mullen committed cmCTestGenericHandler.cxx 1.21 1.22 cmCTestMultiProcessHandler.cxx 1.7 1.8 cmCTestMultiProcessHandler.h 1.4 1.5 cmCTestRunTest.cxx 1.3 1.4 cmCTestRunTest.h 1.2 1.3 cmCTestTestHandler.cxx 1.106 1.107 cmCTestTestHandler.h 1.40 1.41

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Aug 27 10:37:30 EDT 2009


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

Modified Files:
	cmCTestGenericHandler.cxx cmCTestMultiProcessHandler.cxx 
	cmCTestMultiProcessHandler.h cmCTestRunTest.cxx 
	cmCTestRunTest.h cmCTestTestHandler.cxx cmCTestTestHandler.h 
Log Message:
Fixed ctest -N segfault issue.  Further refactored ctest.  Enabled failover for ctest


Index: cmCTestRunTest.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestRunTest.cxx,v
retrieving revision 1.3
retrieving revision 1.4
diff -C 2 -d -r1.3 -r1.4
*** cmCTestRunTest.cxx	26 Aug 2009 16:09:05 -0000	1.3
--- cmCTestRunTest.cxx	27 Aug 2009 14:37:26 -0000	1.4
***************
*** 68,185 ****
    int res = this->TestProcess->GetProcessStatus();
    int retVal = this->TestProcess->GetExitValue();
!   if ( !this->CTest->GetShowOnly() )
      {
!     std::vector<std::pair<cmsys::RegularExpression,
!       std::string> >::iterator passIt;
!     bool forceFail = false;
!     if ( this->TestProperties->RequiredRegularExpressions.size() > 0 )
        {
!       bool found = false;
!       for ( passIt = this->TestProperties->RequiredRegularExpressions.begin();
!             passIt != this->TestProperties->RequiredRegularExpressions.end();
!             ++ passIt )
!         {
!         if ( passIt->first.find(this->ProcessOutput.c_str()) )
!           {
!           found = true;
!           reason = "Required regular expression found.";
!           }
!         }
!       if ( !found )
!         { 
!         reason = "Required regular expression not found.";
!         forceFail = true;
!         }
!       reason +=  "Regex=["; 
!       for ( passIt = this->TestProperties->RequiredRegularExpressions.begin();
!             passIt != this->TestProperties->RequiredRegularExpressions.end();
!             ++ passIt )
          {
!         reason += passIt->second;
!         reason += "\n";
          }
-       reason += "]";
        }
!     if ( this->TestProperties->ErrorRegularExpressions.size() > 0 )
        {
!       for ( passIt = this->TestProperties->ErrorRegularExpressions.begin();
!             passIt != this->TestProperties->ErrorRegularExpressions.end();
!             ++ passIt )
!         {
!         if ( passIt->first.find(this->ProcessOutput.c_str()) )
!           {
!           reason = "Error regular expression found in output.";
!           reason += " Regex=[";
!           reason += passIt->second;
!           reason += "]";
!           forceFail = true;
!           }
!         }
        }
!     if (res == cmsysProcess_State_Exited)
        {
!       bool success = 
!         !forceFail &&  (retVal == 0 || 
!         this->TestProperties->RequiredRegularExpressions.size());
!       if((success && !this->TestProperties->WillFail) 
!         || (!success && this->TestProperties->WillFail))
!         {
!         this->TestResult.Status = cmCTestTestHandler::COMPLETED;
!         cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Passed  " );
!         }
!       else
          {
!         this->TestResult.Status = cmCTestTestHandler::FAILED;
!         cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed  " << reason );
          }
        }
!     else if ( res == cmsysProcess_State_Expired )
        {
!       cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout");
!       this->TestResult.Status = cmCTestTestHandler::TIMEOUT;
        }
!     else if ( res == cmsysProcess_State_Exception )
        {
!       cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: ");
!       switch ( retVal )
!         {
!         case cmsysProcess_Exception_Fault:
!           cmCTestLog(this->CTest, HANDLER_OUTPUT, "SegFault");
!           this->TestResult.Status = cmCTestTestHandler::SEGFAULT;
!           break;
!         case cmsysProcess_Exception_Illegal:
!           cmCTestLog(this->CTest, HANDLER_OUTPUT, "Illegal");
!           this->TestResult.Status = cmCTestTestHandler::ILLEGAL;
!           break;
!         case cmsysProcess_Exception_Interrupt:
!           cmCTestLog(this->CTest, HANDLER_OUTPUT, "Interrupt");
!           this->TestResult.Status = cmCTestTestHandler::INTERRUPT;
!           break;
!         case cmsysProcess_Exception_Numerical:
!           cmCTestLog(this->CTest, HANDLER_OUTPUT, "Numerical");
!           this->TestResult.Status = cmCTestTestHandler::NUMERICAL;
!           break;
!         default:
!           cmCTestLog(this->CTest, HANDLER_OUTPUT, "Other");
!           this->TestResult.Status = cmCTestTestHandler::OTHER_FAULT;
!         }
        }
!     else // if ( res == cmsysProcess_State_Error )
        {
!       cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Bad command " << res );
!       this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND;
        }
  
!     passed = this->TestResult.Status == cmCTestTestHandler::COMPLETED;
  
!     char buf[1024];
!     sprintf(buf, "%6.2f sec", this->TestProcess->GetTotalTime());
!     cmCTestLog(this->CTest, HANDLER_OUTPUT, buf << "\n" );
!     if ( this->TestHandler->LogFile )
!       {
!       *this->TestHandler->LogFile << "Test time = " << buf << std::endl;
!       }
!     this->DartProcessing();
!     } 
    // if this is doing MemCheck then all the output needs to be put into
    // Output since that is what is parsed by cmCTestMemCheckHandler
--- 68,183 ----
    int res = this->TestProcess->GetProcessStatus();
    int retVal = this->TestProcess->GetExitValue();
! 
!   std::vector<std::pair<cmsys::RegularExpression,
!     std::string> >::iterator passIt;
!   bool forceFail = false;
!   if ( this->TestProperties->RequiredRegularExpressions.size() > 0 )
      {
!     bool found = false;
!     for ( passIt = this->TestProperties->RequiredRegularExpressions.begin();
!           passIt != this->TestProperties->RequiredRegularExpressions.end();
!           ++ passIt )
        {
!       if ( passIt->first.find(this->ProcessOutput.c_str()) )
          {
!         found = true;
!         reason = "Required regular expression found.";
          }
        }
!     if ( !found )
!       { 
!       reason = "Required regular expression not found.";
!       forceFail = true;
!       }
!     reason +=  "Regex=["; 
!     for ( passIt = this->TestProperties->RequiredRegularExpressions.begin();
!           passIt != this->TestProperties->RequiredRegularExpressions.end();
!           ++ passIt )
        {
!       reason += passIt->second;
!       reason += "\n";
        }
!     reason += "]";
!     }
!   if ( this->TestProperties->ErrorRegularExpressions.size() > 0 )
!     {
!     for ( passIt = this->TestProperties->ErrorRegularExpressions.begin();
!           passIt != this->TestProperties->ErrorRegularExpressions.end();
!           ++ passIt )
        {
!       if ( passIt->first.find(this->ProcessOutput.c_str()) )
          {
!         reason = "Error regular expression found in output.";
!         reason += " Regex=[";
!         reason += passIt->second;
!         reason += "]";
!         forceFail = true;
          }
        }
!     }
!   if (res == cmsysProcess_State_Exited)
!     {
!     bool success = 
!       !forceFail &&  (retVal == 0 || 
!       this->TestProperties->RequiredRegularExpressions.size());
!     if((success && !this->TestProperties->WillFail) 
!       || (!success && this->TestProperties->WillFail))
        {
!       this->TestResult.Status = cmCTestTestHandler::COMPLETED;
!       cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Passed  " );
        }
!     else
        {
!       this->TestResult.Status = cmCTestTestHandler::FAILED;
!       cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Failed  " << reason );
        }
!     }
!   else if ( res == cmsysProcess_State_Expired )
!     {
!     cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Timeout");
!     this->TestResult.Status = cmCTestTestHandler::TIMEOUT;
!     }
!   else if ( res == cmsysProcess_State_Exception )
!     {
!     cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Exception: ");
!     switch ( retVal )
        {
!       case cmsysProcess_Exception_Fault:
!         cmCTestLog(this->CTest, HANDLER_OUTPUT, "SegFault");
!         this->TestResult.Status = cmCTestTestHandler::SEGFAULT;
!         break;
!       case cmsysProcess_Exception_Illegal:
!         cmCTestLog(this->CTest, HANDLER_OUTPUT, "Illegal");
!         this->TestResult.Status = cmCTestTestHandler::ILLEGAL;
!         break;
!       case cmsysProcess_Exception_Interrupt:
!         cmCTestLog(this->CTest, HANDLER_OUTPUT, "Interrupt");
!         this->TestResult.Status = cmCTestTestHandler::INTERRUPT;
!         break;
!       case cmsysProcess_Exception_Numerical:
!         cmCTestLog(this->CTest, HANDLER_OUTPUT, "Numerical");
!         this->TestResult.Status = cmCTestTestHandler::NUMERICAL;
!         break;
!       default:
!         cmCTestLog(this->CTest, HANDLER_OUTPUT, "Other");
!         this->TestResult.Status = cmCTestTestHandler::OTHER_FAULT;
        }
+     }
+   else // if ( res == cmsysProcess_State_Error )
+     {
+     cmCTestLog(this->CTest, HANDLER_OUTPUT, "***Bad command " << res );
+     this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND;
+     }
  
!   passed = this->TestResult.Status == cmCTestTestHandler::COMPLETED;
  
!   char buf[1024];
!   sprintf(buf, "%6.2f sec", this->TestProcess->GetTotalTime());
!   cmCTestLog(this->CTest, HANDLER_OUTPUT, buf << "\n" );
!   if ( this->TestHandler->LogFile )
!     {
!     *this->TestHandler->LogFile << "Test time = " << buf << std::endl;
!     }
!   this->DartProcessing();
    // if this is doing MemCheck then all the output needs to be put into
    // Output since that is what is parsed by cmCTestMemCheckHandler
***************
*** 304,315 ****
    this->StartTime = this->CTest->CurrentTime();
  
!   if ( !this->CTest->GetShowOnly() )
!     {
!     return this->CreateProcess(this->ActualCommand,
!                                this->TestProperties->Args,
!                                this->TestProperties->Timeout,
!                                &this->TestProperties->Environment);
!     }
!   return true;
  }
  
--- 302,309 ----
    this->StartTime = this->CTest->CurrentTime();
  
!   return this->CreateProcess(this->ActualCommand,
!                              this->TestProperties->Args,
!                              this->TestProperties->Timeout,
!                              &this->TestProperties->Environment);
  }
  
***************
*** 450,462 ****
      << this->ProcessOutput.c_str() << "<end of output>" << std::endl;
  
!   if ( this->CTest->GetShowOnly() )
!     {
!     cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str() << std::endl);
!     }
!   else
!     {
!     cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str());
!     }
! 
    cmCTestLog(this->CTest, DEBUG, "Testing " 
               << this->TestProperties->Name.c_str() << " ... ");
--- 444,448 ----
      << this->ProcessOutput.c_str() << "<end of output>" << std::endl;
  
!   cmCTestLog(this->CTest, HANDLER_OUTPUT, outname.c_str());
    cmCTestLog(this->CTest, DEBUG, "Testing " 
               << this->TestProperties->Name.c_str() << " ... ");

Index: cmCTestGenericHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestGenericHandler.cxx,v
retrieving revision 1.21
retrieving revision 1.22
diff -C 2 -d -r1.21 -r1.22
*** cmCTestGenericHandler.cxx	15 Jan 2009 18:24:54 -0000	1.21
--- cmCTestGenericHandler.cxx	27 Aug 2009 14:37:26 -0000	1.22
***************
*** 167,176 ****
      }
    ostr << ".log";
-   // if this is a parallel subprocess then add the id to the
-   // file so they don't clobber each other
-   if(this->CTest->GetParallelSubprocess())
-     {
-     ostr << "." << this->CTest->GetParallelSubprocessId();
-     }
    if( !this->CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) )
      {
--- 167,170 ----

Index: cmCTestMultiProcessHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestMultiProcessHandler.cxx,v
retrieving revision 1.7
retrieving revision 1.8
diff -C 2 -d -r1.7 -r1.8
*** cmCTestMultiProcessHandler.cxx	26 Aug 2009 16:09:01 -0000	1.7
--- cmCTestMultiProcessHandler.cxx	27 Aug 2009 14:37:26 -0000	1.8
***************
*** 19,23 ****
  #include "cmStandardIncludes.h"
  #include "cmCTest.h"
! 
  
  cmCTestMultiProcessHandler::cmCTestMultiProcessHandler()
--- 19,24 ----
  #include "cmStandardIncludes.h"
  #include "cmCTest.h"
! #include "cmSystemTools.h"
! #include <stdlib.h>
  
  cmCTestMultiProcessHandler::cmCTestMultiProcessHandler()
***************
*** 40,43 ****
--- 41,45 ----
    this->Properties = properties;
  }
+ 
    // Set the max number of tests that can be run at the same time.
  void cmCTestMultiProcessHandler::SetParallelLevel(size_t level)
***************
*** 48,51 ****
--- 50,54 ----
  void cmCTestMultiProcessHandler::RunTests()
  {
+   this->CheckResume();
    this->StartNextTests();
    while(this->Tests.size() != 0)
***************
*** 58,61 ****
--- 61,65 ----
      {
      }
+   this->MarkFinished();
  }
  
***************
*** 177,181 ****
        }
      }
- 
    for( std::vector<cmCTestRunTest*>::iterator i = finished.begin();
         i != finished.end(); ++i)
--- 181,184 ----
***************
*** 200,203 ****
--- 203,207 ----
      this->TestRunningMap[test] = false;
      this->RunningTests.erase(p);
+     this->WriteCheckpoint(test);
  
      delete p;
***************
*** 206,209 ****
--- 210,230 ----
  }
  
+ void cmCTestMultiProcessHandler::WriteCheckpoint(int index)
+ {
+   std::string fname = this->CTest->GetBinaryDir()
+     + "/Testing/Temporary/CTestCheckpoint.txt";
+   std::fstream fout;
+   fout.open(fname.c_str(), std::ios::app);
+   fout << index << "\n";
+   fout.close();
+ }
+ 
+ void cmCTestMultiProcessHandler::MarkFinished()
+ {
+   std::string fname = this->CTest->GetBinaryDir()
+     + "/Testing/Temporary/CTestCheckpoint.txt";
+   cmSystemTools::RemoveFile(fname.c_str());
+ }
+ 
  void cmCTestMultiProcessHandler::PrintTests()
  {
***************
*** 222,225 ****
--- 243,288 ----
  }
  
+ //----------------------------------------------------------------
+ void cmCTestMultiProcessHandler::CheckResume()
+ {
+   std::string fname = this->CTest->GetBinaryDir()
+       + "/Testing/Temporary/CTestCheckpoint.txt";
+   if(this->CTest->GetFailover())
+     {
+     if(cmSystemTools::FileExists(fname.c_str(), true))
+       {
+       *this->TestHandler->LogFile << "Resuming previously interrupted test set"
+         << std::endl
+         << "----------------------------------------------------------"
+         << std::endl;
+         
+       std::ifstream fin;
+       fin.open(fname.c_str());
+       std::string line;
+       while(std::getline(fin, line))
+         {
+         int index = atoi(line.c_str());
+         this->RemoveTest(index);
+         }
+       fin.close();
+       }
+     }
+   else
+     {
+     if(cmSystemTools::FileExists(fname.c_str(), true))
+       {
+       cmSystemTools::RemoveFile(fname.c_str());
+       }
+     }
+ }
+ 
+ void cmCTestMultiProcessHandler::RemoveTest(int index)
+ {
+   this->Tests.erase(index);
+   this->Properties.erase(index);
+   this->TestRunningMap[index] = false;
+   this->TestFinishMap[index] = true;
+ }
+ 
  #if 0
  int main()

Index: cmCTestTestHandler.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestTestHandler.h,v
retrieving revision 1.40
retrieving revision 1.41
diff -C 2 -d -r1.40 -r1.41
*** cmCTestTestHandler.h	26 Aug 2009 16:09:06 -0000	1.40
--- cmCTestTestHandler.h	27 Aug 2009 14:37:27 -0000	1.41
***************
*** 142,145 ****
--- 142,146 ----
    void WriteTestResultFooter(std::ostream& os, cmCTestTestResult* result);
  
+   void PrintTestList();
    //! Clean test output to specified length
    bool CleanTestOutput(std::string& output, size_t length);
***************
*** 204,211 ****
    void ComputeTestList();
    
-   // Save the state of the test list and return the file
-   // name it was saved to
-   std::string SaveTestList();
-   void LoadTestList();
    bool GetValue(const char* tag,
                  std::string& value,
--- 205,208 ----

Index: cmCTestMultiProcessHandler.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestMultiProcessHandler.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -C 2 -d -r1.4 -r1.5
*** cmCTestMultiProcessHandler.h	26 Aug 2009 16:09:03 -0000	1.4
--- cmCTestMultiProcessHandler.h	27 Aug 2009 14:37:26 -0000	1.5
***************
*** 69,76 ****
    void StartTestProcess(int test);
    bool StartTest(int test);
!   //void EndTest(cmProcess*);
    // Return true if there are still tests running
    // check all running processes for output and exit case
    bool CheckOutput();
    // map from test number to set of depend tests
    TestMap Tests;
--- 69,82 ----
    void StartTestProcess(int test);
    bool StartTest(int test);
!   // Mark the checkpoint for the given test
!   void WriteCheckpoint(int index);
!   // Removes the checkpoint file
!   void MarkFinished();
    // Return true if there are still tests running
    // check all running processes for output and exit case
    bool CheckOutput();
+   void RemoveTest(int index);
+   //Check if we need to resume an interrupted test set
+   void CheckResume();
    // map from test number to set of depend tests
    TestMap Tests;
***************
*** 80,85 ****
    std::map<int, bool> TestFinishMap;
    std::map<int, cmStdString> TestOutput;
-   //std::string CTestCommand;
-   //std::string CTestCacheFile;
    std::vector<cmStdString>* Passed;
    std::vector<cmStdString>* Failed;
--- 86,89 ----

Index: cmCTestTestHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestTestHandler.cxx,v
retrieving revision 1.106
retrieving revision 1.107
diff -C 2 -d -r1.106 -r1.107
*** cmCTestTestHandler.cxx	26 Aug 2009 16:09:06 -0000	1.106
--- cmCTestTestHandler.cxx	27 Aug 2009 14:37:26 -0000	1.107
***************
*** 524,535 ****
    
    this->TestResults.clear();
!  // do not output startup if this is a sub-process for parallel tests
!   if(!this->CTest->GetParallelSubprocess())
!     {
!     cmCTestLog(this->CTest, HANDLER_OUTPUT,
!                (this->MemCheck ? "Memory check" : "Test")
!                << " project " << cmSystemTools::GetCurrentWorkingDirectory()
!                << std::endl);
!     }
    if ( ! this->PreProcessHandler() )
      {
--- 524,532 ----
    
    this->TestResults.clear();
! 
!   cmCTestLog(this->CTest, HANDLER_OUTPUT,
!              (this->MemCheck ? "Memory check" : "Test")
!              << " project " << cmSystemTools::GetCurrentWorkingDirectory()
!              << std::endl);
    if ( ! this->PreProcessHandler() )
      {
***************
*** 584,638 ****
        }
      
!     if(!this->CTest->GetParallelSubprocess())
!       {
!       cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
!                  << static_cast<int>(percent + .5) << "% tests passed, "
!                  << failed.size() << " tests failed out of " 
!                  << total << std::endl); 
!       double totalTestTime = 0;
! 
!       for(cmCTestTestHandler::TestResultsVector::size_type cc = 0;
!           cc < this->TestResults.size(); cc ++ )
!         {
!         cmCTestTestResult *result = &this->TestResults[cc];
!         totalTestTime += result->ExecutionTime;
!         }
!       
!       char realBuf[1024];
!       sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start));
!       cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time (real) = "
!                  << realBuf << "\n" );
  
!       char totalBuf[1024];
!       sprintf(totalBuf, "%6.2f sec", totalTestTime); 
!       cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time (parallel) = " 
!                  <<  totalBuf << "\n" );
!       
        }
  
      if (failed.size())
        {
        cmGeneratedFileStream ofs;
!       if(!this->CTest->GetParallelSubprocess())
          {
!         cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl
!                    << "The following tests FAILED:" << std::endl);
!         this->StartLogFile("TestsFailed", ofs);
!         
!         std::vector<cmCTestTestHandler::cmCTestTestResult>::iterator ftit;
!         for(ftit = this->TestResults.begin();
!             ftit != this->TestResults.end(); ++ftit)
            {
!           if ( ftit->Status != cmCTestTestHandler::COMPLETED )
!             {
!             ofs << ftit->TestCount << ":" << ftit->Name << std::endl;
!             cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3)
!                        << ftit->TestCount << " - " 
!                        << ftit->Name.c_str() << " ("
!                        << this->GetTestStatus(ftit->Status) << ")" 
!                        << std::endl);
!             }
            }
-         
          }
        }
--- 581,627 ----
        }
      
!     cmCTestLog(this->CTest, HANDLER_OUTPUT, std::endl
!                << static_cast<int>(percent + .5) << "% tests passed, "
!                << failed.size() << " tests failed out of " 
!                << total << std::endl); 
!     double totalTestTime = 0;
  
!     for(cmCTestTestHandler::TestResultsVector::size_type cc = 0;
!         cc < this->TestResults.size(); cc ++ )
!       {
!       cmCTestTestResult *result = &this->TestResults[cc];
!       totalTestTime += result->ExecutionTime;
        }
+     
+     char realBuf[1024];
+     sprintf(realBuf, "%6.2f sec", (double)(clock_finish - clock_start));
+     cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time (real) = "
+                << realBuf << "\n" );
+ 
+     char totalBuf[1024];
+     sprintf(totalBuf, "%6.2f sec", totalTestTime); 
+     cmCTestLog(this->CTest, HANDLER_OUTPUT, "\nTotal Test time (parallel) = "
+                <<  totalBuf << "\n" );
  
      if (failed.size())
        {
        cmGeneratedFileStream ofs;
!       cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl
!                  << "The following tests FAILED:" << std::endl);
!       this->StartLogFile("TestsFailed", ofs);
!       
!       std::vector<cmCTestTestHandler::cmCTestTestResult>::iterator ftit;
!       for(ftit = this->TestResults.begin();
!           ftit != this->TestResults.end(); ++ftit)
          {
!         if ( ftit->Status != cmCTestTestHandler::COMPLETED )
            {
!           ofs << ftit->TestCount << ":" << ftit->Name << std::endl;
!           cmCTestLog(this->CTest, HANDLER_OUTPUT, "\t" << std::setw(3)
!                      << ftit->TestCount << " - " 
!                      << ftit->Name.c_str() << " ("
!                      << this->GetTestStatus(ftit->Status) << ")" 
!                      << std::endl);
            }
          }
        }
***************
*** 809,813 ****
    int retVal = 0;
    
-   
    cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, std::endl
               << (this->MemCheck?"MemCheck":"Test") 
--- 798,801 ----
***************
*** 840,846 ****
      }
  
!   clock_finish = cmSystemTools::GetTime();  
! 
! 
    
    cres.ExecutionTime = (double)(clock_finish - clock_start);
--- 828,832 ----
      }
  
!   clock_finish = cmSystemTools::GetTime();
    
    cres.ExecutionTime = (double)(clock_finish - clock_start);
***************
*** 1119,1131 ****
  {
    this->TestList.clear(); // clear list of test
!   if(this->CTest->GetParallelSubprocess())
!     {
!     this->LoadTestList();
!     return;
!     }
!   else
!     {
!     this->GetListOfTests();
!     }
    cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size();
    // how many tests are in based on RegExp?
--- 1105,1109 ----
  {
    this->TestList.clear(); // clear list of test
!   this->GetListOfTests();
    cmCTestTestHandler::ListOfTests::size_type tmsize = this->TestList.size();
    // how many tests are in based on RegExp?
***************
*** 1326,1548 ****
  }
  
! 
! // This should load only one test and is used in -j N mode.
! // it is used by the sub-process ctest runs which should have
! // only one -I N test to run.
! void cmCTestTestHandler::LoadTestList()
! {
!   this->TestList.clear();
!   std::string fname = this->CTest->GetBinaryDir()
!     + "/Testing/Temporary/PCache.txt";
!   std::ifstream fin(fname.c_str());
!   std::string line;
!   if(!fin)
!     {
!     cmCTestLog(this->CTest, ERROR_MESSAGE,
!                "Could not load PCache.txt file: "
!                << fname.c_str() << std::endl);
!     return;
!     }
!   bool ok = true;
!   int numTestsToRun = 0;
!   ok = ok && this->GetValue("TotalNumberOfTests:", 
!                             this->TotalNumberOfTests, fin);
!   ok = ok && this->GetValue("NumberOfTestsToRun:", numTestsToRun, fin);
!   this->ExpandTestsToRunInformation(this->TotalNumberOfTests);
!   if(this->TestsToRun.size() != 1)
!     { 
!     cmCTestLog(this->CTest, ERROR_MESSAGE,
!                "Error when in parallel mode only one test should be run: "
!                << this->TestsToRun.size() << std::endl);
!     }
!   int testIndexToRun = this->TestsToRun[0];
!   this->CTest->SetParallelSubprocessId(testIndexToRun);
!   if(!ok)
!     {
!     return;
!     }
!   for(int i =0; i < numTestsToRun; i++)
!     {
!     cmCTestTestProperties p;
!     int numArgs = 0;
!     ok = this->GetValue("Name:", p.Name, fin);
!     ok = ok && this->GetValue("Directory:", p.Directory, fin);
!     ok = ok && this->GetValue("Args:", numArgs, fin);
!     for(int j =0; j < numArgs; ++j)
!       {
!       cmSystemTools::GetLineFromStream(fin, line);
!       p.Args.push_back(line);
!       }
!     int numDep = 0;
!     ok = ok && this->GetValue("Depends:", numDep, fin);
!     for(int j =0; j < numDep; ++j)
!       {
!       cmSystemTools::GetLineFromStream(fin, line);
!       p.Depends.push_back(line);
!       }
!     int numErrRegex = 0;
!     ok = ok && this->GetValue("ErrorRegularExpressions:", 
!                               numErrRegex, fin);
!     for(int j =0; j < numErrRegex; j++)
!       {
!       cmSystemTools::GetLineFromStream(fin, line);
!       std::pair<cmsys::RegularExpression, std::string> rpair;
!       rpair.first.compile(line.c_str());
!       rpair.second = line;
!       p.ErrorRegularExpressions.push_back(rpair);
!       }
!     int numReqRegex = 0;
!     ok = ok && this->GetValue("RequiredRegularExpressions:", 
!                               numReqRegex, fin);
!     for(int j =0; j < numReqRegex; j++)
!       {
!       cmSystemTools::GetLineFromStream(fin, line);
!       std::pair<cmsys::RegularExpression, std::string> rpair;
!       rpair.first.compile(line.c_str());
!       rpair.second = line;
!       p.RequiredRegularExpressions.push_back(rpair);
!       }
!     int numMeasure = 0;
!     ok = ok && this->GetValue("Measurements:", 
!                               numMeasure, fin);
!     for(int j =0; j < numMeasure; j++)
!       {
!       cmStdString m;
!       cmStdString v;
!       cmSystemTools::GetLineFromStream(fin, line);
!       m = line;
!       cmSystemTools::GetLineFromStream(fin, line);
!       v = line;
!       p.Measurements[m] = v;
!       }
!     int isinre;
!     ok = ok && this->GetValue("IsInBasedOnREOptions:", isinre, fin);
!     ok = ok && this->GetValue("WillFail:", p.WillFail, fin);
!     ok = ok && this->GetValue("TimeOut:", p.Timeout, fin);
!     ok = ok && this->GetValue("Index:", p.Index, fin);
!     int numEnv = 0;
!     ok = ok && this->GetValue("Environment:", 
!                               numEnv, fin);
!     for(int j =0; j < numEnv; j++)
!       {
!       cmSystemTools::GetLineFromStream(fin, line);
!       p.Environment.push_back(line);
!       }
!     int numLabels = 0;
!     ok = ok && this->GetValue("Labels:",
!                               numLabels, fin);
!     for(int j =0; j < numLabels; j++)
!       {
!       cmSystemTools::GetLineFromStream(fin, line);
!       p.Labels.push_back(line);
!       }
!     if(!ok)
!       {
!       cmCTestLog(this->CTest, ERROR_MESSAGE,
!                  "Internal Error reading cached test information."
!                  << std::endl);
!       return;
!       }
!     if(p.Index == testIndexToRun)
!       {
!       // add the one test and stop reading
!       this->TestList.push_back(p);
!       return;
!       }
!     }
! }
! std::string cmCTestTestHandler::SaveTestList()
  {
!   std::string fname = this->CTest->GetBinaryDir()
!     + "/Testing/Temporary/PCache.txt";
!   cmGeneratedFileStream fout(fname.c_str());
!   if(!fout)
!     {
!     cmCTestLog(this->CTest, ERROR_MESSAGE, std::endl
!                << "Could not open PCache.txt for write:" 
!                << fname.c_str()
!                << std::endl);
!     }
!   fout << "TotalNumberOfTests:\n";
!   fout << this->TotalNumberOfTests << "\n";
!   fout << "NumberOfTestsToRun:\n";
!   fout << this->TestList.size() << "\n";
    for (ListOfTests::iterator it = this->TestList.begin();
         it != this->TestList.end(); it ++ )
!     {
      cmCTestTestProperties& p = *it;
!     fout << "Name:\n"
!          << p.Name.c_str()
!          << "\nDirectory:\n"
!          << p.Directory.c_str()
!          << "\nArgs:\n"
!          << p.Args.size() << "\n";
!     for(std::vector<std::string>::iterator i = p.Args.begin();
!         i != p.Args.end(); ++i)
!       {
!       fout << i->c_str() << "\n";
!       }
!     fout << "Depends:\n" << p.Depends.size() << "\n";
!     for(std::vector<std::string>::iterator i = p.Depends.begin();
!         i != p.Depends.end(); ++i)
!       {
!       fout << i->c_str() << "\n";
!       }
!     std::vector<std::pair<cmsys::RegularExpression,
!       std::string> >::iterator regxi;
!     fout << "ErrorRegularExpressions:\n" << 
!       p.ErrorRegularExpressions.size() << "\n";
!     for(regxi  = p.ErrorRegularExpressions.begin(); 
!         regxi != p.ErrorRegularExpressions.end(); regxi++)
!       {
!       fout << regxi->second << "\n";
!       }
!     fout << "RequiredRegularExpressions:\n" << 
!       p.RequiredRegularExpressions.size() << "\n";
!     for(regxi  = p.RequiredRegularExpressions.begin(); 
!         regxi != p.RequiredRegularExpressions.end(); regxi++)
!       {
!       fout << regxi->second << "\n";
!       }
!     fout << "Measurements:\n" << 
!       p.Measurements.size() << "\n";
!     for(std::map<cmStdString, cmStdString>::const_iterator m =
!           p.Measurements.begin(); m != p.Measurements.end(); ++m)
!       {
!       fout << m->first << "\n";
!       fout << m->second << "\n";
!       }
! 
!     fout << "IsInBasedOnREOptions:\n"
!          << p.IsInBasedOnREOptions
!          << "\nWillFail:\n"
!          << p.WillFail
!          << "\nTimeOut:\n"
!          << p.Timeout
!          << "\nIndex:\n"
!          << p.Index << "\n";
!     fout << "Environment:\n" << 
!       p.Environment.size() << "\n";
!     for(std::vector<std::string>::const_iterator e =
!           p.Environment.begin(); e != p.Environment.end(); ++e)
        {
!       fout << *e << "\n";
        }
!     fout << "Labels:\n" <<
!       p.Labels.size() << "\n";
!     for(std::vector<std::string>::const_iterator e =
!           p.Labels.begin(); e != p.Labels.end(); ++e)
        {
!       fout << *e << "\n";
        }
      }
-   fout.close();
-   return fname;
  }
  
  void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
                                           std::vector<cmStdString> &failed)
  {
    this->ComputeTestList();
    cmCTestMultiProcessHandler parallel;
    parallel.SetCTest(this->CTest);
--- 1304,1343 ----
  }
  
! //---------------------------------------------------------------------
! void cmCTestTestHandler::PrintTestList()
  {
!   int total = this->TotalNumberOfTests;
    for (ListOfTests::iterator it = this->TestList.begin();
         it != this->TestList.end(); it ++ )
!     { 
      cmCTestTestProperties& p = *it;
!     cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3) 
!              << p.Index << "/");
!     cmCTestLog(this->CTest, HANDLER_OUTPUT, std::setw(3) 
!              << total << " ");
!     if (this->MemCheck)
        {
!       cmCTestLog(this->CTest, HANDLER_OUTPUT, "Memory Check");
        }
!      else
        {
!       cmCTestLog(this->CTest, HANDLER_OUTPUT, "Testing");
        }
+     cmCTestLog(this->CTest, HANDLER_OUTPUT, " ");
+     cmCTestLog(this->CTest, HANDLER_OUTPUT, p.Name.c_str() << std::endl);
      }
  }
  
+ //---------------------------------------------------------------------
  void cmCTestTestHandler::ProcessDirectory(std::vector<cmStdString> &passed,
                                           std::vector<cmStdString> &failed)
  {
    this->ComputeTestList();
+ 
+   if(this->CTest->GetShowOnly())
+     {
+     this->PrintTestList();
+     return;
+     }
    cmCTestMultiProcessHandler parallel;
    parallel.SetCTest(this->CTest);

Index: cmCTestRunTest.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestRunTest.h,v
retrieving revision 1.2
retrieving revision 1.3
diff -C 2 -d -r1.2 -r1.3
*** cmCTestRunTest.h	26 Aug 2009 16:09:06 -0000	1.2
--- cmCTestRunTest.h	27 Aug 2009 14:37:26 -0000	1.3
***************
*** 64,68 ****
                       double testTimeOut,
                       std::vector<std::string>* environment);
! private:
    cmCTestTestHandler::cmCTestTestProperties * TestProperties;
    //Pointer back to the "parent"; the handler that invoked this test run
--- 64,69 ----
                       double testTimeOut,
                       std::vector<std::string>* environment);
!   void WriteLogOutputTop();
! 
    cmCTestTestHandler::cmCTestTestProperties * TestProperties;
    //Pointer back to the "parent"; the handler that invoked this test run
***************
*** 86,90 ****
    std::string TestCommand;
    std::string ActualCommand;
-   void WriteLogOutputTop();
  };
  
--- 87,90 ----



More information about the Cmake-commits mailing list