cmCTestRunScriptCommand.cxx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc., Insight Software Consortium
  4. Distributed under the OSI-approved BSD License (the "License");
  5. see accompanying file Copyright.txt for details.
  6. This software is distributed WITHOUT ANY WARRANTY; without even the
  7. implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  8. See the License for more information.
  9. ============================================================================*/
  10. #include "cmCTestRunScriptCommand.h"
  11. #include "cmCTestScriptHandler.h"
  12. #include "cmMakefile.h"
  13. #include <sstream>
  14. class cmExecutionStatus;
  15. bool cmCTestRunScriptCommand::InitialPass(std::vector<std::string> const& args,
  16. cmExecutionStatus& /*unused*/)
  17. {
  18. if (args.empty()) {
  19. this->CTestScriptHandler->RunCurrentScript();
  20. return true;
  21. }
  22. bool np = false;
  23. unsigned int i = 0;
  24. if (args[i] == "NEW_PROCESS") {
  25. np = true;
  26. i++;
  27. }
  28. int start = i;
  29. // run each script
  30. std::string returnVariable;
  31. for (i = start; i < args.size(); ++i) {
  32. if (args[i] == "RETURN_VALUE") {
  33. ++i;
  34. if (i < args.size()) {
  35. returnVariable = args[i];
  36. }
  37. }
  38. }
  39. for (i = start; i < args.size(); ++i) {
  40. if (args[i] == "RETURN_VALUE") {
  41. ++i;
  42. } else {
  43. int ret;
  44. cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np, &ret);
  45. std::ostringstream str;
  46. str << ret;
  47. this->Makefile->AddDefinition(returnVariable, str.str().c_str());
  48. }
  49. }
  50. return true;
  51. }