[Cmake-commits] [cmake-commits] zach.mullen committed cmCTestRunTest.cxx 1.31 1.32 cmCTestTestHandler.cxx 1.131 1.132 cmCTestTestHandler.h 1.51 1.52

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Dec 10 15:37:06 EST 2009


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

Modified Files:
	cmCTestRunTest.cxx cmCTestTestHandler.cxx cmCTestTestHandler.h 
Log Message:
Unfortunately, I noticed the comment on bug 8668 too late.  This changes my last implementation of the exe wrapper to something which makes much more sense: a REQUIRED_FILES property on tests.


Index: cmCTestTestHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestTestHandler.cxx,v
retrieving revision 1.131
retrieving revision 1.132
diff -C 2 -d -r1.131 -r1.132
*** cmCTestTestHandler.cxx	10 Dec 2009 19:38:32 -0000	1.131
--- cmCTestTestHandler.cxx	10 Dec 2009 20:36:58 -0000	1.132
***************
*** 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);
  }
  
--- 270,274 ----
      return false;
      }
!   return this->TestHandler->AddTest(args);
  }
  
***************
*** 2037,2040 ****
--- 2014,2021 ----
              rtit->Cost = static_cast<float>(atof(val.c_str()));
              }
+           if ( key == "REQUIRED_FILE" )
+             {
+             rtit->RequiredFiles.push_back(val);
+             }
            if ( key == "RUN_SERIAL" )
              {
***************
*** 2128,2133 ****
  
  //----------------------------------------------------------------------
! bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args,
!                                  const std::vector<std::string>& prefix)
  {
    const std::string& testname = args[0];
--- 2109,2113 ----
  
  //----------------------------------------------------------------------
! bool cmCTestTestHandler::AddTest(const std::vector<std::string>& args)
  {
    const std::string& testname = args[0];
***************
*** 2184,2188 ****
    test.Name = testname;
    test.Args = args;
-   test.PrefixArgs = prefix;
    test.Directory = cmSystemTools::GetCurrentWorkingDirectory();
    cmCTestLog(this->CTest, DEBUG, "Set test directory: "
--- 2164,2167 ----

Index: cmCTestTestHandler.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestTestHandler.h,v
retrieving revision 1.51
retrieving revision 1.52
diff -C 2 -d -r1.51 -r1.52
*** cmCTestTestHandler.h	10 Dec 2009 19:38:32 -0000	1.51
--- cmCTestTestHandler.h	10 Dec 2009 20:37:04 -0000	1.52
***************
*** 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);
  
    /*
--- 67,71 ----
     * Add the test to the list of tests to be executed
     */
!   bool AddTest(const std::vector<std::string>& args);
  
    /*
***************
*** 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,
--- 85,89 ----
      cmStdString Directory;
      std::vector<std::string> Args;
!     std::vector<std::string> RequiredFiles;
      std::vector<std::string> Depends;
      std::vector<std::pair<cmsys::RegularExpression,

Index: cmCTestRunTest.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestRunTest.cxx,v
retrieving revision 1.31
retrieving revision 1.32
diff -C 2 -d -r1.31 -r1.32
*** cmCTestRunTest.cxx	10 Dec 2009 19:38:32 -0000	1.31
--- cmCTestRunTest.cxx	10 Dec 2009 20:36:58 -0000	1.32
***************
*** 27,32 ****
    this->TestResult.TestCount = 0;
    this->TestResult.Properties = 0;
-   this->PrefixCommand = "";
-   this->UsePrefixCommand = false;
  }
  
--- 27,30 ----
***************
*** 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;
--- 304,307 ----
***************
*** 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;
      }
--- 309,352 ----
    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();
    
!   // Check if all required files exist
!   for(std::vector<std::string>::iterator i =
!     this->TestProperties->RequiredFiles.begin();
!     i != this->TestProperties->RequiredFiles.end(); ++i)
      {
!     std::string file = *i;
  
+     if(!cmSystemTools::FileExists(file.c_str()))
+       {
+       //Required file was not found
+       this->TestProcess = new cmProcess;
+       *this->TestHandler->LogFile << "Unable to find required file: "
+                << file.c_str() << std::endl;
+       cmCTestLog(this->CTest, ERROR_MESSAGE, "Unable to find required file: "
+                << file.c_str() << std::endl);
+       this->TestResult.Output = "Unable to find required file: " + file;
+       this->TestResult.FullCommandLine = "";
+       this->TestResult.CompletionStatus = "Not Run";
+       this->TestResult.Status = cmCTestTestHandler::NOT_RUN;
+       return false;
+       }
+     }
    // 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;
      }
***************
*** 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()
  {
--- 357,360 ----
***************
*** 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)
--- 363,366 ----
***************
*** 379,382 ****
--- 377,382 ----
      ++j; //skip the executable (it will be actualCommand)
      }
+   this->TestCommand
+     = cmSystemTools::ConvertToOutputPath(this->ActualCommand.c_str());
  
    //Prepends memcheck args to our command string
***************
*** 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)
--- 388,391 ----
***************
*** 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);
  
--- 434,438 ----
    this->TestProcess->SetWorkingDirectory(
          this->TestProperties->Directory.c_str());
!   this->TestProcess->SetCommand(this->ActualCommand.c_str());
    this->TestProcess->SetCommandArguments(this->Arguments);
  



More information about the Cmake-commits mailing list