cmCTestStartCommand.cxx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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
  18. ::InitialPass(std::vector<std::string> const& args, cmExecutionStatus &)
  19. {
  20. if (args.size() < 1)
  21. {
  22. this->SetError("called with incorrect number of arguments");
  23. return false;
  24. }
  25. size_t cnt = 0;
  26. const char* smodel = args[cnt].c_str();
  27. const char* src_dir = 0;
  28. const char* bld_dir = 0;
  29. cnt++;
  30. this->CTest->SetSpecificTrack(0);
  31. if ( cnt < args.size() -1 )
  32. {
  33. if ( args[cnt] == "TRACK" )
  34. {
  35. cnt ++;
  36. this->CTest->SetSpecificTrack(args[cnt].c_str());
  37. cnt ++;
  38. }
  39. }
  40. if ( cnt < args.size() )
  41. {
  42. src_dir = args[cnt].c_str();
  43. cnt ++;
  44. if ( cnt < args.size() )
  45. {
  46. bld_dir = args[cnt].c_str();
  47. }
  48. }
  49. if ( !src_dir )
  50. {
  51. src_dir = this->Makefile->GetDefinition("CTEST_SOURCE_DIRECTORY");
  52. }
  53. if ( !bld_dir)
  54. {
  55. bld_dir = this->Makefile->GetDefinition("CTEST_BINARY_DIRECTORY");
  56. }
  57. if ( !src_dir )
  58. {
  59. this->SetError("source directory not specified. Specify source directory "
  60. "as an argument or set CTEST_SOURCE_DIRECTORY");
  61. return false;
  62. }
  63. if ( !bld_dir)
  64. {
  65. this->SetError("binary directory not specified. Specify binary directory "
  66. "as an argument or set CTEST_BINARY_DIRECTORY");
  67. return false;
  68. }
  69. cmSystemTools::AddKeepPath(src_dir);
  70. cmSystemTools::AddKeepPath(bld_dir);
  71. this->CTest->EmptyCTestConfiguration();
  72. this->CTest->SetCTestConfiguration("SourceDirectory",
  73. cmSystemTools::CollapseFullPath(src_dir).c_str());
  74. this->CTest->SetCTestConfiguration("BuildDirectory",
  75. cmSystemTools::CollapseFullPath(bld_dir).c_str());
  76. cmCTestLog(this->CTest, HANDLER_OUTPUT, "Run dashboard with model "
  77. << smodel << std::endl
  78. << " Source directory: " << src_dir << std::endl
  79. << " Build directory: " << bld_dir << std::endl);
  80. const char* track = this->CTest->GetSpecificTrack();
  81. if ( track )
  82. {
  83. cmCTestLog(this->CTest, HANDLER_OUTPUT,
  84. " Track: " << track << std::endl);
  85. }
  86. this->Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF");
  87. this->CTest->SetSuppressUpdatingCTestConfiguration(true);
  88. int model = this->CTest->GetTestModelFromString(smodel);
  89. this->CTest->SetTestModel(model);
  90. this->CTest->SetProduceXML(true);
  91. return this->CTest->InitializeFromCommand(this, true);
  92. }