浏览代码

cmCTestGIT: add an option to initialize submodules on update

Currently, CTest will not initialize any submodules within the already
checked out source tree. Add an option to do so. The use case for not
doing so is that some submodules may not be necessary for the current
test and keeping network usage down may be important.
Ben Boeckel 9 年之前
父节点
当前提交
06b310b5d5

+ 1 - 0
Help/manual/cmake-variables.7.rst

@@ -407,6 +407,7 @@ Variables for CTest
    /variable/CTEST_DROP_SITE_USER
    /variable/CTEST_DROP_SITE_USER
    /variable/CTEST_EXTRA_COVERAGE_GLOB
    /variable/CTEST_EXTRA_COVERAGE_GLOB
    /variable/CTEST_GIT_COMMAND
    /variable/CTEST_GIT_COMMAND
+   /variable/CTEST_GIT_INIT_SUBMODULES
    /variable/CTEST_GIT_UPDATE_CUSTOM
    /variable/CTEST_GIT_UPDATE_CUSTOM
    /variable/CTEST_GIT_UPDATE_OPTIONS
    /variable/CTEST_GIT_UPDATE_OPTIONS
    /variable/CTEST_HG_COMMAND
    /variable/CTEST_HG_COMMAND

+ 6 - 0
Help/manual/ctest.1.rst

@@ -589,6 +589,12 @@ Configuration settings to specify the version control tool include:
   * `CTest Script`_ variable: :variable:`CTEST_GIT_COMMAND`
   * `CTest Script`_ variable: :variable:`CTEST_GIT_COMMAND`
   * :module:`CTest` module variable: ``GITCOMMAND``
   * :module:`CTest` module variable: ``GITCOMMAND``
 
 
+``GITInitSubmodules``
+  If set, CTest will update the repository's submodules before updating.
+
+  * `CTest Script`_ variable: :variable:`CTEST_GIT_INIT_SUBMODULES`
+  * :module:`CTest` module variable: ``CTEST_GIT_INIT_SUBMODULES``
+
 ``GITUpdateCustom``
 ``GITUpdateCustom``
   Specify a custom command line (as a semicolon-separated list) to run
   Specify a custom command line (as a semicolon-separated list) to run
   in the source tree (Git work tree) to update it instead of running
   in the source tree (Git work tree) to update it instead of running

+ 5 - 0
Help/variable/CTEST_GIT_INIT_SUBMODULES.rst

@@ -0,0 +1,5 @@
+CTEST_GIT_INIT_SUBMODULES
+-------------------------
+
+Specify the CTest ``GITInitSubmodules`` setting
+in a :manual:`ctest(1)` dashboard client script.

+ 1 - 0
Modules/DartConfiguration.tcl.in

@@ -52,6 +52,7 @@ SVNUpdateOptions: @SVN_UPDATE_OPTIONS@
 
 
 # Git options
 # Git options
 GITCommand: @GITCOMMAND@
 GITCommand: @GITCOMMAND@
+GITInitSubmodules: @CTEST_GIT_INIT_SUBMODULES@
 GITUpdateOptions: @GIT_UPDATE_OPTIONS@
 GITUpdateOptions: @GIT_UPDATE_OPTIONS@
 GITUpdateCustom: @CTEST_GIT_UPDATE_CUSTOM@
 GITUpdateCustom: @CTEST_GIT_UPDATE_CUSTOM@
 
 

+ 18 - 1
Source/CTest/cmCTestGIT.cxx

@@ -285,9 +285,26 @@ bool cmCTestGIT::UpdateImpl()
       }
       }
     }
     }
 
 
-  char const* git_submodule[] = {git, "submodule", "update", recursive, 0};
   OutputLogger submodule_out(this->Log, "submodule-out> ");
   OutputLogger submodule_out(this->Log, "submodule-out> ");
   OutputLogger submodule_err(this->Log, "submodule-err> ");
   OutputLogger submodule_err(this->Log, "submodule-err> ");
+
+  bool ret;
+
+  std::string init_submodules =
+    this->CTest->GetCTestConfiguration("GITInitSubmodules");
+  if (cmSystemTools::IsOn(init_submodules.c_str()))
+    {
+    char const* git_submodule_init[] = {git, "submodule", "init", 0};
+    ret = this->RunChild(git_submodule_init, &submodule_out, &submodule_err,
+                         top_dir.c_str());
+
+    if (!ret)
+      {
+      return false;
+      }
+    }
+
+  char const* git_submodule[] = {git, "submodule", "update", recursive, 0};
   return this->RunChild(git_submodule, &submodule_out, &submodule_err,
   return this->RunChild(git_submodule, &submodule_out, &submodule_err,
                         top_dir.c_str());
                         top_dir.c_str());
 }
 }

+ 2 - 0
Source/CTest/cmCTestUpdateCommand.cxx

@@ -54,6 +54,8 @@ cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
     "GITCommand", "CTEST_GIT_COMMAND", this->Quiet);
     "GITCommand", "CTEST_GIT_COMMAND", this->Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
   this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
     "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS", this->Quiet);
     "GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS", this->Quiet);
+  this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
+    "GITInitSubmodules", "CTEST_GIT_INIT_SUBMODULES", this->Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
   this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
     "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet);
     "GITUpdateCustom", "CTEST_GIT_UPDATE_CUSTOM", this->Quiet);
   this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
   this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,