[Cmake-commits] [cmake-commits] zach.mullen committed cmCTestRunTest.cxx 1.30 1.31 cmCTestRunTest.h 1.13 1.14 cmCTestTestHandler.cxx 1.130 1.131 cmCTestTestHandler.h 1.50 1.51

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Dec 10 14:38:34 EST 2009


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

Modified Files:
	cmCTestRunTest.cxx cmCTestRunTest.h cmCTestTestHandler.cxx 
	cmCTestTestHandler.h 
Log Message:
[0008668: CTest Dev: Missing executables shown as failed tests when using MPI.]  Added a wrapping option to add_test so that exes built by the project can be safely wrapped in other exes and be listed as "not run" rather than "failed" if they are not built.


Index: cmCTestTestHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestTestHandler.cxx,v
retrieving revision 1.130
retrieving revision 1.131
diff -C 2 -d -r1.130 -r1.131
*** cmCTestTestHandler.cxx	8 Dec 2009 15:26:43 -0000	1.130
--- cmCTestTestHandler.cxx	10 Dec 2009 19:38:32 -0000	1.131
***************
*** 270,274 ****
      return false;
      }
!   return this->TestHandler->AddTest(args);
  }
  
--- 270,297 ----
      return false;
      }
! 
!   bool prefixCmdFound = false;
!   std::vector<std::string> actualArgs, prefix;
! 
!   //separate the regular command and the prefix command (bug 8668)
!   for(std::vector<std::string>::const_iterator i = args.begin();
!       i != args.end(); ++i)
!     {
!     if(*i == "EXEC_PREFIX_CMD")
!       {
!       prefixCmdFound = true;
!       continue;
!       }
!     if(prefixCmdFound)
!       {
!       prefix.push_back(*i);
!       }
!     else
!       {
!       actualArgs.push_back(*i);
!       }
!     }
! 
!   return this->TestHandler->AddTest(actualArgs, prefix);
  }
  
***************
*** 2105,2112 ****
  
  //----------------------------------------------------------------------
! bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
  {
    const std::string& testname = args[0];
    cmCTestLog(this->CTest, DEBUG, "Add test: " << args[0] << std::endl);
    if (this->UseExcludeRegExpFlag &&
      this->UseExcludeRegExpFirst &&
--- 2128,2137 ----
  
  //----------------------------------------------------------------------
! bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args,
!                                  const std::vector<std::string>& prefix)
  {
    const std::string& testname = args[0];
    cmCTestLog(this->CTest, DEBUG, "Add test: " << args[0] << std::endl);
+ 
    if (this->UseExcludeRegExpFlag &&
      this->UseExcludeRegExpFirst &&
***************
*** 2159,2162 ****
--- 2184,2188 ----
    test.Name = testname;
    test.Args = args;
+   test.PrefixArgs = prefix;
    test.Directory = cmSystemTools::GetCurrentWorkingDirectory();
    cmCTestLog(this->CTest, DEBUG, "Set test directory: "

Index: cmCTestTestHandler.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestTestHandler.h,v
retrieving revision 1.50
retrieving revision 1.51
diff -C 2 -d -r1.50 -r1.51
*** cmCTestTestHandler.h	28 Sep 2009 15:43:02 -0000	1.50
--- cmCTestTestHandler.h	10 Dec 2009 19:38:32 -0000	1.51
***************
*** 67,71 ****
     * Add the test to the list of tests to be executed
     */
!   bool AddTest(const std::vector<std::string>& args);
  
    /*
--- 67,72 ----
     * Add the test to the list of tests to be executed
     */
!   bool AddTest(const std::vector<std::string>& args,
!                const std::vector<std::string>& prefix);
  
    /*
***************
*** 85,88 ****
--- 86,90 ----
      cmStdString Directory;
      std::vector<std::string> Args;
+     std::vector<std::string> PrefixArgs;
      std::vector<std::string> Depends;
      std::vector<std::pair<cmsys::RegularExpression,

Index: cmCTestRunTest.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestRunTest.h,v
retrieving revision 1.13
retrieving revision 1.14
diff -C 2 -d -r1.13 -r1.14
*** cmCTestRunTest.h	5 Oct 2009 14:20:52 -0000	1.13
--- cmCTestRunTest.h	10 Dec 2009 19:38:32 -0000	1.14
***************
*** 54,57 ****
--- 54,58 ----
  private:
    void DartProcessing();
+   void ExeNotFound(std::string exe);
    bool CreateProcess(double testTimeOut,
                       std::vector<std::string>* environment);
***************
*** 72,75 ****
--- 73,80 ----
    //flag for whether the env was modified for this run
    bool ModifyEnv;
+ 
+   bool UsePrefixCommand;
+   std::string PrefixCommand;
+ 
    //stores the original environment if we are modifying it
    std::vector<std::string> OrigEnv;
***************
*** 97,100 ****
--- 102,106 ----
    return numWidth;
  }
+ 
  #endif
  

Index: cmCTestRunTest.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestRunTest.cxx,v
retrieving revision 1.30
retrieving revision 1.31
diff -C 2 -d -r1.30 -r1.31
*** cmCTestRunTest.cxx	2 Dec 2009 21:37:43 -0000	1.30
--- cmCTestRunTest.cxx	10 Dec 2009 19:38:32 -0000	1.31
***************
*** 27,30 ****
--- 27,32 ----
    this->TestResult.TestCount = 0;
    this->TestResult.Properties = 0;
+   this->PrefixCommand = "";
+   this->UsePrefixCommand = false;
  }
  
***************
*** 304,307 ****
--- 306,310 ----
    this->ComputeArguments();
    std::vector<std::string>& args = this->TestProperties->Args;
+   std::vector<std::string>& pargs = this->TestProperties->PrefixArgs;
    this->TestResult.Properties = this->TestProperties;
    this->TestResult.ExecutionTime = 0;
***************
*** 309,330 ****
    this->TestResult.CompletionStatus = "Failed to start";
    this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND;
!   this->TestResult.TestCount = this->TestProperties->Index;  
    this->TestResult.Name = this->TestProperties->Name;
    this->TestResult.Path = this->TestProperties->Directory.c_str();
    
    // log and return if we did not find the executable
    if (this->ActualCommand == "")
      {
!     // if the command was not found create a TestResult object
!     // that has that information 
!     this->TestProcess = new cmProcess;
!     *this->TestHandler->LogFile << "Unable to find executable: " 
!                    << args[1].c_str() << std::endl;
!     cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: "
!                << args[1].c_str() << std::endl);
!     this->TestResult.Output = "Unable to find executable: " + args[1];
!     this->TestResult.FullCommandLine = "";
!     this->TestResult.CompletionStatus = "Not Run";
!     this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
      return false;
      }
--- 312,330 ----
    this->TestResult.CompletionStatus = "Failed to start";
    this->TestResult.Status = cmCTestTestHandler::BAD_COMMAND;
!   this->TestResult.TestCount = this->TestProperties->Index;
    this->TestResult.Name = this->TestProperties->Name;
    this->TestResult.Path = this->TestProperties->Directory.c_str();
    
+   // if we are using a prefix command, make sure THAT executable exists
+   if (this->UsePrefixCommand && this->PrefixCommand == "")
+     {
+     this->ExeNotFound(pargs[0]);
+     return false;
+     }
+ 
    // log and return if we did not find the executable
    if (this->ActualCommand == "")
      {
!     this->ExeNotFound(args[1]);
      return false;
      }
***************
*** 335,338 ****
--- 335,352 ----
  }
  
+ void cmCTestRunTest::ExeNotFound(std::string exe)
+ {
+   this->TestProcess = new cmProcess;
+   *this->TestHandler->LogFile << "Unable to find executable: "
+              << exe.c_str() << std::endl;
+   cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find executable: "
+              << exe.c_str() << std::endl);
+   this->TestResult.Output = "Unable to find executable: " + exe;
+   this->TestResult.FullCommandLine = "";
+   this->TestResult.CompletionStatus = "Not Run";
+   this->TestResult.Reason = "";
+   this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
+ }
+ 
  void cmCTestRunTest::ComputeArguments()
  {
***************
*** 341,344 ****
--- 355,368 ----
    ++j; // skip test name
  
+   this->TestCommand = "";
+ 
+   //If we are using a prefix command, find the exe for it
+   if(this->TestProperties->PrefixArgs.size())
+     {
+     this->UsePrefixCommand = true;
+     this->PrefixCommand = this->TestHandler->FindTheExecutable(
+       this->TestProperties->PrefixArgs[0].c_str());
+     }
+ 
    // find the test executable
    if(this->TestHandler->MemCheck)
***************
*** 355,360 ****
      ++j; //skip the executable (it will be actualCommand)
      }
-   this->TestCommand
-     = cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
  
    //Prepends memcheck args to our command string
--- 379,382 ----
***************
*** 366,369 ****
--- 388,412 ----
      this->TestCommand += cmSystemTools::EscapeSpaces(j->c_str());
      }
+   //Add user specified prefix args
+   if(this->UsePrefixCommand)
+     {
+     this->TestCommand +=
+       cmSystemTools::ConvertToOutputPath(this->PrefixCommand.c_str());
+ 
+     std::vector<std::string>::iterator i = 
+         this->TestProperties->PrefixArgs.begin();
+     ++i; //skip the exe name
+     for(; i != this->TestProperties->PrefixArgs.end(); ++i)
+       {
+       this->TestCommand += " ";
+       this->TestCommand += cmSystemTools::EscapeSpaces(i->c_str());
+       this->Arguments.push_back(*i);
+       }
+     this->Arguments.push_back(this->ActualCommand);
+     this->TestCommand += " ";
+     }
+   //Add regular test args
+   this->TestCommand
+     += cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
  
    for(;j != this->TestProperties->Args.end(); ++j)
***************
*** 412,416 ****
    this->TestProcess->SetWorkingDirectory(
          this->TestProperties->Directory.c_str());
!   this->TestProcess->SetCommand(this->ActualCommand.c_str());
    this->TestProcess->SetCommandArguments(this->Arguments);
  
--- 455,461 ----
    this->TestProcess->SetWorkingDirectory(
          this->TestProperties->Directory.c_str());
!   this->TestProcess->SetCommand(this->UsePrefixCommand ?
!     this->PrefixCommand.c_str() :
!     this->ActualCommand.c_str());
    this->TestProcess->SetCommandArguments(this->Arguments);
  



More information about the Cmake-commits mailing list