2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2005-02-17 18:51:52 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
Distributed under the OSI-approved BSD License (the "License");
|
|
|
|
see accompanying file Copyright.txt for details.
|
2005-02-17 18:51:52 +03:00
|
|
|
|
2009-09-28 19:43:28 +04:00
|
|
|
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.
|
|
|
|
============================================================================*/
|
2005-02-17 18:51:52 +03:00
|
|
|
#include "cmCTestStartCommand.h"
|
|
|
|
|
|
|
|
#include "cmCTest.h"
|
2009-11-24 16:58:59 +03:00
|
|
|
#include "cmCTestVC.h"
|
|
|
|
#include "cmGeneratedFileStream.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmGlobalGenerator.h"
|
2005-02-17 18:51:52 +03:00
|
|
|
|
2009-12-29 22:38:31 +03:00
|
|
|
cmCTestStartCommand::cmCTestStartCommand()
|
|
|
|
{
|
|
|
|
this->CreateNewTag = true;
|
2015-02-17 17:58:25 +03:00
|
|
|
this->Quiet = false;
|
2009-12-29 22:38:31 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
|
|
|
|
cmExecutionStatus&)
|
2005-02-17 18:51:52 +03:00
|
|
|
{
|
2016-05-27 00:05:30 +03:00
|
|
|
if (args.empty()) {
|
2005-02-17 18:51:52 +03:00
|
|
|
this->SetError("called with incorrect number of arguments");
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-02-17 18:51:52 +03:00
|
|
|
|
2006-04-28 19:59:31 +04:00
|
|
|
size_t cnt = 0;
|
|
|
|
const char* smodel = args[cnt].c_str();
|
2016-06-27 23:44:16 +03:00
|
|
|
const char* src_dir = CM_NULLPTR;
|
|
|
|
const char* bld_dir = CM_NULLPTR;
|
2005-02-17 18:51:52 +03:00
|
|
|
|
2006-04-28 19:59:31 +04:00
|
|
|
cnt++;
|
|
|
|
|
2016-06-27 23:44:16 +03:00
|
|
|
this->CTest->SetSpecificTrack(CM_NULLPTR);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cnt < args.size() - 1) {
|
|
|
|
if (args[cnt] == "TRACK") {
|
|
|
|
cnt++;
|
2006-04-28 19:59:31 +04:00
|
|
|
this->CTest->SetSpecificTrack(args[cnt].c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
cnt++;
|
2005-02-17 18:51:52 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-28 19:59:31 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cnt < args.size()) {
|
|
|
|
if (args[cnt] == "APPEND") {
|
|
|
|
cnt++;
|
2009-12-29 22:38:31 +03:00
|
|
|
this->CreateNewTag = false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cnt < args.size()) {
|
|
|
|
if (args[cnt] == "QUIET") {
|
|
|
|
cnt++;
|
2015-02-17 17:58:25 +03:00
|
|
|
this->Quiet = true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-12-29 22:38:31 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cnt < args.size()) {
|
2006-04-28 19:59:31 +04:00
|
|
|
src_dir = args[cnt].c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
cnt++;
|
|
|
|
if (cnt < args.size()) {
|
2006-04-28 19:59:31 +04:00
|
|
|
bld_dir = args[cnt].c_str();
|
2005-02-17 18:51:52 +03:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!src_dir) {
|
2006-03-15 19:02:08 +03:00
|
|
|
src_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!bld_dir) {
|
2006-03-15 19:02:08 +03:00
|
|
|
bld_dir = this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!src_dir) {
|
2006-03-09 19:17:10 +03:00
|
|
|
this->SetError("source directory not specified. Specify source directory "
|
2016-05-16 17:34:04 +03:00
|
|
|
"as an argument or set CTEST_SOURCE_DIRECTORY");
|
2005-02-17 18:51:52 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!bld_dir) {
|
2006-03-09 19:17:10 +03:00
|
|
|
this->SetError("binary directory not specified. Specify binary directory "
|
2016-05-16 17:34:04 +03:00
|
|
|
"as an argument or set CTEST_BINARY_DIRECTORY");
|
2005-02-17 18:51:52 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-08-14 18:51:08 +04:00
|
|
|
|
|
|
|
cmSystemTools::AddKeepPath(src_dir);
|
|
|
|
cmSystemTools::AddKeepPath(bld_dir);
|
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->EmptyCTestConfiguration();
|
2009-11-24 16:58:59 +03:00
|
|
|
|
|
|
|
std::string sourceDir = cmSystemTools::CollapseFullPath(src_dir);
|
|
|
|
std::string binaryDir = cmSystemTools::CollapseFullPath(bld_dir);
|
2015-02-17 17:58:25 +03:00
|
|
|
this->CTest->SetCTestConfiguration("SourceDirectory", sourceDir.c_str(),
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2015-02-17 17:58:25 +03:00
|
|
|
this->CTest->SetCTestConfiguration("BuildDirectory", binaryDir.c_str(),
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Quiet);
|
2005-05-02 22:15:29 +04:00
|
|
|
|
2015-02-17 17:58:25 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< smodel << std::endl
|
|
|
|
<< " Source directory: " << src_dir << std::endl
|
|
|
|
<< " Build directory: " << bld_dir << std::endl,
|
|
|
|
this->Quiet);
|
2006-04-28 19:59:31 +04:00
|
|
|
const char* track = this->CTest->GetSpecificTrack();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (track) {
|
2015-02-17 17:58:25 +03:00
|
|
|
cmCTestOptionalLog(this->CTest, HANDLER_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
" Track: " << track << std::endl, this->Quiet);
|
|
|
|
}
|
2005-06-16 21:18:21 +04:00
|
|
|
|
2009-11-24 16:58:59 +03:00
|
|
|
// Log startup actions.
|
|
|
|
std::string startLogFile = binaryDir + "/Testing/Temporary/LastStart.log";
|
|
|
|
cmGeneratedFileStream ofs(startLogFile.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!ofs) {
|
2009-11-24 16:58:59 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
|
|
|
"Cannot create log file: LastStart.log" << std::endl);
|
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-11-24 16:58:59 +03:00
|
|
|
|
|
|
|
// Make sure the source directory exists.
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->InitialCheckout(ofs, sourceDir)) {
|
2009-11-24 16:58:59 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!cmSystemTools::FileIsDirectory(sourceDir)) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream e;
|
2009-11-24 16:58:59 +03:00
|
|
|
e << "given source path\n"
|
|
|
|
<< " " << sourceDir << "\n"
|
|
|
|
<< "which is not an existing directory. "
|
|
|
|
<< "Set CTEST_CHECKOUT_COMMAND to a command line to create it.";
|
2014-03-11 03:04:11 +04:00
|
|
|
this->SetError(e.str());
|
2009-11-24 16:58:59 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-11-24 16:58:59 +03:00
|
|
|
|
2006-03-15 19:02:08 +03:00
|
|
|
this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF");
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTest->SetSuppressUpdatingCTestConfiguration(true);
|
|
|
|
int model = this->CTest->GetTestModelFromString(smodel);
|
|
|
|
this->CTest->SetTestModel(model);
|
|
|
|
this->CTest->SetProduceXML(true);
|
2005-06-16 21:18:21 +04:00
|
|
|
|
2009-11-24 16:58:59 +03:00
|
|
|
return this->CTest->InitializeFromCommand(this);
|
2005-02-17 18:51:52 +03:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCTestStartCommand::InitialCheckout(std::ostream& ofs,
|
|
|
|
std::string const& sourceDir)
|
2009-11-24 16:58:59 +03:00
|
|
|
{
|
|
|
|
// Use the user-provided command to create the source tree.
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* initialCheckoutCommand =
|
|
|
|
this->Makefile->GetDefinition("CTEST_CHECKOUT_COMMAND");
|
|
|
|
if (!initialCheckoutCommand) {
|
2009-11-24 16:58:59 +03:00
|
|
|
initialCheckoutCommand =
|
|
|
|
this->Makefile->GetDefinition("CTEST_CVS_CHECKOUT");
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (initialCheckoutCommand) {
|
2009-11-24 16:58:59 +03:00
|
|
|
// Use a generic VC object to run and log the command.
|
|
|
|
cmCTestVC vc(this->CTest, ofs);
|
2014-03-11 03:04:11 +04:00
|
|
|
vc.SetSourceDirectory(sourceDir);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!vc.InitialCheckout(initialCheckoutCommand)) {
|
2009-11-24 16:58:59 +03:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-11-24 16:58:59 +03:00
|
|
|
return true;
|
|
|
|
}
|