[Cmake-commits] [cmake-commits] king committed cmCTestStartCommand.cxx 1.17 1.18 cmCTestStartCommand.h 1.7 1.8 cmCTestUpdateCommand.cxx 1.19 1.20 cmCTestUpdateHandler.cxx 1.68 1.69 cmCTestUpdateHandler.h 1.15 1.16

cmake-commits at cmake.org cmake-commits at cmake.org
Tue Nov 24 08:59:01 EST 2009


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

Modified Files:
	cmCTestStartCommand.cxx cmCTestStartCommand.h 
	cmCTestUpdateCommand.cxx cmCTestUpdateHandler.cxx 
	cmCTestUpdateHandler.h 
Log Message:
CTest: Move initial checkout to ctest_start()

In CTest command-driven script mode we support starting without a source
tree.  Previously the ctest_start() command would do some initialization
but could not do anything that required CTestConfig.cmake from the input
source tree.  Later, ctest_update() would run CTEST_CHECKOUT_COMMAND to
create the source tree, and then re-initialize everything.  This
delayed-initialization approach led to many complicated cases of which
only some worked.  For example, the second initialization only worked
correctly in Nightly mode and simply failed for Experimental and
Continuous builds.

A simpler solution is to run CTEST_CHECKOUT_COMMAND during ctest_start()
and then have a single initialization path.  In principle this change in
behavior could break scripts that set the checkout command after
ctest_start() but before ctest_update().  However, the convention we've
always followed has been to set all variables before ctest_start().

See issue #9450.


Index: cmCTestUpdateHandler.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestUpdateHandler.cxx,v
retrieving revision 1.68
retrieving revision 1.69
diff -C 2 -d -r1.68 -r1.69
*** cmCTestUpdateHandler.cxx	28 Sep 2009 15:43:02 -0000	1.68
--- cmCTestUpdateHandler.cxx	24 Nov 2009 13:58:58 -0000	1.69
***************
*** 202,214 ****
      }
  
-   cmCTestLog(this->CTest, HANDLER_OUTPUT,
-     "Updating the repository" << std::endl);
- 
-   // Make sure the source directory exists.
-   if(!this->InitialCheckout(ofs))
-     {
-     return -1;
-     }
- 
    cmCTestLog(this->CTest, HANDLER_OUTPUT, "   Updating the repository: "
      << sourceDirectory << std::endl);
--- 202,205 ----
***************
*** 324,353 ****
  
  //----------------------------------------------------------------------
- bool cmCTestUpdateHandler::InitialCheckout(std::ostream& ofs)
- {
-   // Use the user-provided command to create the source tree.
-   if(const char* command = this->GetOption("InitialCheckout"))
-     {
-     // Use a generic VC object to run and log the command.
-     cmCTestVC vc(this->CTest, ofs);
-     vc.SetSourceDirectory(this->GetOption("SourceDirectory"));
-     if(!vc.InitialCheckout(command))
-       {
-       return false;
-       }
- 
-     if(!this->CTest->InitializeFromCommand(this->Command))
-       {
-       cmCTestLog(this->CTest, HANDLER_OUTPUT,
-                  " Fatal Error in initialize: "
-                  << std::endl);
-       cmSystemTools::SetFatalErrorOccured();
-       return false;
-       }
-     }
-   return true;
- }
- 
- //----------------------------------------------------------------------
  int cmCTestUpdateHandler::DetectVCS(const char* dir)
  {
--- 315,318 ----

Index: cmCTestUpdateCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestUpdateCommand.cxx,v
retrieving revision 1.19
retrieving revision 1.20
diff -C 2 -d -r1.19 -r1.20
*** cmCTestUpdateCommand.cxx	28 Sep 2009 15:43:02 -0000	1.19
--- cmCTestUpdateCommand.cxx	24 Nov 2009 13:58:56 -0000	1.20
***************
*** 57,68 ****
      "HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS");
  
-   const char* initialCheckoutCommand
-     = this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
-   if ( !initialCheckoutCommand )
-     {
-     initialCheckoutCommand = 
-       this->Makefile->GetDefinition("CTEST_CVS_CHECKOUT");
-     }
- 
    cmCTestGenericHandler* handler
      = this->CTest->GetInitializedHandler("update");
--- 57,60 ----
***************
*** 79,100 ****
      }
    handler->SetOption("SourceDirectory", source_dir.c_str());
-   if ( initialCheckoutCommand )
-     {
-     handler->SetOption("InitialCheckout", initialCheckoutCommand);
-     }
-   if ( (!cmSystemTools::FileExists(source_dir.c_str()) ||
-       !cmSystemTools::FileIsDirectory(source_dir.c_str()))
-     && !initialCheckoutCommand )
-     {
-     cmOStringStream str;
-     str << "cannot find source directory: " << source_dir.c_str() << ".";
-     if ( !cmSystemTools::FileExists(source_dir.c_str()) )
-       {
-       str << " Looks like it is not checked out yet. Please specify "
-         "CTEST_CHECKOUT_COMMAND.";
-       }
-     this->SetError(str.str().c_str());
-     return 0;
-     }
    return handler;
  }
