cmake/Source/CTest/cmCTestRunScriptCommand.cxx

47 lines
1.2 KiB
C++
Raw Normal View History

2016-10-30 18:24:19 +01:00
/* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
file Copyright.txt or https://cmake.org/licensing for details. */
#include "cmCTestRunScriptCommand.h"
#include "cmCTestScriptHandler.h"
2016-10-30 18:24:19 +01:00
#include "cmMakefile.h"
class cmExecutionStatus;
2016-07-09 11:21:54 +02:00
bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
2016-10-30 18:24:19 +01:00
cmExecutionStatus& /*unused*/)
{
2016-10-30 18:24:19 +01:00
if (args.empty()) {
this->CTestScriptHandler->RunCurrentScript();
return true;
2016-07-09 11:21:54 +02:00
}
bool np = false;
unsigned int i = 0;
2016-07-09 11:21:54 +02:00
if (args[i] == "NEW_PROCESS") {
np = true;
i++;
2016-07-09 11:21:54 +02:00
}
2009-10-04 10:30:41 +03:00
int start = i;
// run each script
2009-10-04 10:30:41 +03:00
std::string returnVariable;
2016-07-09 11:21:54 +02:00
for (i = start; i < args.size(); ++i) {
if (args[i] == "RETURN_VALUE") {
2009-10-04 10:30:41 +03:00
++i;
2016-07-09 11:21:54 +02:00
if (i < args.size()) {
2009-10-04 10:30:41 +03:00
returnVariable = args[i];
}
}
2016-07-09 11:21:54 +02:00
}
for (i = start; i < args.size(); ++i) {
if (args[i] == "RETURN_VALUE") {
2009-10-04 10:30:41 +03:00
++i;
2016-07-09 11:21:54 +02:00
} else {
2009-10-04 10:30:41 +03:00
int ret;
2021-09-14 00:13:48 +02:00
cmCTestScriptHandler::RunScript(this->CTest, this->Makefile, args[i],
!np, &ret);
2020-02-01 23:06:01 +01:00
this->Makefile->AddDefinition(returnVariable, std::to_string(ret));
}
2016-07-09 11:21:54 +02:00
}
return true;
}