cmCTestRunScriptCommand.cxx 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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 "cmExecutionStatus.h"
  6. #include "cmMakefile.h"
  7. bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
  8. cmExecutionStatus& status)
  9. {
  10. if (args.empty()) {
  11. status.SetError("called with incorrect number of arguments");
  12. return false;
  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, args[i],
  37. !np, &ret);
  38. this->Makefile->AddDefinition(returnVariable, std::to_string(ret));
  39. }
  40. }
  41. return true;
  42. }