summaryrefslogtreecommitdiffstats
path: root/Source/CTest
diff options
context:
space:
mode:
authorBill Hoffman <bill.hoffman@kitware.com>2009-09-04 17:24:25 (GMT)
committerBill Hoffman <bill.hoffman@kitware.com>2009-09-04 17:24:25 (GMT)
commit7d190a65ca3fb717e4889de7604ac8ef3484c593 (patch)
tree6a372a8684754102c510bb5d59ae3f63d11c84f0 /Source/CTest
parent368a18b83c1a0885f477b4911d3f5224b4fd534e (diff)
downloadCMake-7d190a65ca3fb717e4889de7604ac8ef3484c593.zip
CMake-7d190a65ca3fb717e4889de7604ac8ef3484c593.tar.gz
CMake-7d190a65ca3fb717e4889de7604ac8ef3484c593.tar.bz2
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
Diffstat (limited to 'Source/CTest')
-rw-r--r--Source/CTest/cmCTestRunScriptCommand.cxx29
-rw-r--r--Source/CTest/cmCTestRunScriptCommand.h7
-rw-r--r--Source/CTest/cmCTestScriptHandler.cxx12
-rw-r--r--Source/CTest/cmCTestScriptHandler.h3
4 files changed, 43 insertions, 8 deletions
diff --git a/Source/CTest/cmCTestRunScriptCommand.cxx b/Source/CTest/cmCTestRunScriptCommand.cxx
index e01994d..53ca8ef 100644
--- a/Source/CTest/cmCTestRunScriptCommand.cxx
+++ b/Source/CTest/cmCTestRunScriptCommand.cxx
@@ -34,10 +34,35 @@ bool cmCTestRunScriptCommand
np = true;
i++;
}
+ int start = i;
// 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;
}
diff --git a/Source/CTest/cmCTestRunScriptCommand.h b/Source/CTest/cmCTestRunScriptCommand.h
index f0bdb7b..73fa595 100644
--- a/Source/CTest/cmCTestRunScriptCommand.h
+++ b/Source/CTest/cmCTestRunScriptCommand.h
@@ -69,15 +69,16 @@ public:
{
return
" 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. "
"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 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);
-
};
diff --git a/Source/CTest/cmCTestScriptHandler.cxx b/Source/CTest/cmCTestScriptHandler.cxx
index 0890fd1..0c292e5 100644
--- a/Source/CTest/cmCTestScriptHandler.cxx
+++ b/Source/CTest/cmCTestScriptHandler.cxx
@@ -445,6 +445,10 @@ int cmCTestScriptHandler::ReadInScript(const std::string& total_script_arg)
cmCTestLog(this->CTest, ERROR_MESSAGE, "Error in read script: "
<< script.c_str()
<< 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;
}
@@ -1030,12 +1034,16 @@ void cmCTestScriptHandler::RestoreBackupDirectories()
}
bool cmCTestScriptHandler::RunScript(cmCTest* ctest, const char *sname,
- bool InProcess)
+ bool InProcess, int* returnValue)
{
cmCTestScriptHandler* sh = new cmCTestScriptHandler();
sh->SetCTestInstance(ctest);
sh->AddConfigurationScript(sname,InProcess);
- sh->ProcessHandler();
+ int res = sh->ProcessHandler();
+ if(returnValue)
+ {
+ *returnValue = res;
+ }
delete sh;
return true;
}
diff --git a/Source/CTest/cmCTestScriptHandler.h b/Source/CTest/cmCTestScriptHandler.h
index 709b928..ececa06 100644
--- a/Source/CTest/cmCTestScriptHandler.h
+++ b/Source/CTest/cmCTestScriptHandler.h
@@ -82,7 +82,8 @@ public:
/*
* 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();
/*