cmCTestStartCommand.cxx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  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 "cmCTestStartCommand.h"
  14. #include "cmCTest.h"
  15. #include "cmLocalGenerator.h"
  16. #include "cmGlobalGenerator.h"
  17. bool cmCTestStartCommand::InitialPass(
  18. std::vector<std::string> const& args)
  19. {
  20. if (args.size() < 1)
  21. {
  22. this->SetError("called with incorrect number of arguments");
  23. return false;
  24. }
  25. const char* smodel = args[0].c_str();
  26. const char* src_dir = 0;
  27. const char* bld_dir = 0;
  28. if ( args.size() >= 2 )
  29. {
  30. src_dir = args[1].c_str();
  31. if ( args.size() == 3 )
  32. {
  33. bld_dir = args[2].c_str();
  34. }
  35. }
  36. if ( args.size() > 3 )
  37. {
  38. this->SetError("called with incorrect number of arguments");
  39. return false;
  40. }
  41. if ( !src_dir )
  42. {
  43. src_dir = m_Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY");
  44. }
  45. if ( !bld_dir)
  46. {
  47. bld_dir = m_Makefile->GetDefinition("CTEST_BINARY_DIRECTORY");
  48. }
  49. if ( !src_dir )
  50. {
  51. this->SetError("source directory not specified. Specify source directory as an argument or set CTEST_SOURCE_DIRECTORY");
  52. return false;
  53. }
  54. if ( !bld_dir)
  55. {
  56. this->SetError("binary directory not specified. Specify binary directory as an argument or set CTEST_BINARY_DIRECTORY");
  57. return false;
  58. }
  59. m_CTest->EmptyCTestConfiguration();
  60. m_CTest->SetCTestConfiguration("SourceDirectory", src_dir);
  61. m_CTest->SetCTestConfiguration("BuildDirectory", bld_dir);
  62. cmCTestLog(m_CTest, OUTPUT, "Run dashboard with model " << smodel << std::endl
  63. << " Source directory: " << src_dir << std::endl << " Build directory: " << bld_dir << std::endl);
  64. m_Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF");
  65. m_CTest->SetSuppressUpdatingCTestConfiguration(true);
  66. int model = m_CTest->GetTestModelFromString(smodel);
  67. m_CTest->SetTestModel(model);
  68. m_CTest->SetProduceXML(true);
  69. return m_CTest->InitializeFromCommand(this, true);
  70. }