cmCTestRunScriptCommand.cxx 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. bool cmCTestRunScriptCommand
  13. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  14. {
  15. if(args.size() < 1 )
  16. {
  17. this->CTestScriptHandler->RunCurrentScript();
  18. return true;
  19. }
  20. bool np = false;
  21. unsigned int i = 0;
  22. if (args[i] == "NEW_PROCESS")
  23. {
  24. np = true;
  25. i++;
  26. }
  27. int start = i;
  28. // run each script
  29. std::string returnVariable;
  30. for (i = start; i < args.size(); ++i)
  31. {
  32. if(args[i] == "RETURN_VALUE")
  33. {
  34. ++i;
  35. if(i < args.size())
  36. {
  37. returnVariable = args[i];
  38. }
  39. }
  40. }
  41. for (i = start; i < args.size(); ++i)
  42. {
  43. if(args[i] == "RETURN_VALUE")
  44. {
  45. ++i;
  46. }
  47. else
  48. {
  49. int ret;
  50. cmCTestScriptHandler::RunScript(this->CTest, args[i].c_str(), !np,
  51. &ret);
  52. std::ostringstream str;
  53. str << ret;
  54. this->Makefile->AddDefinition(returnVariable, str.str().c_str());
  55. }
  56. }
  57. return true;
  58. }