cmCTestStartCommand.cxx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. cmCTestLog(m_CTest, OUTPUT, "Run dashboard with model " << smodel
  60. << " for src dir: " << src_dir << " and binary dir: " << bld_dir << std::endl);
  61. std::string fname = src_dir;
  62. fname += "/CTestConfig.cmake";
  63. cmSystemTools::ConvertToUnixSlashes(fname);
  64. if ( cmSystemTools::FileExists(fname.c_str()) )
  65. {
  66. cmCTestLog(m_CTest, OUTPUT, " Reading ctest configuration file: " << fname.c_str() << std::endl);
  67. bool readit = m_Makefile->ReadListFile(m_Makefile->GetCurrentListFile(),
  68. fname.c_str() );
  69. if(!readit)
  70. {
  71. std::string m = "Could not find include file: ";
  72. m += fname;
  73. this->SetError(m.c_str());
  74. return false;
  75. }
  76. }
  77. m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "NightlyStartTime", "CTEST_NIGHTLY_START_TIME");
  78. m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "Site", "CTEST_SITE");
  79. m_CTest->SetCTestConfigurationFromCMakeVariable(m_Makefile, "BuildName", "CTEST_BUILD_NAME");
  80. m_CTest->SetCTestConfiguration("SourceDirectory", src_dir);
  81. m_CTest->SetCTestConfiguration("BuildDirectory", bld_dir);
  82. m_Makefile->AddDefinition("CTEST_RUN_CURRENT_SCRIPT", "OFF");
  83. m_CTest->SetSuppressUpdatingCTestConfiguration(true);
  84. int model = m_CTest->GetTestModelFromString(smodel);
  85. m_CTest->SetTestModel(model);
  86. m_CTest->SetProduceXML(true);
  87. if ( !m_CTest->Initialize(bld_dir, true) )
  88. {
  89. return false;
  90. }
  91. return true;
  92. }