cmCTestRunScriptCommand.cxx 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. /*=========================================================================
  2. Program: CMake - Cross-Platform Makefile Generator
  3. Module: $RCSfile$
  4. Language: C++
  5. Date: $Date$
  6. Version: $Revision$
  7. Copyright (c) 2002 Kitware, Inc., Insight Consortium. All rights reserved.
  8. See Copyright.txt or http://www.cmake.org/HTML/Copyright.html for details.
  9. This software is distributed WITHOUT ANY WARRANTY; without even
  10. the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  11. PURPOSE. See the above copyright notices for more information.
  12. =========================================================================*/
  13. #include "cmCTestRunScriptCommand.h"
  14. #include "cmCTestScriptHandler.h"
  15. bool cmCTestRunScriptCommand
  16. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  17. {
  18. if(args.size() < 1 )
  19. {
  20. this->CTestScriptHandler->RunCurrentScript();
  21. return true;
  22. }
  23. bool np = false;
  24. unsigned int i = 0;
  25. if (args[i] == "NEW_PROCESS")
  26. {
  27. np = true;
  28. i++;
  29. }
  30. int start = i;
  31. // run each script
  32. std::string returnVariable;
  33. for (i = start; i < args.size(); ++i)
  34. {
  35. if(args[i] == "RETURN_VALUE")
  36. {
  37. ++i;
  38. if(i < args.size())
  39. {
  40. returnVariable = args[i];
  41. }
  42. }
  43. }
  44. for (i = start; i < args.size(); ++i)
  45. {
  46. if(args[i] == "RETURN_VALUE")
  47. {
  48. ++i;
  49. }
  50. else
  51. {
  52. int ret;
  53. cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np,
  54. &ret);
  55. cmOStringStream str;
  56. str << ret;
  57. this->Makefile->AddDefinition(returnVariable.c_str(), str.str().c_str());
  58. }
  59. }
  60. return true;
  61. }