cmCTestTestCommand.cxx 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 "cmCTestTestCommand.h"
  14. #include "cmCTest.h"
  15. #include "cmCTestGenericHandler.h"
  16. bool cmCTestTestCommand::InitialPass(
  17. std::vector<std::string> const& args)
  18. {
  19. if (args.size() != 2)
  20. {
  21. this->SetError("called with incorrect number of arguments");
  22. return false;
  23. }
  24. const char* build_dir = args[0].c_str();
  25. const char* res_var = args[1].c_str();
  26. m_CTest->SetCTestConfiguration("BuildDirectory", build_dir);
  27. cmCTestGenericHandler* handler = m_CTest->GetHandler("test");
  28. if ( !handler )
  29. {
  30. this->SetError("internal CTest error. Cannot instantiate test handler");
  31. return false;
  32. }
  33. std::string current_dir = cmSystemTools::GetCurrentWorkingDirectory();
  34. cmSystemTools::ChangeDirectory(build_dir);
  35. int res = handler->ProcessHandler();
  36. cmSystemTools::ChangeDirectory(current_dir.c_str());
  37. cmOStringStream str;
  38. str << res;
  39. m_Makefile->AddDefinition(res_var, str.str().c_str());
  40. return true;
  41. }