cmCTestRunScriptCommand.cxx 1.5 KB

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