cmake/Source/CTest/cmCTestStartCommand.cxx

161 lines
4.9 KiB
C++
Raw Normal View History

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