CMake/Source/CTest/cmCTestUpdateCommand.cxx
Brad King e1548142fb 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.
2009-11-24 08:58:59 -05:00

77 lines
3.0 KiB
C++

/*============================================================================
CMake - Cross Platform Makefile Generator
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
Distributed under the OSI-approved BSD License (the "License");
see accompanying file Copyright.txt for details.
This software is distributed WITHOUT ANY WARRANTY; without even the
implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the License for more information.
============================================================================*/
#include "cmCTestUpdateCommand.h"
#include "cmCTest.h"
#include "cmCTestGenericHandler.h"
cmCTestGenericHandler* cmCTestUpdateCommand::InitializeHandler()
{
if ( this->Values[ct_SOURCE] )
{
this->CTest->SetCTestConfiguration("SourceDirectory",
cmSystemTools::CollapseFullPath(
this->Values[ct_SOURCE]).c_str());
}
else
{
this->CTest->SetCTestConfiguration("SourceDirectory",
cmSystemTools::CollapseFullPath(
this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY")).c_str());
}
std::string source_dir
= this->CTest->GetCTestConfiguration("SourceDirectory");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"UpdateCommand", "CTEST_UPDATE_COMMAND");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"UpdateOptions", "CTEST_UPDATE_OPTIONS");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"CVSCommand", "CTEST_CVS_COMMAND");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"CVSUpdateOptions", "CTEST_CVS_UPDATE_OPTIONS");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"SVNCommand", "CTEST_SVN_COMMAND");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"SVNUpdateOptions", "CTEST_SVN_UPDATE_OPTIONS");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"BZRCommand", "CTEST_BZR_COMMAND");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"BZRUpdateOptions", "CTEST_BZR_UPDATE_OPTIONS");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"GITCommand", "CTEST_GIT_COMMAND");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"GITUpdateOptions", "CTEST_GIT_UPDATE_OPTIONS");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"HGCommand", "CTEST_HG_COMMAND");
this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
"HGUpdateOptions", "CTEST_HG_UPDATE_OPTIONS");
cmCTestGenericHandler* handler
= this->CTest->GetInitializedHandler("update");
if ( !handler )
{
this->SetError("internal CTest error. Cannot instantiate update handler");
return 0;
}
handler->SetCommand(this);
if ( source_dir.empty() )
{
this->SetError("source directory not specified. Please use SOURCE tag");
return 0;
}
handler->SetOption("SourceDirectory", source_dir.c_str());
return handler;
}