cmCTestRunScriptCommand.cxx 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  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. class cmExecutionStatus;
  7. bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
  8. cmExecutionStatus& /*unused*/)
  9. {
  10. if (args.empty()) {
  11. this->CTestScriptHandler->RunCurrentScript();
  12. return true;
  13. }
  14. bool np = false;
  15. unsigned int i = 0;
  16. if (args[i] == "NEW_PROCESS") {
  17. np = true;
  18. i++;
  19. }
  20. int start = i;
  21. // run each script
  22. std::string returnVariable;
  23. for (i = start; i < args.size(); ++i) {
  24. if (args[i] == "RETURN_VALUE") {
  25. ++i;
  26. if (i < args.size()) {
  27. returnVariable = args[i];
  28. }
  29. }
  30. }
  31. for (i = start; i < args.size(); ++i) {
  32. if (args[i] == "RETURN_VALUE") {
  33. ++i;
  34. } else {
  35. int ret;
  36. cmCTestScriptHandler::RunScript(this->CTest, this->Makefile,
  37. args[i].c_str(), !np, &ret);
  38. this->Makefile->AddDefinition(returnVariable, std::to_string(ret));
  39. }
  40. }
  41. return true;
  42. }