--- 71,74 ----

Index: cmCTestStartCommand.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestStartCommand.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -C 2 -d -r1.7 -r1.8
*** cmCTestStartCommand.h	28 Sep 2009 15:43:02 -0000	1.7
--- cmCTestStartCommand.h	24 Nov 2009 13:58:55 -0000	1.8
***************
*** 73,76 ****
--- 73,78 ----
    cmTypeMacro(cmCTestStartCommand, cmCTestCommand);
  
+ private:
+   bool InitialCheckout(std::ostream& ofs, std::string const& sourceDir);
  };
  

Index: cmCTestUpdateHandler.h
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestUpdateHandler.h,v
retrieving revision 1.15
retrieving revision 1.16
diff -C 2 -d -r1.15 -r1.16
*** cmCTestUpdateHandler.h	28 Sep 2009 15:43:02 -0000	1.15
--- cmCTestUpdateHandler.h	24 Nov 2009 13:58:59 -0000	1.16
***************
*** 66,70 ****
    int UpdateType;
  
-   bool InitialCheckout(std::ostream& ofs);
    int DetectVCS(const char* dir);
    bool SelectVCS();
--- 66,69 ----

Index: cmCTestStartCommand.cxx
===================================================================
RCS file: /cvsroot/CMake/CMake/Source/CTest/cmCTestStartCommand.cxx,v
retrieving revision 1.17
retrieving revision 1.18
diff -C 2 -d -r1.17 -r1.18
*** cmCTestStartCommand.cxx	28 Sep 2009 15:43:02 -0000	1.17
--- cmCTestStartCommand.cxx	24 Nov 2009 13:58:54 -0000	1.18
***************
*** 15,18 ****
--- 15,20 ----
  #include "cmLocalGenerator.h"
  #include "cmGlobalGenerator.h"
+ #include "cmCTestVC.h"
+ #include "cmGeneratedFileStream.h"
  
  bool cmCTestStartCommand
***************
*** 77,84 ****
  
    this->CTest->EmptyCTestConfiguration();
!   this->CTest->SetCTestConfiguration("SourceDirectory",
!     cmSystemTools::CollapseFullPath(src_dir).c_str());
!   this->CTest->SetCTestConfiguration("BuildDirectory",
!     cmSystemTools::CollapseFullPath(bld_dir).c_str());
  
    cmCTestLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model "
--- 79,87 ----
  
    this->CTest->EmptyCTestConfiguration();
! 
!   std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir);
!   std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir);
!   this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str());
!   this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str());
  
    cmCTestLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model "
***************
*** 93,96 ****
--- 96,125 ----
      }
  
+   // Log startup actions.
+   std::string startLogFile = binaryDir + "/Testing/Temporary/LastStart.log";
+   cmGeneratedFileStream ofs(startLogFile.c_str());
+   if(!ofs)
+     {
+     cmCTestLog(this->CTest, ERROR_MESSAGE,
+                "Cannot create log file: LastStart.log" << std::endl);
+     return false;
+     }
+ 
+   // Make sure the source directory exists.
+   if(!this->InitialCheckout(ofs, sourceDir))
+     {
+     return false;
+     }
+   if(!cmSystemTools::FileIsDirectory(sourceDir.c_str()))
+     {
+     cmOStringStream e;
+     e << "given source path\n"
+       << "  " << sourceDir << "\n"
+       << "which is not an existing directory.  "
+       << "Set CTEST_CHECKOUT_COMMAND to a command line to create it.";
+     this->SetError(e.str().c_str());
+     return false;
+     }
+ 
    this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF");
    this->CTest->SetSuppressUpdatingCTestConfiguration(true);
***************
*** 99,104 ****
    this->CTest->SetProduceXML(true);
  
!   return this->CTest->InitializeFromCommand(this, true);
  }
  
! 
--- 128,156 ----
    this->CTest->SetProduceXML(true);
  
!   return this->CTest->InitializeFromCommand(this);
  }
  
! //----------------------------------------------------------------------------
! bool cmCTestStartCommand::InitialCheckout(
!   std::ostream& ofs, std::string const& sourceDir)
! {
!   // Use the user-provided command to create the source tree.
!   const char* initialCheckoutCommand
!     = this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
!   if(!initialCheckoutCommand)
!     {
!     initialCheckoutCommand =
!       this->Makefile->GetDefinition("CTEST_CVS_CHECKOUT");
!     }
!   if(initialCheckoutCommand)
!     {
!     // Use a generic VC object to run and log the command.
!     cmCTestVC vc(this->CTest, ofs);
!     vc.SetSourceDirectory(sourceDir.c_str());
!     if(!vc.InitialCheckout(initialCheckoutCommand))
!       {
!       return false;
!       }
!     }
!   return true;
! }



More information about the Cmake-commits mailing list