Change run_ctest_script in ctest to not stop processing when there is an error in the script being run. Also, add a RETURN_VALUE option so that you can find out if the script failed
This commit is contained in:
parent
368a18b83c
commit
7d190a65ca
|
@ -34,10 +34,35 @@ bool cmCTestRunScriptCommand
|
||||||
np = true;
|
np = true;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
int start = i;
|
||||||
// run each script
|
// run each script
|
||||||
for (; i < args.size(); ++i)
|
std::string returnVariable;
|
||||||
|
for (i = start; i < args.size(); ++i)
|
||||||
{
|
{
|
||||||
cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np);
|
if(args[i] == "RETURN_VALUE")
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
if(i < args.size())
|
||||||
|
{
|
||||||
|
returnVariable = args[i];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
for (i = start; i < args.size(); ++i)
|
||||||
|
{
|
||||||
|
if(args[i] == "RETURN_VALUE")
|
||||||
|
{
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int ret;
|
||||||
|
cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np,
|
||||||
|
&ret);
|
||||||
|
cmOStringStream str;
|
||||||
|
str << ret;
|
||||||
|
this->Makefile->AddDefinition(returnVariable.c_str(), str.str().c_str());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -69,15 +69,16 @@ public:
|
||||||
{
|
{
|
||||||
return
|
return
|
||||||
" ctest_run_script([NEW_PROCESS] script_file_name script_file_name1 \n"
|
" ctest_run_script([NEW_PROCESS] script_file_name script_file_name1 \n"
|
||||||
" script_file_name2 ...)\n"
|
" script_file_name2 ... [RETURN_VALUE var])\n"
|
||||||
"Runs a script or scripts much like if it was run from ctest -S. "
|
"Runs a script or scripts much like if it was run from ctest -S. "
|
||||||
"If no argument is provided then the current script is run using "
|
"If no argument is provided then the current script is run using "
|
||||||
"the current settings of the variables. If NEW_PROCESS is specified "
|
"the current settings of the variables. If NEW_PROCESS is specified "
|
||||||
"then each script will be run in a seperate process.";
|
"then each script will be run in a seperate process."
|
||||||
|
"If RETURN_VALUE is specified the return value of the last script "
|
||||||
|
"run will be put into var.";
|
||||||
}
|
}
|
||||||
|
|
||||||
cmTypeMacro(cmCTestRunScriptCommand, cmCTestCommand);
|
cmTypeMacro(cmCTestRunScriptCommand, cmCTestCommand);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -445,6 +445,10 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
|
||||||
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read script: "
|
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read script: "
|
||||||
<< script.c_str()
|
<< script.c_str()
|
||||||
<< std::endl);
|
<< std::endl);
|
||||||
|
// Reset the error flag so that it can run more than
|
||||||
|
// one script with an error when you
|
||||||
|
// use ctest_run_script
|
||||||
|
cmSystemTools::ResetErrorOccuredFlag();
|
||||||
return 2;
|
return 2;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1030,12 +1034,16 @@ void cmCTestScriptHandler::RestoreBackupDirectories()
|
||||||
}
|
}
|
||||||
|
|
||||||
bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char *sname,
|
bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char *sname,
|
||||||
bool InProcess)
|
bool InProcess, int* returnValue)
|
||||||
{
|
{
|
||||||
cmCTestScriptHandler* sh = new cmCTestScriptHandler();
|
cmCTestScriptHandler* sh = new cmCTestScriptHandler();
|
||||||
sh->SetCTestInstance(ctest);
|
sh->SetCTestInstance(ctest);
|
||||||
sh->AddConfigurationScript(sname,InProcess);
|
sh->AddConfigurationScript(sname,InProcess);
|
||||||
sh->ProcessHandler();
|
int res = sh->ProcessHandler();
|
||||||
|
if(returnValue)
|
||||||
|
{
|
||||||
|
*returnValue = res;
|
||||||
|
}
|
||||||
delete sh;
|
delete sh;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -82,7 +82,8 @@ public:
|
||||||
/*
|
/*
|
||||||
* Run a script
|
* Run a script
|
||||||
*/
|
*/
|
||||||
static bool RunScript(cmCTest* ctest, const char *script, bool InProcess);
|
static bool RunScript(cmCTest* ctest, const char *script, bool InProcess,
|
||||||
|
int* returnValue);
|
||||||
int RunCurrentScript();
|
int RunCurrentScript();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Reference in New Issue