cmCTestStartCommand.cxx 2.9 KB

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