2009-09-28 19:43:28 +04:00
|
|
|
/*============================================================================
|
|
|
|
CMake - Cross Platform Makefile Generator
|
|
|
|
Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
|
2004-09-06 20:45:14 +04: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.
|
2004-09-06 20:45:14 +04: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.
|
|
|
|
============================================================================*/
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
#include "cmCTestScriptHandler.h"
|
|
|
|
|
|
|
|
#include "cmCTest.h"
|
2005-01-27 18:11:04 +03:00
|
|
|
#include "cmFunctionBlocker.h"
|
2005-05-28 00:17:38 +04:00
|
|
|
#include "cmGeneratedFileStream.h"
|
2016-04-29 17:53:13 +03:00
|
|
|
#include "cmGlobalGenerator.h"
|
|
|
|
#include "cmMakefile.h"
|
|
|
|
#include "cmake.h"
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
//#include <cmsys/RegularExpression.hxx>
|
2013-11-02 00:55:45 +04:00
|
|
|
#include <cmsys/Directory.hxx>
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <cmsys/Process.h>
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// used for sleep
|
|
|
|
#ifdef _WIN32
|
|
|
|
#include "windows.h"
|
|
|
|
#endif
|
|
|
|
|
2016-04-29 17:53:13 +03:00
|
|
|
#include <float.h>
|
|
|
|
#include <math.h>
|
2006-03-09 19:17:10 +03:00
|
|
|
#include <stdlib.h>
|
2004-09-06 20:45:14 +04:00
|
|
|
#include <time.h>
|
|
|
|
|
|
|
|
// needed for sleep
|
|
|
|
#if !defined(_WIN32)
|
2016-05-16 17:34:04 +03:00
|
|
|
#include <unistd.h>
|
2004-09-06 20:45:14 +04:00
|
|
|
#endif
|
|
|
|
|
2005-05-02 22:15:29 +04:00
|
|
|
#include "cmCTestBuildCommand.h"
|
|
|
|
#include "cmCTestConfigureCommand.h"
|
2005-06-14 22:00:45 +04:00
|
|
|
#include "cmCTestCoverageCommand.h"
|
2005-01-27 18:11:04 +03:00
|
|
|
#include "cmCTestEmptyBinaryDirectoryCommand.h"
|
2005-06-14 22:00:45 +04:00
|
|
|
#include "cmCTestMemCheckCommand.h"
|
2006-03-28 23:37:44 +04:00
|
|
|
#include "cmCTestReadCustomFilesCommand.h"
|
2005-01-27 18:11:04 +03:00
|
|
|
#include "cmCTestRunScriptCommand.h"
|
|
|
|
#include "cmCTestSleepCommand.h"
|
2005-02-17 18:51:52 +03:00
|
|
|
#include "cmCTestStartCommand.h"
|
2005-05-03 16:17:39 +04:00
|
|
|
#include "cmCTestSubmitCommand.h"
|
2005-06-14 22:00:45 +04:00
|
|
|
#include "cmCTestTestCommand.h"
|
|
|
|
#include "cmCTestUpdateCommand.h"
|
2011-02-18 20:11:51 +03:00
|
|
|
#include "cmCTestUploadCommand.h"
|
2005-01-27 18:11:04 +03:00
|
|
|
|
2004-09-28 17:00:06 +04:00
|
|
|
#define CTEST_INITIAL_CMAKE_OUTPUT_FILE_NAME "CTestInitialCMakeOutput.log"
|
|
|
|
|
2005-01-27 18:11:04 +03:00
|
|
|
// used to keep elapsed time up to date
|
|
|
|
class cmCTestScriptFunctionBlocker : public cmFunctionBlocker
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
cmCTestScriptFunctionBlocker() {}
|
|
|
|
virtual ~cmCTestScriptFunctionBlocker() {}
|
2016-05-16 17:34:04 +03:00
|
|
|
virtual bool IsFunctionBlocked(const cmListFileFunction& lff, cmMakefile& mf,
|
|
|
|
cmExecutionStatus&);
|
|
|
|
// virtual bool ShouldRemove(const cmListFileFunction& lff, cmMakefile &mf);
|
|
|
|
// virtual void ScopeEnded(cmMakefile &mf);
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestScriptHandler* CTestScriptHandler;
|
2005-01-27 18:11:04 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
// simply update the time and don't block anything
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCTestScriptFunctionBlocker::IsFunctionBlocked(const cmListFileFunction&,
|
|
|
|
cmMakefile&,
|
|
|
|
cmExecutionStatus&)
|
2005-01-27 18:11:04 +03:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTestScriptHandler->UpdateElapsedTime();
|
2005-01-27 18:11:04 +03:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
cmCTestScriptHandler::cmCTestScriptHandler()
|
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Backup = false;
|
|
|
|
this->EmptyBinDir = false;
|
|
|
|
this->EmptyBinDirOnce = false;
|
|
|
|
this->Makefile = 0;
|
|
|
|
this->CMake = 0;
|
|
|
|
this->GlobalGenerator = 0;
|
2005-01-27 18:11:04 +03:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
this->ScriptStartTime = 0;
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// the *60 is becuase the settings are in minutes but GetTime is seconds
|
2016-05-16 17:34:04 +03:00
|
|
|
this->MinimumInterval = 30 * 60;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->ContinuousDuration = -1;
|
2004-09-06 20:45:14 +04:00
|
|
|
}
|
|
|
|
|
2005-06-17 21:04:56 +04:00
|
|
|
void cmCTestScriptHandler::Initialize()
|
|
|
|
{
|
2005-06-23 21:04:18 +04:00
|
|
|
this->Superclass::Initialize();
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Backup = false;
|
|
|
|
this->EmptyBinDir = false;
|
|
|
|
this->EmptyBinDirOnce = false;
|
|
|
|
|
|
|
|
this->SourceDir = "";
|
|
|
|
this->BinaryDir = "";
|
|
|
|
this->BackupSourceDir = "";
|
|
|
|
this->BackupBinaryDir = "";
|
|
|
|
this->CTestRoot = "";
|
|
|
|
this->CVSCheckOut = "";
|
|
|
|
this->CTestCmd = "";
|
2006-04-30 04:13:05 +04:00
|
|
|
this->UpdateCmd = "";
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTestEnv = "";
|
2009-07-12 00:27:28 +04:00
|
|
|
this->InitialCache = "";
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CMakeCmd = "";
|
|
|
|
this->CMOutFile = "";
|
|
|
|
this->ExtraUpdates.clear();
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->MinimumInterval = 20 * 60;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->ContinuousDuration = -1;
|
2005-06-17 21:04:56 +04:00
|
|
|
|
|
|
|
// what time in seconds did this script start running
|
2006-03-10 23:03:09 +03:00
|
|
|
this->ScriptStartTime = 0;
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2015-08-02 12:41:51 +03:00
|
|
|
delete this->Makefile;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Makefile = 0;
|
2015-08-25 00:00:21 +03:00
|
|
|
|
|
|
|
delete this->GlobalGenerator;
|
2006-03-10 23:03:09 +03:00
|
|
|
this->GlobalGenerator = 0;
|
2015-08-25 00:00:21 +03:00
|
|
|
|
|
|
|
delete this->CMake;
|
2005-06-17 21:04:56 +04:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
cmCTestScriptHandler::~cmCTestScriptHandler()
|
|
|
|
{
|
2015-08-02 12:41:51 +03:00
|
|
|
delete this->Makefile;
|
2015-08-25 00:00:21 +03:00
|
|
|
delete this->GlobalGenerator;
|
|
|
|
delete this->CMake;
|
2004-09-06 20:45:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// just adds an argument to the vector
|
2016-05-16 17:34:04 +03:00
|
|
|
void cmCTestScriptHandler::AddConfigurationScript(const char* script,
|
2006-05-10 21:50:44 +04:00
|
|
|
bool pscope)
|
2004-09-06 20:45:14 +04:00
|
|
|
{
|
2006-03-10 23:03:09 +03:00
|
|
|
this->ConfigurationScripts.push_back(script);
|
2006-04-04 21:04:28 +04:00
|
|
|
this->ScriptProcessScope.push_back(pscope);
|
2004-09-06 20:45:14 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
// the generic entry point for handling scripts, this routine will run all
|
|
|
|
// the scripts provides a -S arguments
|
2005-01-27 23:54:47 +03:00
|
|
|
int cmCTestScriptHandler::ProcessHandler()
|
2004-09-06 20:45:14 +04:00
|
|
|
{
|
|
|
|
int res = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 0; i < this->ConfigurationScripts.size(); ++i) {
|
2004-09-06 20:45:14 +04:00
|
|
|
// for each script run it
|
2016-05-16 17:34:04 +03:00
|
|
|
res |= this->RunConfigurationScript(
|
|
|
|
cmSystemTools::CollapseFullPath(this->ConfigurationScripts[i]),
|
|
|
|
this->ScriptProcessScope[i]);
|
|
|
|
}
|
|
|
|
if (res) {
|
2005-01-27 23:54:47 +03:00
|
|
|
return -1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-01-27 23:54:47 +03:00
|
|
|
return 0;
|
2004-09-06 20:45:14 +04:00
|
|
|
}
|
|
|
|
|
2005-01-27 18:11:04 +03:00
|
|
|
void cmCTestScriptHandler::UpdateElapsedTime()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile) {
|
2005-01-27 18:11:04 +03:00
|
|
|
// set the current elapsed time
|
|
|
|
char timeString[20];
|
2016-05-16 17:34:04 +03:00
|
|
|
int itime = static_cast<unsigned int>(cmSystemTools::GetTime() -
|
|
|
|
this->ScriptStartTime);
|
|
|
|
sprintf(timeString, "%i", itime);
|
2015-10-05 21:03:14 +03:00
|
|
|
this->Makefile->AddDefinition("CTEST_ELAPSED_TIME", timeString);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-01-27 18:11:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
2005-02-17 18:51:52 +03:00
|
|
|
void cmCTestScriptHandler::AddCTestCommand(cmCTestCommand* command)
|
|
|
|
{
|
|
|
|
cmCTestCommand* newCom = command;
|
2006-03-10 23:03:09 +03:00
|
|
|
newCom->CTest = this->CTest;
|
|
|
|
newCom->CTestScriptHandler = this;
|
2015-04-11 13:52:14 +03:00
|
|
|
this->CMake->GetState()->AddCommand(newCom);
|
2005-02-17 18:51:52 +03:00
|
|
|
}
|
|
|
|
|
2006-04-04 21:04:28 +04:00
|
|
|
int cmCTestScriptHandler::ExecuteScript(const std::string& total_script_arg)
|
|
|
|
{
|
|
|
|
// execute the script passing in the arguments to the script as well as the
|
|
|
|
// arguments from this invocation of cmake
|
|
|
|
std::vector<const char*> argv;
|
2013-11-08 00:30:59 +04:00
|
|
|
argv.push_back(cmSystemTools::GetCTestCommand().c_str());
|
2006-04-04 21:04:28 +04:00
|
|
|
argv.push_back("-SR");
|
|
|
|
argv.push_back(total_script_arg.c_str());
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Executable for CTest is: "
|
|
|
|
<< cmSystemTools::GetCTestCommand() << "\n");
|
2006-04-04 21:04:28 +04:00
|
|
|
|
|
|
|
// now pass through all the other arguments
|
2016-05-16 17:34:04 +03:00
|
|
|
std::vector<std::string>& initArgs =
|
2006-04-04 21:04:28 +04:00
|
|
|
this->CTest->GetInitialCommandLineArguments();
|
2009-06-26 00:39:10 +04:00
|
|
|
//*** need to make sure this does not have the current script ***
|
2016-05-16 17:34:04 +03:00
|
|
|
for (size_t i = 1; i < initArgs.size(); ++i) {
|
2006-04-04 21:04:28 +04:00
|
|
|
argv.push_back(initArgs[i].c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-04-04 21:04:28 +04:00
|
|
|
argv.push_back(0);
|
|
|
|
|
|
|
|
// Now create process object
|
|
|
|
cmsysProcess* cp = cmsysProcess_New();
|
|
|
|
cmsysProcess_SetCommand(cp, &*argv.begin());
|
2016-05-16 17:34:04 +03:00
|
|
|
// cmsysProcess_SetWorkingDirectory(cp, dir);
|
2006-04-04 21:04:28 +04:00
|
|
|
cmsysProcess_SetOption(cp, cmsysProcess_Option_HideWindow, 1);
|
2016-05-16 17:34:04 +03:00
|
|
|
// cmsysProcess_SetTimeout(cp, timeout);
|
2006-04-04 21:04:28 +04:00
|
|
|
cmsysProcess_Execute(cp);
|
|
|
|
|
|
|
|
std::vector<char> out;
|
|
|
|
std::vector<char> err;
|
|
|
|
std::string line;
|
|
|
|
int pipe = cmSystemTools::WaitForLine(cp, line, 100.0, out, err);
|
2016-05-16 17:34:04 +03:00
|
|
|
while (pipe != cmsysProcess_Pipe_None) {
|
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Output: " << line
|
|
|
|
<< "\n");
|
|
|
|
if (pipe == cmsysProcess_Pipe_STDERR) {
|
2006-04-04 21:04:28 +04:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, line << "\n");
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (pipe == cmsysProcess_Pipe_STDOUT) {
|
2006-04-04 21:04:28 +04:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, line << "\n");
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
pipe = cmSystemTools::WaitForLine(cp, line, 100, out, err);
|
|
|
|
}
|
2011-03-11 16:04:58 +03:00
|
|
|
|
2006-04-04 21:04:28 +04:00
|
|
|
// Properly handle output of the build command
|
|
|
|
cmsysProcess_WaitForExit(cp, 0);
|
|
|
|
int result = cmsysProcess_GetState(cp);
|
|
|
|
int retVal = 0;
|
2008-12-19 05:57:42 +03:00
|
|
|
bool failed = false;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (result == cmsysProcess_State_Exited) {
|
2006-04-04 21:04:28 +04:00
|
|
|
retVal = cmsysProcess_GetExitValue(cp);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (result == cmsysProcess_State_Exception) {
|
2008-12-19 05:57:42 +03:00
|
|
|
retVal = cmsysProcess_GetExitException(cp);
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was an exception: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmsysProcess_GetExceptionString(cp) << " " << retVal
|
|
|
|
<< std::endl);
|
2008-12-19 05:57:42 +03:00
|
|
|
failed = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (result == cmsysProcess_State_Expired) {
|
2008-12-19 05:57:42 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tThere was a timeout"
|
2016-05-16 17:34:04 +03:00
|
|
|
<< std::endl);
|
2008-12-19 05:57:42 +03:00
|
|
|
failed = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
} else if (result == cmsysProcess_State_Error) {
|
2008-12-19 05:57:42 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "\tError executing ctest: "
|
2016-05-16 17:34:04 +03:00
|
|
|
<< cmsysProcess_GetErrorString(cp) << std::endl);
|
2008-12-19 05:57:42 +03:00
|
|
|
failed = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-09-05 01:01:47 +04:00
|
|
|
cmsysProcess_Delete(cp);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (failed) {
|
2015-01-05 22:31:31 +03:00
|
|
|
std::ostringstream message;
|
2008-12-19 05:57:42 +03:00
|
|
|
message << "Error running command: [";
|
|
|
|
message << result << "] ";
|
2016-05-16 17:34:04 +03:00
|
|
|
for (std::vector<const char*>::iterator i = argv.begin(); i != argv.end();
|
|
|
|
++i) {
|
|
|
|
if (*i) {
|
|
|
|
message << *i << " ";
|
2008-12-19 05:57:42 +03:00
|
|
|
}
|
2006-04-04 21:04:28 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, message.str() << argv[0]
|
|
|
|
<< std::endl);
|
|
|
|
return -1;
|
|
|
|
}
|
2006-04-04 21:04:28 +04:00
|
|
|
return retVal;
|
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
static void ctestScriptProgressCallback(const char* m, float, void* cd)
|
2014-07-02 18:23:23 +04:00
|
|
|
{
|
|
|
|
cmCTest* ctest = static_cast<cmCTest*>(cd);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (m && *m) {
|
2014-07-02 18:23:23 +04:00
|
|
|
cmCTestLog(ctest, HANDLER_OUTPUT, "-- " << m << std::endl);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2014-07-02 18:23:23 +04:00
|
|
|
}
|
|
|
|
|
2007-06-09 00:06:33 +04:00
|
|
|
void cmCTestScriptHandler::CreateCMake()
|
|
|
|
{
|
|
|
|
// create a cmake instance to read the configuration script
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CMake) {
|
2007-06-09 00:06:33 +04:00
|
|
|
delete this->CMake;
|
|
|
|
delete this->GlobalGenerator;
|
2015-08-02 12:41:51 +03:00
|
|
|
delete this->Makefile;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2007-06-09 00:06:33 +04:00
|
|
|
this->CMake = new cmake;
|
2015-05-05 00:01:29 +03:00
|
|
|
this->CMake->SetHomeDirectory("");
|
|
|
|
this->CMake->SetHomeOutputDirectory("");
|
2015-10-13 22:48:46 +03:00
|
|
|
this->CMake->GetCurrentSnapshot().SetDefaultDefinitions();
|
2007-12-14 01:56:50 +03:00
|
|
|
this->CMake->AddCMakePaths();
|
2015-05-24 12:31:14 +03:00
|
|
|
this->GlobalGenerator = new cmGlobalGenerator(this->CMake);
|
2007-06-09 00:06:33 +04:00
|
|
|
|
2015-05-31 02:43:31 +03:00
|
|
|
cmState::Snapshot snapshot = this->CMake->GetCurrentSnapshot();
|
2015-05-31 02:57:04 +03:00
|
|
|
std::string cwd = cmSystemTools::GetCurrentWorkingDirectory();
|
|
|
|
snapshot.GetDirectory().SetCurrentSource(cwd);
|
|
|
|
snapshot.GetDirectory().SetCurrentBinary(cwd);
|
2015-08-02 12:41:51 +03:00
|
|
|
this->Makefile = new cmMakefile(this->GlobalGenerator, snapshot);
|
2007-06-09 00:06:33 +04:00
|
|
|
|
2014-07-02 18:23:23 +04:00
|
|
|
this->CMake->SetProgressCallback(ctestScriptProgressCallback, this->CTest);
|
|
|
|
|
2011-03-11 16:04:58 +03:00
|
|
|
// remove all cmake commands which are not scriptable, since they can't be
|
2007-06-12 18:56:40 +04:00
|
|
|
// used in ctest scripts
|
2015-04-11 13:52:14 +03:00
|
|
|
this->CMake->GetState()->RemoveUnscriptableCommands();
|
2007-06-09 00:06:33 +04:00
|
|
|
|
|
|
|
// add any ctest specific commands, probably should have common superclass
|
|
|
|
// for ctest commands to clean this up. If a couple more commands are
|
|
|
|
// created with the same format lets do that - ken
|
|
|
|
this->AddCTestCommand(new cmCTestBuildCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestConfigureCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestCoverageCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestEmptyBinaryDirectoryCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestMemCheckCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestReadCustomFilesCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestRunScriptCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestSleepCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestStartCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestSubmitCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestTestCommand);
|
|
|
|
this->AddCTestCommand(new cmCTestUpdateCommand);
|
2011-02-18 20:11:51 +03:00
|
|
|
this->AddCTestCommand(new cmCTestUploadCommand);
|
2007-06-09 00:06:33 +04:00
|
|
|
}
|
|
|
|
|
2006-04-04 21:04:28 +04:00
|
|
|
// this sets up some variables for the script to use, creates the required
|
2004-09-06 20:45:14 +04:00
|
|
|
// cmake instance and generators, and then reads in the script
|
2005-01-27 19:43:22 +03:00
|
|
|
int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
|
2004-09-06 20:45:14 +04:00
|
|
|
{
|
2009-03-04 19:24:57 +03:00
|
|
|
// Reset the error flag so that the script is read in no matter what
|
|
|
|
cmSystemTools::ResetErrorOccuredFlag();
|
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// if the argument has a , in it then it needs to be broken into the fist
|
|
|
|
// argument (which is the script) and the second argument which will be
|
|
|
|
// passed into the scripts as S_ARG
|
|
|
|
std::string script = total_script_arg;
|
|
|
|
std::string script_arg;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (total_script_arg.find(",") != std::string::npos) {
|
|
|
|
script = total_script_arg.substr(0, total_script_arg.find(","));
|
|
|
|
script_arg = total_script_arg.substr(total_script_arg.find(",") + 1);
|
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
// make sure the file exists
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(script.c_str())) {
|
2004-09-28 17:00:06 +04:00
|
|
|
cmSystemTools::Error("Cannot find file: ", script.c_str());
|
2004-09-06 20:45:14 +04:00
|
|
|
return 1;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// read in the list file to fill the cache
|
2007-06-09 00:06:33 +04:00
|
|
|
// create a cmake instance to read the configuration script
|
|
|
|
this->CreateCMake();
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// set a variable with the path to the current script
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->AddDefinition(
|
|
|
|
"CTEST_SCRIPT_DIRECTORY", cmSystemTools::GetFilenamePath(script).c_str());
|
|
|
|
this->Makefile->AddDefinition(
|
|
|
|
"CTEST_SCRIPT_NAME", cmSystemTools::GetFilenameName(script).c_str());
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Makefile->AddDefinition("CTEST_EXECUTABLE_NAME",
|
2013-11-08 00:30:59 +04:00
|
|
|
cmSystemTools::GetCTestCommand().c_str());
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME",
|
2013-11-08 00:30:59 +04:00
|
|
|
cmSystemTools::GetCMakeCommand().c_str());
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", true);
|
2005-01-27 18:11:04 +03:00
|
|
|
this->UpdateElapsedTime();
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// add the script arg if defined
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!script_arg.empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Makefile->AddDefinition("CTEST_SCRIPT_ARG", script_arg.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-01-27 18:11:04 +03:00
|
|
|
|
2015-06-08 21:13:47 +03:00
|
|
|
#if defined(__CYGWIN__)
|
|
|
|
this->Makefile->AddDefinition("CMAKE_LEGACY_CYGWIN_WIN32", "0");
|
|
|
|
#endif
|
|
|
|
|
2005-01-27 18:11:04 +03:00
|
|
|
// always add a function blocker to update the elapsed time
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestScriptFunctionBlocker* f = new cmCTestScriptFunctionBlocker();
|
2006-03-10 23:03:09 +03:00
|
|
|
f->CTestScriptHandler = this;
|
|
|
|
this->Makefile->AddFunctionBlocker(f);
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2011-03-11 16:04:58 +03:00
|
|
|
/* Execute CTestScriptMode.cmake, which loads CMakeDetermineSystem and
|
|
|
|
CMakeSystemSpecificInformation, so
|
2008-11-07 23:56:54 +03:00
|
|
|
that variables like CMAKE_SYSTEM and also the search paths for libraries,
|
|
|
|
header and executables are set correctly and can be used. Makes new-style
|
|
|
|
ctest scripting easier. */
|
2011-03-11 16:04:58 +03:00
|
|
|
std::string systemFile =
|
2016-05-16 17:34:04 +03:00
|
|
|
this->Makefile->GetModulesFile("CTestScriptMode.cmake");
|
2015-04-18 15:50:37 +03:00
|
|
|
if (!this->Makefile->ReadListFile(systemFile.c_str()) ||
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::GetErrorOccuredFlag()) {
|
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read:" << systemFile
|
|
|
|
<< "\n");
|
2008-11-07 23:56:54 +03:00
|
|
|
return 2;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2008-11-07 23:56:54 +03:00
|
|
|
|
2012-06-24 14:16:32 +04:00
|
|
|
// Add definitions of variables passed in on the command line:
|
2016-05-16 17:34:04 +03:00
|
|
|
const std::map<std::string, std::string>& defs =
|
2012-06-24 14:16:32 +04:00
|
|
|
this->CTest->GetDefinitions();
|
|
|
|
for (std::map<std::string, std::string>::const_iterator it = defs.begin();
|
2016-05-16 17:34:04 +03:00
|
|
|
it != defs.end(); ++it) {
|
2014-03-11 03:04:11 +04:00
|
|
|
this->Makefile->AddDefinition(it->first, it->second.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2012-06-24 14:16:32 +04:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// finally read in the script
|
2015-04-18 15:50:37 +03:00
|
|
|
if (!this->Makefile->ReadListFile(script.c_str()) ||
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::GetErrorOccuredFlag()) {
|
2011-03-11 16:04:58 +03:00
|
|
|
// Reset the error flag so that it can run more than
|
2015-02-26 17:00:10 +03:00
|
|
|
// one script with an error when you use ctest_run_script.
|
2009-09-04 21:24:25 +04:00
|
|
|
cmSystemTools::ResetErrorOccuredFlag();
|
2004-09-06 20:45:14 +04:00
|
|
|
return 2;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// extract variabels from the script to set ivars
|
|
|
|
int cmCTestScriptHandler::ExtractVariables()
|
|
|
|
{
|
2004-09-29 01:51:29 +04:00
|
|
|
// Temporary variables
|
|
|
|
const char* minInterval;
|
|
|
|
const char* contDuration;
|
2004-09-06 20:45:14 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SourceDir =
|
|
|
|
this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
|
|
|
|
this->BinaryDir =
|
|
|
|
this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
|
2006-08-14 18:51:08 +04:00
|
|
|
|
|
|
|
// add in translations for src and bin
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::AddKeepPath(this->SourceDir);
|
|
|
|
cmSystemTools::AddKeepPath(this->BinaryDir);
|
2006-08-14 18:51:08 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CTestCmd = this->Makefile->GetSafeDefinition("CTEST_COMMAND");
|
|
|
|
this->CVSCheckOut = this->Makefile->GetSafeDefinition("CTEST_CVS_CHECKOUT");
|
|
|
|
this->CTestRoot = this->Makefile->GetSafeDefinition("CTEST_DASHBOARD_ROOT");
|
|
|
|
this->UpdateCmd = this->Makefile->GetSafeDefinition("CTEST_UPDATE_COMMAND");
|
|
|
|
if (this->UpdateCmd.empty()) {
|
|
|
|
this->UpdateCmd = this->Makefile->GetSafeDefinition("CTEST_CVS_COMMAND");
|
|
|
|
}
|
|
|
|
this->CTestEnv = this->Makefile->GetSafeDefinition("CTEST_ENVIRONMENT");
|
|
|
|
this->InitialCache =
|
|
|
|
this->Makefile->GetSafeDefinition("CTEST_INITIAL_CACHE");
|
|
|
|
this->CMakeCmd = this->Makefile->GetSafeDefinition("CTEST_CMAKE_COMMAND");
|
|
|
|
this->CMOutFile =
|
|
|
|
this->Makefile->GetSafeDefinition("CTEST_CMAKE_OUTPUT_FILE_NAME");
|
|
|
|
|
|
|
|
this->Backup = this->Makefile->IsOn("CTEST_BACKUP_AND_RESTORE");
|
|
|
|
this->EmptyBinDir =
|
|
|
|
this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY");
|
|
|
|
this->EmptyBinDirOnce =
|
|
|
|
this->Makefile->IsOn("CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE");
|
|
|
|
|
|
|
|
minInterval =
|
|
|
|
this->Makefile->GetDefinition("CTEST_CONTINUOUS_MINIMUM_INTERVAL");
|
|
|
|
contDuration = this->Makefile->GetDefinition("CTEST_CONTINUOUS_DURATION");
|
2004-09-29 01:51:29 +04:00
|
|
|
|
|
|
|
char updateVar[40];
|
|
|
|
int i;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (i = 1; i < 10; ++i) {
|
|
|
|
sprintf(updateVar, "CTEST_EXTRA_UPDATES_%i", i);
|
|
|
|
const char* updateVal = this->Makefile->GetDefinition(updateVar);
|
|
|
|
if (updateVal) {
|
|
|
|
if (this->UpdateCmd.empty()) {
|
|
|
|
cmSystemTools::Error(
|
|
|
|
updateVar, " specified without specifying CTEST_CVS_COMMAND.");
|
2004-09-29 01:51:29 +04:00
|
|
|
return 12;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ExtraUpdates.push_back(updateVal);
|
2004-09-29 01:51:29 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-29 01:51:29 +04:00
|
|
|
|
|
|
|
// in order to backup and restore we also must have the cvs root
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Backup && this->CVSCheckOut.empty()) {
|
2004-09-06 20:45:14 +04:00
|
|
|
cmSystemTools::Error(
|
2006-03-09 19:17:10 +03:00
|
|
|
"Backup was requested without specifying CTEST_CVS_CHECKOUT.");
|
2004-09-06 20:45:14 +04:00
|
|
|
return 3;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// make sure the required info is here
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->SourceDir.empty() || this->BinaryDir.empty() ||
|
|
|
|
this->CTestCmd.empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
std::string msg = "CTEST_SOURCE_DIRECTORY = ";
|
|
|
|
msg += (!this->SourceDir.empty()) ? this->SourceDir.c_str() : "(Null)";
|
|
|
|
msg += "\nCTEST_BINARY_DIRECTORY = ";
|
|
|
|
msg += (!this->BinaryDir.empty()) ? this->BinaryDir.c_str() : "(Null)";
|
|
|
|
msg += "\nCTEST_COMMAND = ";
|
|
|
|
msg += (!this->CTestCmd.empty()) ? this->CTestCmd.c_str() : "(Null)";
|
2004-09-06 20:45:14 +04:00
|
|
|
cmSystemTools::Error(
|
|
|
|
"Some required settings in the configuration file were missing:\n",
|
2006-03-10 23:03:09 +03:00
|
|
|
msg.c_str());
|
2004-09-06 20:45:14 +04:00
|
|
|
return 4;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// if the dashboard root isn't specified then we can compute it from the
|
2006-03-10 23:03:09 +03:00
|
|
|
// this->SourceDir
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CTestRoot.empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->CTestRoot = cmSystemTools::GetFilenamePath(this->SourceDir).c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// the script may override the minimum continuous interval
|
2016-05-16 17:34:04 +03:00
|
|
|
if (minInterval) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->MinimumInterval = 60 * atof(minInterval);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (contDuration) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->ContinuousDuration = 60.0 * atof(contDuration);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2005-01-27 18:11:04 +03:00
|
|
|
this->UpdateElapsedTime();
|
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2005-01-27 18:11:04 +03:00
|
|
|
void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait)
|
2004-09-06 20:45:14 +04:00
|
|
|
{
|
|
|
|
#if defined(_WIN32)
|
2016-05-16 17:34:04 +03:00
|
|
|
Sleep(1000 * secondsToWait);
|
2004-09-06 20:45:14 +04:00
|
|
|
#else
|
2016-05-16 17:34:04 +03:00
|
|
|
sleep(secondsToWait);
|
2004-09-06 20:45:14 +04:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
// run a specific script
|
2016-05-16 17:34:04 +03:00
|
|
|
int cmCTestScriptHandler::RunConfigurationScript(
|
|
|
|
const std::string& total_script_arg, bool pscope)
|
2004-09-06 20:45:14 +04:00
|
|
|
{
|
2009-12-23 22:34:46 +03:00
|
|
|
#ifdef CMAKE_BUILD_WITH_CMAKE
|
|
|
|
cmSystemTools::SaveRestoreEnvironment sre;
|
|
|
|
#endif
|
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
int result;
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
this->ScriptStartTime = cmSystemTools::GetTime();
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// read in the script
|
2016-05-16 17:34:04 +03:00
|
|
|
if (pscope) {
|
2006-04-04 21:04:28 +04:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Reading Script: " << total_script_arg << std::endl);
|
2006-04-04 21:04:28 +04:00
|
|
|
result = this->ReadInScript(total_script_arg);
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-04-04 21:04:28 +04:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Executing Script: " << total_script_arg << std::endl);
|
2006-04-04 21:04:28 +04:00
|
|
|
result = this->ExecuteScript(total_script_arg);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (result) {
|
2004-09-06 20:45:14 +04:00
|
|
|
return result;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2005-01-27 21:31:31 +03:00
|
|
|
// only run the curent script if we should
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Makefile && this->Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT")) {
|
2005-01-27 19:01:56 +03:00
|
|
|
return this->RunCurrentScript();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-01-27 18:11:04 +03:00
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2005-01-27 19:01:56 +03:00
|
|
|
int cmCTestScriptHandler::RunCurrentScript()
|
2005-01-27 18:11:04 +03:00
|
|
|
{
|
|
|
|
int result;
|
|
|
|
|
2005-01-27 21:31:31 +03:00
|
|
|
// do not run twice
|
2006-03-10 23:03:09 +03:00
|
|
|
this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", false);
|
2005-01-27 18:11:04 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// no popup widows
|
|
|
|
cmSystemTools::SetRunCommandHideConsole(true);
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// extract the vars from the cache and store in ivars
|
|
|
|
result = this->ExtractVariables();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (result) {
|
2004-09-06 20:45:14 +04:00
|
|
|
return result;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// set any environment variables
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CTestEnv.empty()) {
|
2004-09-06 20:45:14 +04:00
|
|
|
std::vector<std::string> envArgs;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(this->CTestEnv, envArgs);
|
2012-04-25 00:24:17 +04:00
|
|
|
cmSystemTools::AppendEnv(envArgs);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// now that we have done most of the error checking finally run the
|
|
|
|
// dashboard, we may be asked to repeatedly run this dashboard, such as
|
|
|
|
// for a continuous, do we ned to run it more than once?
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->ContinuousDuration >= 0) {
|
2005-01-27 18:11:04 +03:00
|
|
|
this->UpdateElapsedTime();
|
2016-05-16 17:34:04 +03:00
|
|
|
double ending_time = cmSystemTools::GetTime() + this->ContinuousDuration;
|
|
|
|
if (this->EmptyBinDirOnce) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->EmptyBinDir = true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
do {
|
2004-09-06 20:45:14 +04:00
|
|
|
double interval = cmSystemTools::GetTime();
|
|
|
|
result = this->RunConfigurationDashboard();
|
|
|
|
interval = cmSystemTools::GetTime() - interval;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (interval < this->MinimumInterval) {
|
2005-01-27 18:11:04 +03:00
|
|
|
this->SleepInSeconds(
|
2006-03-10 23:03:09 +03:00
|
|
|
static_cast<unsigned int>(this->MinimumInterval - interval));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (this->EmptyBinDirOnce) {
|
2006-03-10 23:03:09 +03:00
|
|
|
this->EmptyBinDir = false;
|
2004-09-06 20:45:14 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} while (cmSystemTools::GetTime() < ending_time);
|
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
// otherwise just run it once
|
2016-05-16 17:34:04 +03:00
|
|
|
else {
|
2004-09-06 20:45:14 +04:00
|
|
|
result = this->RunConfigurationDashboard();
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmCTestScriptHandler::CheckOutSourceDir()
|
|
|
|
{
|
|
|
|
std::string command;
|
|
|
|
std::string output;
|
|
|
|
int retVal;
|
2006-03-09 19:17:10 +03:00
|
|
|
bool res;
|
2004-09-06 20:45:14 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
if (!cmSystemTools::FileExists(this->SourceDir.c_str()) &&
|
2016-05-16 17:34:04 +03:00
|
|
|
!this->CVSCheckOut.empty()) {
|
2004-09-06 20:45:14 +04:00
|
|
|
// we must now checkout the src dir
|
|
|
|
output = "";
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Run cvs: " << this->CVSCheckOut << std::endl);
|
2015-04-20 22:36:57 +03:00
|
|
|
res = cmSystemTools::RunSingleCommand(
|
2016-05-16 17:34:04 +03:00
|
|
|
this->CVSCheckOut.c_str(), &output, &output, &retVal,
|
|
|
|
this->CTestRoot.c_str(), this->HandlerVerbose, 0 /*this->TimeOut*/);
|
|
|
|
if (!res || retVal != 0) {
|
2006-03-09 19:17:10 +03:00
|
|
|
cmSystemTools::Error("Unable to perform cvs checkout:\n",
|
|
|
|
output.c_str());
|
2004-09-06 20:45:14 +04:00
|
|
|
return 6;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmCTestScriptHandler::BackupDirectories()
|
|
|
|
{
|
|
|
|
int retVal;
|
|
|
|
|
|
|
|
// compute the backup names
|
2006-03-10 23:03:09 +03:00
|
|
|
this->BackupSourceDir = this->SourceDir;
|
|
|
|
this->BackupSourceDir += "_CMakeBackup";
|
|
|
|
this->BackupBinaryDir = this->BinaryDir;
|
|
|
|
this->BackupBinaryDir += "_CMakeBackup";
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// backup the binary and src directories if requested
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Backup) {
|
2004-09-06 20:45:14 +04:00
|
|
|
// if for some reason those directories exist then first delete them
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(this->BackupSourceDir.c_str())) {
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::RemoveADirectory(this->BackupSourceDir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmSystemTools::FileExists(this->BackupBinaryDir.c_str())) {
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
|
|
|
// first rename the src and binary directories
|
2006-03-10 23:03:09 +03:00
|
|
|
rename(this->SourceDir.c_str(), this->BackupSourceDir.c_str());
|
|
|
|
rename(this->BinaryDir.c_str(), this->BackupBinaryDir.c_str());
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// we must now checkout the src dir
|
|
|
|
retVal = this->CheckOutSourceDir();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal) {
|
2004-09-06 20:45:14 +04:00
|
|
|
this->RestoreBackupDirectories();
|
|
|
|
return retVal;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int cmCTestScriptHandler::PerformExtraUpdates()
|
|
|
|
{
|
|
|
|
std::string command;
|
|
|
|
std::string output;
|
|
|
|
int retVal;
|
2006-03-09 19:17:10 +03:00
|
|
|
bool res;
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// do an initial cvs update as required
|
2006-04-30 04:13:05 +04:00
|
|
|
command = this->UpdateCmd;
|
2014-02-10 09:21:34 +04:00
|
|
|
std::vector<std::string>::iterator it;
|
2016-05-16 17:34:04 +03:00
|
|
|
for (it = this->ExtraUpdates.begin(); it != this->ExtraUpdates.end(); ++it) {
|
2004-09-29 01:51:29 +04:00
|
|
|
std::vector<std::string> cvsArgs;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(*it, cvsArgs);
|
|
|
|
if (cvsArgs.size() == 2) {
|
2004-09-29 01:51:29 +04:00
|
|
|
std::string fullCommand = command;
|
|
|
|
fullCommand += " update ";
|
|
|
|
fullCommand += cvsArgs[1];
|
|
|
|
output = "";
|
|
|
|
retVal = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
|
|
|
"Run Update: " << fullCommand << std::endl);
|
2015-04-20 22:36:57 +03:00
|
|
|
res = cmSystemTools::RunSingleCommand(
|
2016-05-16 17:34:04 +03:00
|
|
|
fullCommand.c_str(), &output, &output, &retVal, cvsArgs[0].c_str(),
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HandlerVerbose, 0 /*this->TimeOut*/);
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!res || retVal != 0) {
|
|
|
|
cmSystemTools::Error("Unable to perform extra updates:\n", it->c_str(),
|
|
|
|
"\nWith output:\n", output.c_str());
|
2004-09-29 19:52:02 +04:00
|
|
|
return 0;
|
2004-09-06 20:45:14 +04:00
|
|
|
}
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
// run a single dashboard entry
|
|
|
|
int cmCTestScriptHandler::RunConfigurationDashboard()
|
|
|
|
{
|
|
|
|
// local variables
|
|
|
|
std::string command;
|
|
|
|
std::string output;
|
|
|
|
int retVal;
|
2006-03-09 19:17:10 +03:00
|
|
|
bool res;
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// make sure the src directory is there, if it isn't then we might be able
|
|
|
|
// to check it out from cvs
|
|
|
|
retVal = this->CheckOutSourceDir();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal) {
|
2004-09-06 20:45:14 +04:00
|
|
|
return retVal;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// backup the dirs if requested
|
|
|
|
retVal = this->BackupDirectories();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal) {
|
2004-09-06 20:45:14 +04:00
|
|
|
return retVal;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// clear the binary directory?
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->EmptyBinDir) {
|
|
|
|
if (!cmCTestScriptHandler::EmptyBinaryDirectory(this->BinaryDir.c_str())) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Problem removing the binary directory" << std::endl);
|
2004-09-06 20:45:14 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// make sure the binary directory exists if it isn't the srcdir
|
2006-03-10 23:03:09 +03:00
|
|
|
if (!cmSystemTools::FileExists(this->BinaryDir.c_str()) &&
|
2016-05-16 17:34:04 +03:00
|
|
|
this->SourceDir != this->BinaryDir) {
|
|
|
|
if (!cmSystemTools::MakeDirectory(this->BinaryDir.c_str())) {
|
2006-03-09 19:17:10 +03:00
|
|
|
cmSystemTools::Error("Unable to create the binary directory:\n",
|
2006-03-10 23:03:09 +03:00
|
|
|
this->BinaryDir.c_str());
|
2004-09-06 20:45:14 +04:00
|
|
|
this->RestoreBackupDirectories();
|
|
|
|
return 7;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// if the binary directory and the source directory are the same,
|
|
|
|
// and we are starting with an empty binary directory, then that means
|
|
|
|
// we must check out the source tree
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->EmptyBinDir && this->SourceDir == this->BinaryDir) {
|
2004-09-06 20:45:14 +04:00
|
|
|
// make sure we have the required info
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->CVSCheckOut.empty()) {
|
|
|
|
cmSystemTools::Error(
|
|
|
|
"You have specified the source and binary "
|
2006-03-09 19:17:10 +03:00
|
|
|
"directories to be the same (an in source build). You have also "
|
|
|
|
"specified that the binary directory is to be erased. This means "
|
|
|
|
"that the source will have to be checked out from CVS. But you have "
|
|
|
|
"not specified CTEST_CVS_CHECKOUT");
|
2004-09-06 20:45:14 +04:00
|
|
|
return 8;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// we must now checkout the src dir
|
|
|
|
retVal = this->CheckOutSourceDir();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal) {
|
2004-09-06 20:45:14 +04:00
|
|
|
this->RestoreBackupDirectories();
|
|
|
|
return retVal;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// backup the dirs if requested
|
|
|
|
retVal = this->PerformExtraUpdates();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (retVal) {
|
2004-09-06 20:45:14 +04:00
|
|
|
return retVal;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// put the initial cache into the bin dir
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->InitialCache.empty()) {
|
2011-03-11 16:04:58 +03:00
|
|
|
if (!this->WriteInitialCache(this->BinaryDir.c_str(),
|
2016-05-16 17:34:04 +03:00
|
|
|
this->InitialCache.c_str())) {
|
2004-09-06 20:45:14 +04:00
|
|
|
this->RestoreBackupDirectories();
|
|
|
|
return 9;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// do an initial cmake to setup the DartConfig file
|
|
|
|
int cmakeFailed = 0;
|
|
|
|
std::string cmakeFailedOuput;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CMakeCmd.empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
command = this->CMakeCmd;
|
2004-09-06 20:45:14 +04:00
|
|
|
command += " \"";
|
2006-03-10 23:03:09 +03:00
|
|
|
command += this->SourceDir;
|
2004-09-06 20:45:14 +04:00
|
|
|
output = "";
|
|
|
|
command += "\"";
|
|
|
|
retVal = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
|
|
|
"Run cmake command: " << command << std::endl);
|
2015-04-20 22:36:57 +03:00
|
|
|
res = cmSystemTools::RunSingleCommand(
|
2016-05-16 17:34:04 +03:00
|
|
|
command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
|
2006-03-10 23:03:09 +03:00
|
|
|
this->HandlerVerbose, 0 /*this->TimeOut*/);
|
2004-09-28 17:00:06 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->CMOutFile.empty()) {
|
2006-03-10 23:03:09 +03:00
|
|
|
std::string cmakeOutputFile = this->CMOutFile;
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileIsFullPath(cmakeOutputFile.c_str())) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmakeOutputFile = this->BinaryDir + "/" + cmakeOutputFile;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-28 17:00:06 +04:00
|
|
|
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Write CMake output to file: " << cmakeOutputFile
|
|
|
|
<< std::endl);
|
2005-05-28 00:17:38 +04:00
|
|
|
cmGeneratedFileStream fout(cmakeOutputFile.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (fout) {
|
2004-09-28 17:00:06 +04:00
|
|
|
fout << output.c_str();
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Cannot open CMake output file: "
|
|
|
|
<< cmakeOutputFile << " for writing" << std::endl);
|
2004-09-28 17:00:06 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (!res || retVal != 0) {
|
2004-09-06 20:45:14 +04:00
|
|
|
// even if this fails continue to the next step
|
|
|
|
cmakeFailed = 1;
|
|
|
|
cmakeFailedOuput = output;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
// run ctest, it may be more than one command in here
|
|
|
|
std::vector<std::string> ctestCommands;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::ExpandListArgument(this->CTestCmd, ctestCommands);
|
2004-09-06 20:45:14 +04:00
|
|
|
// for each variable/argument do a putenv
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned i = 0; i < ctestCommands.size(); ++i) {
|
2004-09-06 20:45:14 +04:00
|
|
|
command = ctestCommands[i];
|
|
|
|
output = "";
|
|
|
|
retVal = 0;
|
2016-05-16 17:34:04 +03:00
|
|
|
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
|
|
|
"Run ctest command: " << command << std::endl);
|
2015-04-20 22:36:57 +03:00
|
|
|
res = cmSystemTools::RunSingleCommand(
|
2016-05-16 17:34:04 +03:00
|
|
|
command.c_str(), &output, &output, &retVal, this->BinaryDir.c_str(),
|
|
|
|
this->HandlerVerbose, 0 /*this->TimeOut*/);
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// did something critical fail in ctest
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!res || cmakeFailed || retVal & cmCTest::BUILD_ERRORS) {
|
2004-09-06 20:45:14 +04:00
|
|
|
this->RestoreBackupDirectories();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmakeFailed) {
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Unable to run cmake:" << std::endl
|
|
|
|
<< cmakeFailedOuput << std::endl);
|
2004-09-06 20:45:14 +04:00
|
|
|
return 10;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-10 23:03:09 +03:00
|
|
|
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
2016-05-16 17:34:04 +03:00
|
|
|
"Unable to run ctest:" << std::endl
|
|
|
|
<< "command: " << command << std::endl
|
|
|
|
<< "output: " << output << std::endl);
|
|
|
|
if (!res) {
|
2004-09-06 20:45:14 +04:00
|
|
|
return 11;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
return retVal * 100;
|
2004-09-06 20:45:14 +04:00
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2004-09-06 20:45:14 +04:00
|
|
|
// if all was succesful, delete the backup dirs to free up disk space
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Backup) {
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::RemoveADirectory(this->BackupSourceDir);
|
|
|
|
cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
2006-03-09 19:17:10 +03:00
|
|
|
return 0;
|
2004-09-06 20:45:14 +04:00
|
|
|
}
|
|
|
|
|
2011-03-11 16:04:58 +03:00
|
|
|
bool cmCTestScriptHandler::WriteInitialCache(const char* directory,
|
2009-07-12 00:30:18 +04:00
|
|
|
const char* text)
|
|
|
|
{
|
|
|
|
std::string cacheFile = directory;
|
|
|
|
cacheFile += "/CMakeCache.txt";
|
|
|
|
cmGeneratedFileStream fout(cacheFile.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!fout) {
|
2009-07-12 00:30:18 +04:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-07-12 00:30:18 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (text != 0) {
|
2009-07-12 00:30:18 +04:00
|
|
|
fout.write(text, strlen(text));
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2009-07-12 00:30:18 +04:00
|
|
|
|
|
|
|
// Make sure the operating system has finished writing the file
|
|
|
|
// before closing it. This will ensure the file is finished before
|
|
|
|
// the check below.
|
|
|
|
fout.flush();
|
|
|
|
fout.close();
|
|
|
|
return true;
|
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
|
|
|
void cmCTestScriptHandler::RestoreBackupDirectories()
|
|
|
|
{
|
|
|
|
// if we backed up the dirs and the build failed, then restore
|
|
|
|
// the backed up dirs
|
2016-05-16 17:34:04 +03:00
|
|
|
if (this->Backup) {
|
2004-09-06 20:45:14 +04:00
|
|
|
// if for some reason those directories exist then first delete them
|
2016-05-16 17:34:04 +03:00
|
|
|
if (cmSystemTools::FileExists(this->SourceDir.c_str())) {
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::RemoveADirectory(this->SourceDir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
|
|
|
if (cmSystemTools::FileExists(this->BinaryDir.c_str())) {
|
2014-10-15 16:54:05 +04:00
|
|
|
cmSystemTools::RemoveADirectory(this->BinaryDir);
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
// rename the src and binary directories
|
2006-03-10 23:03:09 +03:00
|
|
|
rename(this->BackupSourceDir.c_str(), this->SourceDir.c_str());
|
|
|
|
rename(this->BackupBinaryDir.c_str(), this->BinaryDir.c_str());
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
}
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char* sname,
|
2009-09-04 21:24:25 +04:00
|
|
|
bool InProcess, int* returnValue)
|
2005-01-27 18:11:04 +03:00
|
|
|
{
|
|
|
|
cmCTestScriptHandler* sh = new cmCTestScriptHandler();
|
2005-01-27 19:43:22 +03:00
|
|
|
sh->SetCTestInstance(ctest);
|
2016-05-16 17:34:04 +03:00
|
|
|
sh->AddConfigurationScript(sname, InProcess);
|
2009-09-04 21:24:25 +04:00
|
|
|
int res = sh->ProcessHandler();
|
2016-05-16 17:34:04 +03:00
|
|
|
if (returnValue) {
|
2009-09-04 21:24:25 +04:00
|
|
|
*returnValue = res;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2005-01-27 18:11:04 +03:00
|
|
|
delete sh;
|
|
|
|
return true;
|
|
|
|
}
|
2004-09-06 20:45:14 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
bool cmCTestScriptHandler::EmptyBinaryDirectory(const char* sname)
|
2005-01-27 18:11:04 +03:00
|
|
|
{
|
|
|
|
// try to avoid deleting root
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!sname || strlen(sname) < 2) {
|
2005-01-27 18:11:04 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-03-09 19:17:10 +03:00
|
|
|
|
2013-11-02 00:55:45 +04:00
|
|
|
// consider non existing target directory a success
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(sname)) {
|
2013-11-02 00:55:45 +04:00
|
|
|
return true;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-11-02 00:55:45 +04:00
|
|
|
|
2005-01-27 18:11:04 +03:00
|
|
|
// try to avoid deleting directories that we shouldn't
|
|
|
|
std::string check = sname;
|
|
|
|
check += "/CMakeCache.txt";
|
2013-11-02 00:55:45 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!cmSystemTools::FileExists(check.c_str())) {
|
2005-03-11 20:56:10 +03:00
|
|
|
return false;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-11-02 00:55:45 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (int i = 0; i < 5; ++i) {
|
|
|
|
if (TryToRemoveBinaryDirectoryOnce(sname)) {
|
2013-11-02 00:55:45 +04:00
|
|
|
return true;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
cmSystemTools::Delay(100);
|
|
|
|
}
|
2013-11-02 00:55:45 +04:00
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool cmCTestScriptHandler::TryToRemoveBinaryDirectoryOnce(
|
|
|
|
const std::string& directoryPath)
|
|
|
|
{
|
|
|
|
cmsys::Directory directory;
|
2014-10-15 16:54:05 +04:00
|
|
|
directory.Load(directoryPath);
|
2013-11-02 00:55:45 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
for (unsigned long i = 0; i < directory.GetNumberOfFiles(); ++i) {
|
2013-11-02 00:55:45 +04:00
|
|
|
std::string path = directory.GetFile(i);
|
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (path == "." || path == ".." || path == "CMakeCache.txt") {
|
2013-11-02 00:55:45 +04:00
|
|
|
continue;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-11-02 00:55:45 +04:00
|
|
|
|
|
|
|
std::string fullPath = directoryPath + std::string("/") + path;
|
|
|
|
|
2014-10-15 16:54:05 +04:00
|
|
|
bool isDirectory = cmSystemTools::FileIsDirectory(fullPath) &&
|
|
|
|
!cmSystemTools::FileIsSymlink(fullPath);
|
2013-11-02 00:55:45 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (isDirectory) {
|
|
|
|
if (!cmSystemTools::RemoveADirectory(fullPath)) {
|
2013-11-02 00:55:45 +04:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
} else {
|
|
|
|
if (!cmSystemTools::RemoveFile(fullPath)) {
|
2013-11-02 00:55:45 +04:00
|
|
|
return false;
|
|
|
|
}
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2013-11-02 00:55:45 +04:00
|
|
|
}
|
|
|
|
|
2014-10-15 16:54:05 +04:00
|
|
|
return cmSystemTools::RemoveADirectory(directoryPath);
|
2005-01-27 18:11:04 +03:00
|
|
|
}
|
2006-10-19 18:45:19 +04:00
|
|
|
|
|
|
|
double cmCTestScriptHandler::GetRemainingTimeAllowed()
|
|
|
|
{
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!this->Makefile) {
|
2006-10-19 18:45:19 +04:00
|
|
|
return 1.0e7;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-10-19 18:45:19 +04:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
const char* timelimitS = this->Makefile->GetDefinition("CTEST_TIME_LIMIT");
|
2011-03-11 16:04:58 +03:00
|
|
|
|
2016-05-16 17:34:04 +03:00
|
|
|
if (!timelimitS) {
|
2006-10-19 18:45:19 +04:00
|
|
|
return 1.0e7;
|
2016-05-16 17:34:04 +03:00
|
|
|
}
|
2006-10-19 18:45:19 +04:00
|
|
|
|
|
|
|
double timelimit = atof(timelimitS);
|
2011-03-11 16:04:58 +03:00
|
|
|
|
2006-10-19 18:45:19 +04:00
|
|
|
return timelimit - cmSystemTools::GetTime() + this->ScriptStartTime;
|
|
|
|
}
|