CTest: Remove declarative scripting mode
This commit is contained in:
parent
902ab3b263
commit
267b42bccc
@ -9,7 +9,6 @@ runs a :option:`ctest -S` script
|
||||
script_file_name2 ... [RETURN_VALUE var])
|
||||
|
||||
Runs a script or scripts much like if it was run from :option:`ctest -S`.
|
||||
If no argument is provided then the current script is run using the current
|
||||
settings of the variables. If ``NEW_PROCESS`` is specified then each
|
||||
script will be run in a separate process.If ``RETURN_VALUE`` is specified
|
||||
the return value of the last script run will be put into ``var``.
|
||||
If ``NEW_PROCESS`` is specified then each script will be run in a separate
|
||||
process. If ``RETURN_VALUE`` is specified the return value of the last script
|
||||
run will be put into ``var``.
|
||||
|
14
Help/release/dev/ctest-remove-declarative-script-mode.rst
Normal file
14
Help/release/dev/ctest-remove-declarative-script-mode.rst
Normal file
@ -0,0 +1,14 @@
|
||||
ctest-remove-declarative-script-mode
|
||||
------------------------------------
|
||||
|
||||
* CTest's declarative scripting mode has been removed. This mode used to be
|
||||
triggered by a :option:`ctest -S` script which did not call any
|
||||
:ref:`CTest Commands` unless :variable:`CTEST_RUN_CURRENT_SCRIPT` was
|
||||
explicitly set to ``OFF``. This feature was undocumented and was not covered
|
||||
by any unit tests.
|
||||
|
||||
* The :variable:`CTEST_RUN_CURRENT_SCRIPT` variable no longer has any special
|
||||
meaning.
|
||||
|
||||
* The :command:`ctest_run_script` command may no longer be called without any
|
||||
arguments.
|
@ -1,7 +1,5 @@
|
||||
CTEST_RUN_CURRENT_SCRIPT
|
||||
------------------------
|
||||
|
||||
.. versionadded:: 3.11
|
||||
|
||||
Setting this to 0 prevents :manual:`ctest(1)` from being run again when it
|
||||
reaches the end of a script run by calling :option:`ctest -S`.
|
||||
Removed. This variable once supported an undocumented feature that has since
|
||||
been removed.
|
||||
|
@ -3,16 +3,15 @@
|
||||
#include "cmCTestRunScriptCommand.h"
|
||||
|
||||
#include "cmCTestScriptHandler.h"
|
||||
#include "cmExecutionStatus.h"
|
||||
#include "cmMakefile.h"
|
||||
|
||||
class cmExecutionStatus;
|
||||
|
||||
bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
|
||||
cmExecutionStatus& /*unused*/)
|
||||
cmExecutionStatus& status)
|
||||
{
|
||||
if (args.empty()) {
|
||||
this->CTestScriptHandler->RunCurrentScript();
|
||||
return true;
|
||||
status.SetError("called with incorrect number of arguments");
|
||||
return false;
|
||||
}
|
||||
|
||||
bool np = false;
|
||||
|
@ -2,7 +2,6 @@
|
||||
file Copyright.txt or https://cmake.org/licensing for details. */
|
||||
#include "cmCTestScriptHandler.h"
|
||||
|
||||
#include <cstdio>
|
||||
#include <cstdlib>
|
||||
#include <map>
|
||||
#include <ratio>
|
||||
@ -32,9 +31,7 @@
|
||||
#include "cmCTestUploadCommand.h"
|
||||
#include "cmCommand.h"
|
||||
#include "cmDuration.h"
|
||||
#include "cmGeneratedFileStream.h"
|
||||
#include "cmGlobalGenerator.h"
|
||||
#include "cmList.h"
|
||||
#include "cmMakefile.h"
|
||||
#include "cmState.h"
|
||||
#include "cmStateDirectory.h"
|
||||
@ -57,26 +54,6 @@ cmCTestScriptHandler::cmCTestScriptHandler() = default;
|
||||
void cmCTestScriptHandler::Initialize()
|
||||
{
|
||||
this->Superclass::Initialize();
|
||||
this->Backup = false;
|
||||
this->EmptyBinDir = false;
|
||||
this->EmptyBinDirOnce = false;
|
||||
|
||||
this->SourceDir.clear();
|
||||
this->BinaryDir.clear();
|
||||
this->BackupSourceDir.clear();
|
||||
this->BackupBinaryDir.clear();
|
||||
this->CTestRoot.clear();
|
||||
this->CVSCheckOut.clear();
|
||||
this->CTestCmd.clear();
|
||||
this->UpdateCmd.clear();
|
||||
this->CTestEnv.clear();
|
||||
this->InitialCache.clear();
|
||||
this->CMakeCmd.clear();
|
||||
this->CMOutFile.clear();
|
||||
this->ExtraUpdates.clear();
|
||||
|
||||
this->MinimumInterval = 20 * 60;
|
||||
this->ContinuousDuration = -1;
|
||||
|
||||
// what time in seconds did this script start running
|
||||
this->ScriptStartTime = std::chrono::steady_clock::time_point();
|
||||
@ -314,8 +291,6 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
|
||||
cmSystemTools::GetCTestCommand());
|
||||
this->Makefile->AddDefinition("CMAKE_EXECUTABLE_NAME",
|
||||
cmSystemTools::GetCMakeCommand());
|
||||
this->Makefile->AddDefinitionBool("CTEST_RUN_CURRENT_SCRIPT", true);
|
||||
this->SetRunCurrentScript(true);
|
||||
this->UpdateElapsedTime();
|
||||
|
||||
// set the CTEST_CONFIGURATION_TYPE variable to the current value of the
|
||||
@ -366,104 +341,6 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
|
||||
return 0;
|
||||
}
|
||||
|
||||
// extract variables from the script to set ivars
|
||||
int cmCTestScriptHandler::ExtractVariables()
|
||||
{
|
||||
// Temporary variables
|
||||
cmValue minInterval;
|
||||
cmValue contDuration;
|
||||
|
||||
this->SourceDir =
|
||||
this->Makefile->GetSafeDefinition("CTEST_SOURCE_DIRECTORY");
|
||||
this->BinaryDir =
|
||||
this->Makefile->GetSafeDefinition("CTEST_BINARY_DIRECTORY");
|
||||
|
||||
// add in translations for src and bin
|
||||
cmSystemTools::AddKeepPath(this->SourceDir);
|
||||
cmSystemTools::AddKeepPath(this->BinaryDir);
|
||||
|
||||
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");
|
||||
|
||||
char updateVar[40];
|
||||
int i;
|
||||
for (i = 1; i < 10; ++i) {
|
||||
snprintf(updateVar, sizeof(updateVar), "CTEST_EXTRA_UPDATES_%i", i);
|
||||
cmValue updateVal = this->Makefile->GetDefinition(updateVar);
|
||||
if (updateVal) {
|
||||
if (this->UpdateCmd.empty()) {
|
||||
cmSystemTools::Error(
|
||||
std::string(updateVar) +
|
||||
" specified without specifying CTEST_CVS_COMMAND.");
|
||||
return 12;
|
||||
}
|
||||
this->ExtraUpdates.emplace_back(*updateVal);
|
||||
}
|
||||
}
|
||||
|
||||
// in order to backup and restore we also must have the cvs root
|
||||
if (this->Backup && this->CVSCheckOut.empty()) {
|
||||
cmSystemTools::Error(
|
||||
"Backup was requested without specifying CTEST_CVS_CHECKOUT.");
|
||||
return 3;
|
||||
}
|
||||
|
||||
// make sure the required info is here
|
||||
if (this->SourceDir.empty() || this->BinaryDir.empty() ||
|
||||
this->CTestCmd.empty()) {
|
||||
std::string msg =
|
||||
cmStrCat("CTEST_SOURCE_DIRECTORY = ",
|
||||
(!this->SourceDir.empty()) ? this->SourceDir.c_str() : "(Null)",
|
||||
"\nCTEST_BINARY_DIRECTORY = ",
|
||||
(!this->BinaryDir.empty()) ? this->BinaryDir.c_str() : "(Null)",
|
||||
"\nCTEST_COMMAND = ",
|
||||
(!this->CTestCmd.empty()) ? this->CTestCmd.c_str() : "(Null)");
|
||||
cmSystemTools::Error(
|
||||
"Some required settings in the configuration file were missing:\n" +
|
||||
msg);
|
||||
return 4;
|
||||
}
|
||||
|
||||
// if the dashboard root isn't specified then we can compute it from the
|
||||
// this->SourceDir
|
||||
if (this->CTestRoot.empty()) {
|
||||
this->CTestRoot = cmSystemTools::GetFilenamePath(this->SourceDir);
|
||||
}
|
||||
|
||||
// the script may override the minimum continuous interval
|
||||
if (minInterval) {
|
||||
this->MinimumInterval = 60 * atof(minInterval->c_str());
|
||||
}
|
||||
if (contDuration) {
|
||||
this->ContinuousDuration = 60.0 * atof(contDuration->c_str());
|
||||
}
|
||||
|
||||
this->UpdateElapsedTime();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
void cmCTestScriptHandler::SleepInSeconds(unsigned int secondsToWait)
|
||||
{
|
||||
#if defined(_WIN32)
|
||||
@ -495,355 +372,10 @@ int cmCTestScriptHandler::RunConfigurationScript(
|
||||
"Executing Script: " << total_script_arg << std::endl);
|
||||
result = this->ExecuteScript(total_script_arg);
|
||||
}
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// only run the current script if we should
|
||||
if (this->Makefile && this->Makefile->IsOn("CTEST_RUN_CURRENT_SCRIPT") &&
|
||||
this->ShouldRunCurrentScript) {
|
||||
return this->RunCurrentScript();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
int cmCTestScriptHandler::RunCurrentScript()
|
||||
{
|
||||
int result;
|
||||
|
||||
// do not run twice
|
||||
this->SetRunCurrentScript(false);
|
||||
|
||||
// no popup widows
|
||||
cmSystemTools::SetRunCommandHideConsole(true);
|
||||
|
||||
// extract the vars from the cache and store in ivars
|
||||
result = this->ExtractVariables();
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
// set any environment variables
|
||||
if (!this->CTestEnv.empty()) {
|
||||
cmList envArgs{ this->CTestEnv };
|
||||
cmSystemTools::AppendEnv(envArgs);
|
||||
}
|
||||
|
||||
// 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 need to run it more than once?
|
||||
if (this->ContinuousDuration >= 0) {
|
||||
this->UpdateElapsedTime();
|
||||
auto ending_time =
|
||||
std::chrono::steady_clock::now() + cmDuration(this->ContinuousDuration);
|
||||
if (this->EmptyBinDirOnce) {
|
||||
this->EmptyBinDir = true;
|
||||
}
|
||||
do {
|
||||
auto startOfInterval = std::chrono::steady_clock::now();
|
||||
result = this->RunConfigurationDashboard();
|
||||
auto interval = std::chrono::steady_clock::now() - startOfInterval;
|
||||
auto minimumInterval = cmDuration(this->MinimumInterval);
|
||||
if (interval < minimumInterval) {
|
||||
auto sleepTime =
|
||||
cmDurationTo<unsigned int>(minimumInterval - interval);
|
||||
this->SleepInSeconds(sleepTime);
|
||||
}
|
||||
if (this->EmptyBinDirOnce) {
|
||||
this->EmptyBinDir = false;
|
||||
}
|
||||
} while (std::chrono::steady_clock::now() < ending_time);
|
||||
}
|
||||
// otherwise just run it once
|
||||
else {
|
||||
result = this->RunConfigurationDashboard();
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
int cmCTestScriptHandler::CheckOutSourceDir()
|
||||
{
|
||||
std::string output;
|
||||
int retVal;
|
||||
|
||||
if (!cmSystemTools::FileExists(this->SourceDir) &&
|
||||
!this->CVSCheckOut.empty()) {
|
||||
// we must now checkout the src dir
|
||||
output.clear();
|
||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||
"Run cvs: " << this->CVSCheckOut << std::endl);
|
||||
bool res = cmSystemTools::RunSingleCommand(
|
||||
this->CVSCheckOut, &output, &output, &retVal, this->CTestRoot.c_str(),
|
||||
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
||||
if (!res || retVal != 0) {
|
||||
cmSystemTools::Error("Unable to perform cvs checkout:\n" + output);
|
||||
return 6;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmCTestScriptHandler::BackupDirectories()
|
||||
{
|
||||
// compute the backup names
|
||||
this->BackupSourceDir = cmStrCat(this->SourceDir, "_CMakeBackup");
|
||||
this->BackupBinaryDir = cmStrCat(this->BinaryDir, "_CMakeBackup");
|
||||
|
||||
// backup the binary and src directories if requested
|
||||
if (this->Backup) {
|
||||
// if for some reason those directories exist then first delete them
|
||||
if (cmSystemTools::FileExists(this->BackupSourceDir)) {
|
||||
cmSystemTools::RemoveADirectory(this->BackupSourceDir);
|
||||
}
|
||||
if (cmSystemTools::FileExists(this->BackupBinaryDir)) {
|
||||
cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
|
||||
}
|
||||
|
||||
// first rename the src and binary directories
|
||||
rename(this->SourceDir.c_str(), this->BackupSourceDir.c_str());
|
||||
rename(this->BinaryDir.c_str(), this->BackupBinaryDir.c_str());
|
||||
|
||||
// we must now checkout the src dir
|
||||
int retVal = this->CheckOutSourceDir();
|
||||
if (retVal) {
|
||||
this->RestoreBackupDirectories();
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int cmCTestScriptHandler::PerformExtraUpdates()
|
||||
{
|
||||
std::string command;
|
||||
std::string output;
|
||||
int retVal;
|
||||
bool res;
|
||||
|
||||
// do an initial cvs update as required
|
||||
command = this->UpdateCmd;
|
||||
for (std::string const& eu : this->ExtraUpdates) {
|
||||
cmList cvsArgs{ eu };
|
||||
if (cvsArgs.size() == 2) {
|
||||
std::string fullCommand = cmStrCat(command, " update ", cvsArgs[1]);
|
||||
output.clear();
|
||||
retVal = 0;
|
||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||
"Run Update: " << fullCommand << std::endl);
|
||||
res = cmSystemTools::RunSingleCommand(
|
||||
fullCommand, &output, &output, &retVal, cvsArgs[0].c_str(),
|
||||
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
||||
if (!res || retVal != 0) {
|
||||
cmSystemTools::Error(cmStrCat("Unable to perform extra updates:\n", eu,
|
||||
"\nWith output:\n", output));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
// run a single dashboard entry
|
||||
int cmCTestScriptHandler::RunConfigurationDashboard()
|
||||
{
|
||||
// local variables
|
||||
std::string command;
|
||||
std::string output;
|
||||
int retVal;
|
||||
bool res;
|
||||
|
||||
// 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();
|
||||
if (retVal) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// backup the dirs if requested
|
||||
retVal = this->BackupDirectories();
|
||||
if (retVal) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// clear the binary directory?
|
||||
if (this->EmptyBinDir) {
|
||||
std::string err;
|
||||
if (!cmCTestScriptHandler::EmptyBinaryDirectory(this->BinaryDir, err)) {
|
||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||
"Problem removing the binary directory ("
|
||||
<< err << "): " << this->BinaryDir << std::endl);
|
||||
}
|
||||
}
|
||||
|
||||
// make sure the binary directory exists if it isn't the srcdir
|
||||
if (!cmSystemTools::FileExists(this->BinaryDir) &&
|
||||
this->SourceDir != this->BinaryDir) {
|
||||
if (!cmSystemTools::MakeDirectory(this->BinaryDir)) {
|
||||
cmSystemTools::Error("Unable to create the binary directory:\n" +
|
||||
this->BinaryDir);
|
||||
this->RestoreBackupDirectories();
|
||||
return 7;
|
||||
}
|
||||
}
|
||||
|
||||
// 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
|
||||
if (this->EmptyBinDir && this->SourceDir == this->BinaryDir) {
|
||||
// make sure we have the required info
|
||||
if (this->CVSCheckOut.empty()) {
|
||||
cmSystemTools::Error(
|
||||
"You have specified the source and binary "
|
||||
"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");
|
||||
return 8;
|
||||
}
|
||||
|
||||
// we must now checkout the src dir
|
||||
retVal = this->CheckOutSourceDir();
|
||||
if (retVal) {
|
||||
this->RestoreBackupDirectories();
|
||||
return retVal;
|
||||
}
|
||||
}
|
||||
|
||||
// backup the dirs if requested
|
||||
retVal = this->PerformExtraUpdates();
|
||||
if (retVal) {
|
||||
return retVal;
|
||||
}
|
||||
|
||||
// put the initial cache into the bin dir
|
||||
if (!this->InitialCache.empty()) {
|
||||
if (!cmCTestScriptHandler::WriteInitialCache(this->BinaryDir,
|
||||
this->InitialCache)) {
|
||||
this->RestoreBackupDirectories();
|
||||
return 9;
|
||||
}
|
||||
}
|
||||
|
||||
// do an initial cmake to setup the DartConfig file
|
||||
int cmakeFailed = 0;
|
||||
std::string cmakeFailedOuput;
|
||||
if (!this->CMakeCmd.empty()) {
|
||||
command = cmStrCat(this->CMakeCmd, " \"", this->SourceDir);
|
||||
output.clear();
|
||||
command += "\"";
|
||||
retVal = 0;
|
||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||
"Run cmake command: " << command << std::endl);
|
||||
res = cmSystemTools::RunSingleCommand(
|
||||
command, &output, &output, &retVal, this->BinaryDir.c_str(),
|
||||
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
||||
|
||||
if (!this->CMOutFile.empty()) {
|
||||
std::string cmakeOutputFile = this->CMOutFile;
|
||||
if (!cmSystemTools::FileIsFullPath(cmakeOutputFile)) {
|
||||
cmakeOutputFile = this->BinaryDir + "/" + cmakeOutputFile;
|
||||
}
|
||||
|
||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||
"Write CMake output to file: " << cmakeOutputFile
|
||||
<< std::endl);
|
||||
cmGeneratedFileStream fout(cmakeOutputFile);
|
||||
if (fout) {
|
||||
fout << output.c_str();
|
||||
} else {
|
||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||
"Cannot open CMake output file: "
|
||||
<< cmakeOutputFile << " for writing" << std::endl);
|
||||
}
|
||||
}
|
||||
if (!res || retVal != 0) {
|
||||
// even if this fails continue to the next step
|
||||
cmakeFailed = 1;
|
||||
cmakeFailedOuput = output;
|
||||
}
|
||||
}
|
||||
|
||||
// run ctest, it may be more than one command in here
|
||||
cmList ctestCommands{ this->CTestCmd };
|
||||
// for each variable/argument do a putenv
|
||||
for (std::string const& ctestCommand : ctestCommands) {
|
||||
command = ctestCommand;
|
||||
output.clear();
|
||||
retVal = 0;
|
||||
cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT,
|
||||
"Run ctest command: " << command << std::endl);
|
||||
res = cmSystemTools::RunSingleCommand(
|
||||
command, &output, &output, &retVal, this->BinaryDir.c_str(),
|
||||
this->HandlerVerbose, cmDuration::zero() /*this->TimeOut*/);
|
||||
|
||||
// did something critical fail in ctest
|
||||
if (!res || cmakeFailed || retVal & cmCTest::BUILD_ERRORS) {
|
||||
this->RestoreBackupDirectories();
|
||||
if (cmakeFailed) {
|
||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||
"Unable to run cmake:" << std::endl
|
||||
<< cmakeFailedOuput << std::endl);
|
||||
return 10;
|
||||
}
|
||||
cmCTestLog(this->CTest, ERROR_MESSAGE,
|
||||
"Unable to run ctest:" << std::endl
|
||||
<< "command: " << command << std::endl
|
||||
<< "output: " << output << std::endl);
|
||||
if (!res) {
|
||||
return 11;
|
||||
}
|
||||
return retVal * 100;
|
||||
}
|
||||
}
|
||||
|
||||
// if all was successful, delete the backup dirs to free up disk space
|
||||
if (this->Backup) {
|
||||
cmSystemTools::RemoveADirectory(this->BackupSourceDir);
|
||||
cmSystemTools::RemoveADirectory(this->BackupBinaryDir);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool cmCTestScriptHandler::WriteInitialCache(const std::string& directory,
|
||||
const std::string& text)
|
||||
{
|
||||
std::string cacheFile = cmStrCat(directory, "/CMakeCache.txt");
|
||||
cmGeneratedFileStream fout(cacheFile);
|
||||
if (!fout) {
|
||||
return false;
|
||||
}
|
||||
|
||||
fout.write(text.data(), text.size());
|
||||
|
||||
// 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;
|
||||
}
|
||||
|
||||
void cmCTestScriptHandler::RestoreBackupDirectories()
|
||||
{
|
||||
// if we backed up the dirs and the build failed, then restore
|
||||
// the backed up dirs
|
||||
if (this->Backup) {
|
||||
// if for some reason those directories exist then first delete them
|
||||
if (cmSystemTools::FileExists(this->SourceDir)) {
|
||||
cmSystemTools::RemoveADirectory(this->SourceDir);
|
||||
}
|
||||
if (cmSystemTools::FileExists(this->BinaryDir)) {
|
||||
cmSystemTools::RemoveADirectory(this->BinaryDir);
|
||||
}
|
||||
// rename the src and binary directories
|
||||
rename(this->BackupSourceDir.c_str(), this->SourceDir.c_str());
|
||||
rename(this->BackupBinaryDir.c_str(), this->BinaryDir.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
bool cmCTestScriptHandler::RunScript(cmCTest* ctest, cmMakefile* mf,
|
||||
const std::string& sname, bool InProcess,
|
||||
int* returnValue)
|
||||
@ -944,8 +476,3 @@ cmDuration cmCTestScriptHandler::GetRemainingTimeAllowed()
|
||||
std::chrono::steady_clock::now() - this->ScriptStartTime);
|
||||
return (timelimit - duration);
|
||||
}
|
||||
|
||||
void cmCTestScriptHandler::SetRunCurrentScript(bool value)
|
||||
{
|
||||
this->ShouldRunCurrentScript = value;
|
||||
}
|
||||
|
@ -22,39 +22,6 @@ class cmake;
|
||||
|
||||
/** \class cmCTestScriptHandler
|
||||
* \brief A class that handles ctest -S invocations
|
||||
*
|
||||
* CTest script is controlled using several variables that script has to
|
||||
* specify and some optional ones. Required ones are:
|
||||
* CTEST_SOURCE_DIRECTORY - Source directory of the project
|
||||
* CTEST_BINARY_DIRECTORY - Binary directory of the project
|
||||
* CTEST_COMMAND - Testing commands
|
||||
*
|
||||
* Optional variables are:
|
||||
* CTEST_BACKUP_AND_RESTORE
|
||||
* CTEST_CMAKE_COMMAND
|
||||
* CTEST_CMAKE_OUTPUT_FILE_NAME
|
||||
* CTEST_CONTINUOUS_DURATION
|
||||
* CTEST_CONTINUOUS_MINIMUM_INTERVAL
|
||||
* CTEST_CVS_CHECKOUT
|
||||
* CTEST_CVS_COMMAND
|
||||
* CTEST_UPDATE_COMMAND
|
||||
* CTEST_DASHBOARD_ROOT
|
||||
* CTEST_ENVIRONMENT
|
||||
* CTEST_INITIAL_CACHE
|
||||
* CTEST_START_WITH_EMPTY_BINARY_DIRECTORY
|
||||
* CTEST_START_WITH_EMPTY_BINARY_DIRECTORY_ONCE
|
||||
*
|
||||
* In addition the following variables can be used. The number can be 1-10.
|
||||
* CTEST_EXTRA_UPDATES_1
|
||||
* CTEST_EXTRA_UPDATES_2
|
||||
* ...
|
||||
* CTEST_EXTRA_UPDATES_10
|
||||
*
|
||||
* CTest script can use the following arguments CTest provides:
|
||||
* CTEST_SCRIPT_ARG
|
||||
* CTEST_SCRIPT_DIRECTORY
|
||||
* CTEST_SCRIPT_NAME
|
||||
*
|
||||
*/
|
||||
class cmCTestScriptHandler : public cmCTestGenericHandler
|
||||
{
|
||||
@ -77,19 +44,12 @@ public:
|
||||
static bool RunScript(cmCTest* ctest, cmMakefile* mf,
|
||||
const std::string& script, bool InProcess,
|
||||
int* returnValue);
|
||||
int RunCurrentScript();
|
||||
|
||||
/*
|
||||
* Empty Binary Directory
|
||||
*/
|
||||
static bool EmptyBinaryDirectory(const std::string& dir, std::string& err);
|
||||
|
||||
/*
|
||||
* Write an initial CMakeCache.txt from the given contents.
|
||||
*/
|
||||
static bool WriteInitialCache(const std::string& directory,
|
||||
const std::string& text);
|
||||
|
||||
/*
|
||||
* Some elapsed time handling functions
|
||||
*/
|
||||
@ -113,28 +73,12 @@ public:
|
||||
void CreateCMake();
|
||||
cmake* GetCMake() { return this->CMake.get(); }
|
||||
|
||||
void SetRunCurrentScript(bool value);
|
||||
|
||||
private:
|
||||
// reads in a script
|
||||
int ReadInScript(const std::string& total_script_arg);
|
||||
int ExecuteScript(const std::string& total_script_arg);
|
||||
|
||||
// extract vars from the script to set ivars
|
||||
int ExtractVariables();
|
||||
|
||||
// perform a CVS checkout of the source dir
|
||||
int CheckOutSourceDir();
|
||||
|
||||
// perform any extra cvs updates that were requested
|
||||
int PerformExtraUpdates();
|
||||
|
||||
// backup and restore dirs
|
||||
int BackupDirectories();
|
||||
void RestoreBackupDirectories();
|
||||
|
||||
int RunConfigurationScript(const std::string& script, bool pscope);
|
||||
int RunConfigurationDashboard();
|
||||
|
||||
// Add ctest command
|
||||
void AddCTestCommand(std::string const& name,
|
||||
@ -147,30 +91,6 @@ private:
|
||||
std::vector<std::string> ConfigurationScripts;
|
||||
std::vector<bool> ScriptProcessScope;
|
||||
|
||||
bool ShouldRunCurrentScript;
|
||||
|
||||
bool Backup = false;
|
||||
bool EmptyBinDir = false;
|
||||
bool EmptyBinDirOnce = false;
|
||||
|
||||
std::string SourceDir;
|
||||
std::string BinaryDir;
|
||||
std::string BackupSourceDir;
|
||||
std::string BackupBinaryDir;
|
||||
std::string CTestRoot;
|
||||
std::string CVSCheckOut;
|
||||
std::string CTestCmd;
|
||||
std::string UpdateCmd;
|
||||
std::string CTestEnv;
|
||||
std::string InitialCache;
|
||||
std::string CMakeCmd;
|
||||
std::string CMOutFile;
|
||||
std::vector<std::string> ExtraUpdates;
|
||||
|
||||
// the *60 is because the settings are in minutes but GetTime is seconds
|
||||
double MinimumInterval = 30 * 60;
|
||||
double ContinuousDuration = -1;
|
||||
|
||||
// what time in seconds did this script start running
|
||||
std::chrono::steady_clock::time_point ScriptStartTime =
|
||||
std::chrono::steady_clock::time_point();
|
||||
|
@ -144,7 +144,6 @@ bool cmCTestStartCommand::InitialPass(std::vector<std::string> const& args,
|
||||
return false;
|
||||
}
|
||||
|
||||
this->CTest->SetRunCurrentScript(false);
|
||||
this->CTest->SetSuppressUpdatingCTestConfiguration(true);
|
||||
int model;
|
||||
if (smodel) {
|
||||
|
@ -3805,11 +3805,6 @@ cmDuration cmCTest::MaxDuration()
|
||||
return cmDuration(1.0e7);
|
||||
}
|
||||
|
||||
void cmCTest::SetRunCurrentScript(bool value)
|
||||
{
|
||||
this->GetScriptHandler()->SetRunCurrentScript(value);
|
||||
}
|
||||
|
||||
void cmCTest::OutputTestErrors(std::vector<char> const& process_output)
|
||||
{
|
||||
std::string test_outputs("\n*** Test Failed:\n");
|
||||
|
@ -462,8 +462,6 @@ public:
|
||||
void GenerateSubprojectsOutput(cmXMLWriter& xml);
|
||||
std::vector<std::string> GetLabelsForSubprojects();
|
||||
|
||||
void SetRunCurrentScript(bool value);
|
||||
|
||||
private:
|
||||
void SetPersistentOptionIfNotEmpty(const std::string& value,
|
||||
const std::string& optionName);
|
||||
|
@ -2589,9 +2589,9 @@ if(BUILD_TESTING)
|
||||
# A simple test for ctest in script mode
|
||||
configure_file("${CMake_SOURCE_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake.in"
|
||||
"${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake" @ONLY)
|
||||
# add_test(CTest.ScriptMode ${CMAKE_CTEST_COMMAND}
|
||||
# -S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake"
|
||||
# )
|
||||
add_test(CTest.ScriptMode ${CMAKE_CTEST_COMMAND}
|
||||
-S "${CMake_BINARY_DIR}/Tests/CTestScriptMode/CTestTestScriptMode.cmake"
|
||||
)
|
||||
|
||||
# Test CTest Update with Subversion
|
||||
if(NOT DEFINED CMake_TEST_CTestUpdate_SVN OR CMake_TEST_CTestUpdate_SVN)
|
||||
|
@ -1,5 +1,3 @@
|
||||
set(CTEST_RUN_CURRENT_SCRIPT 0)
|
||||
|
||||
macro(check_arg name expected_value)
|
||||
message("${name}='${${name}}'")
|
||||
if(NOT "${${name}}" STREQUAL "${expected_value}")
|
||||
|
@ -1,5 +1,3 @@
|
||||
set(CTEST_RUN_CURRENT_SCRIPT 0)
|
||||
|
||||
if(NOT DEFINED basefilename)
|
||||
message(FATAL_ERROR "pass -Dbasefilename=f1")
|
||||
endif()
|
||||
|
@ -6,9 +6,3 @@ set(CMAKE_CMAKE_SYSTEM_NAME "@CMAKE_SYSTEM_NAME@")
|
||||
if (NOT "${CMAKE_SYSTEM_NAME}" STREQUAL "${CMAKE_CMAKE_SYSTEM_NAME}")
|
||||
message(FATAL_ERROR "Error: CMAKE_SYSTEM_NAME is \"${CMAKE_SYSTEM_NAME}\", but should be \"@CMAKE_SYSTEM_NAME@\"")
|
||||
endif()
|
||||
|
||||
# this seems to be necessary, otherwise ctest complains that these
|
||||
# variables are not set:
|
||||
set(CTEST_COMMAND "\"@CMAKE_CTEST_COMMAND@\"")
|
||||
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestScriptMode/")
|
||||
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestScriptMode/")
|
||||
|
@ -1,7 +1,5 @@
|
||||
cmake_minimum_required(VERSION 3.10)
|
||||
|
||||
set(CTEST_RUN_CURRENT_SCRIPT 0)
|
||||
|
||||
set(CTEST_SOURCE_DIRECTORY "@CMake_SOURCE_DIR@/Tests/CTestTestEmptyBinaryDirectory")
|
||||
set(CTEST_BINARY_DIRECTORY "@CMake_BINARY_DIR@/Tests/CTestTestEmptyBinaryDirectory")
|
||||
|
||||
|
@ -1,2 +1 @@
|
||||
set(CTEST_RUN_CURRENT_SCRIPT 0)
|
||||
message("hello world")
|
||||
|
@ -1,2 +1 @@
|
||||
set(CTEST_RUN_CURRENT_SCRIPT 0)
|
||||
CTEST_RUN_SCRIPT("CTestTestRunScript/hello.cmake" RETURN_VALUE res RETURN_VALUE)
|
||||
|
@ -1,5 +1,3 @@
|
||||
set(CTEST_RUN_CURRENT_SCRIPT 0)
|
||||
|
||||
set(LOCK_FILE "${TEST_NAME}.lock")
|
||||
|
||||
# Delete the old lock file in case it's lingering from a previous failed test run
|
||||
|
@ -1,5 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
set(CTEST_RUN_CURRENT_SCRIPT 0)
|
||||
|
||||
get_property(role GLOBAL PROPERTY CMAKE_ROLE)
|
||||
if(NOT role STREQUAL "CTEST")
|
||||
|
@ -19,7 +19,7 @@ Call Stack \(most recent call first\):
|
||||
.*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
|
||||
.*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
|
||||
.*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
|
||||
.*/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-env/test\.cmake:10 \(ctest_read_custom_files\)
|
||||
.*/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-env/test\.cmake:5 \(ctest_read_custom_files\)
|
||||
|
||||
|
||||
Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
|
||||
|
@ -19,7 +19,7 @@ Call Stack \(most recent call first\):
|
||||
.*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
|
||||
.*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
|
||||
.*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake:3 \(ctest_read_custom_files\)
|
||||
.*/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var/test\.cmake:10 \(ctest_read_custom_files\)
|
||||
.*/Tests/RunCMake/MaxRecursionDepth/ctest_read_custom_files-var/test\.cmake:5 \(ctest_read_custom_files\)
|
||||
|
||||
|
||||
Problem reading custom configuration: .*/Tests/RunCMake/MaxRecursionDepth/CTestCustom\.cmake
|
||||
|
@ -11,41 +11,41 @@ CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_11\.cmake:1
|
||||
Maximum recursion depth of 10 exceeded
|
||||
|
||||
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_10\.cmake:13 \(message\):
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_10\.cmake:8 \(message\):
|
||||
Nested script failed
|
||||
|
||||
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_9\.cmake:13 \(message\):
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_9\.cmake:8 \(message\):
|
||||
Nested script failed
|
||||
|
||||
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_8\.cmake:13 \(message\):
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_8\.cmake:8 \(message\):
|
||||
Nested script failed
|
||||
|
||||
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_7\.cmake:13 \(message\):
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_7\.cmake:8 \(message\):
|
||||
Nested script failed
|
||||
|
||||
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_6\.cmake:13 \(message\):
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_6\.cmake:8 \(message\):
|
||||
Nested script failed
|
||||
|
||||
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_5\.cmake:13 \(message\):
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_5\.cmake:8 \(message\):
|
||||
Nested script failed
|
||||
|
||||
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_4\.cmake:13 \(message\):
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_4\.cmake:8 \(message\):
|
||||
Nested script failed
|
||||
|
||||
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_3\.cmake:13 \(message\):
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_3\.cmake:8 \(message\):
|
||||
Nested script failed
|
||||
|
||||
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_2\.cmake:13 \(message\):
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script_2\.cmake:8 \(message\):
|
||||
Nested script failed
|
||||
|
||||
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var/test\.cmake:19 \(message\):
|
||||
CMake Error at .*/Tests/RunCMake/MaxRecursionDepth/ctest_run_script-var/test\.cmake:14 \(message\):
|
||||
Nested script failed$
|
||||
|
@ -1,12 +1,7 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
set(CTEST_RUN_CURRENT_SCRIPT 0)
|
||||
|
||||
message("@LEVEL_CURRENT@")
|
||||
|
||||
set(CTEST_SOURCE_DIRECTORY "@CTEST_SOURCE_DIRECTORY@")
|
||||
set(CTEST_BINARY_DIRECTORY "@CTEST_BINARY_DIRECTORY@")
|
||||
set(CTEST_COMMAND "@CTEST_COMMAND@")
|
||||
|
||||
ctest_run_script("${CMAKE_CURRENT_LIST_DIR}/ctest_run_script_@LEVEL_NEXT@.cmake" RETURN_VALUE val)
|
||||
|
||||
if(NOT val EQUAL 0)
|
||||
|
@ -1,9 +1,4 @@
|
||||
cmake_minimum_required(VERSION 3.12)
|
||||
set(CTEST_RUN_CURRENT_SCRIPT 0)
|
||||
|
||||
set(CTEST_SOURCE_DIRECTORY "@RunCMake_SOURCE_DIR@")
|
||||
set(CTEST_BINARY_DIRECTORY "@RunCMake_BINARY_DIR@")
|
||||
set(CTEST_COMMAND "${CMAKE_CTEST_COMMAND}")
|
||||
|
||||
if(TEST_NAME STREQUAL "ctest_read_custom_files")
|
||||
set(x 2)
|
||||
|
Loading…
Reference in New Issue
Block a user