cmCTestRunScriptCommand.cxx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /* Distributed under the OSI-approved BSD 3-Clause License. See accompanying
  2. file Copyright.txt or https://cmake.org/licensing for details. */
  3. #include "cmCTestRunScriptCommand.h"
  4. #include "cmCTestScriptHandler.h"
  5. #include "cmMakefile.h"
  6. #include <sstream>
  7. class cmExecutionStatus;
  8. bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
  9. cmExecutionStatus& /*unused*/)
  10. {
  11. if (args.empty()) {
  12. this->CTestScriptHandler->RunCurrentScript();
  13. return true;
  14. }
  15. bool np = false;
  16. unsigned int i = 0;
  17. if (args[i] == "NEW_PROCESS") {
  18. np = true;
  19. i++;
  20. }
  21. int start = i;
  22. // run each script
  23. std::string returnVariable;
  24. for (i = start; i < args.size(); ++i) {
  25. if (args[i] == "RETURN_VALUE") {
  26. ++i;
  27. if (i < args.size()) {
  28. returnVariable = args[i];
  29. }
  30. }
  31. }
  32. for (i = start; i < args.size(); ++i) {
  33. if (args[i] == "RETURN_VALUE") {
  34. ++i;
  35. } else {
  36. int ret;
  37. cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np, &ret);
  38. std::ostringstream str;
  39. str << ret;
  40. this->Makefile->AddDefinition(returnVariable, str.str().c_str());
  41. }
  42. }
  43. return true;
  44. }