cmCTestTestCommand.cxx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 "cmCTestTestCommand.h"
  11. #include "cmCTest.h"
  12. #include "cmCTestGenericHandler.h"
  13. cmCTestTestCommand::cmCTestTestCommand()
  14. {
  15. this->Arguments[ctt_START] = "START";
  16. this->Arguments[ctt_END] = "END";
  17. this->Arguments[ctt_STRIDE] = "STRIDE";
  18. this->Arguments[ctt_EXCLUDE] = "EXCLUDE";
  19. this->Arguments[ctt_INCLUDE] = "INCLUDE";
  20. this->Arguments[ctt_EXCLUDE_LABEL] = "EXCLUDE_LABEL";
  21. this->Arguments[ctt_INCLUDE_LABEL] = "INCLUDE_LABEL";
  22. this->Arguments[ctt_PARALLEL_LEVEL] = "PARALLEL_LEVEL";
  23. this->Arguments[ctt_SCHEDULE_RANDOM] = "SCHEDULE_RANDOM";
  24. this->Arguments[ctt_STOP_TIME] = "STOP_TIME";
  25. this->Arguments[ctt_LAST] = 0;
  26. this->Last = ctt_LAST;
  27. }
  28. cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
  29. {
  30. const char* ctestTimeout =
  31. this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT");
  32. double timeout = this->CTest->GetTimeOut();
  33. if ( ctestTimeout )
  34. {
  35. timeout = atof(ctestTimeout);
  36. }
  37. else
  38. {
  39. if ( timeout <= 0 )
  40. {
  41. // By default use timeout of 10 minutes
  42. timeout = 600;
  43. }
  44. }
  45. this->CTest->SetTimeOut(timeout);
  46. cmCTestGenericHandler* handler = this->InitializeActualHandler();
  47. if ( this->Values[ctt_START] || this->Values[ctt_END] ||
  48. this->Values[ctt_STRIDE] )
  49. {
  50. std::ostringstream testsToRunString;
  51. if ( this->Values[ctt_START] )
  52. {
  53. testsToRunString << this->Values[ctt_START];
  54. }
  55. testsToRunString << ",";
  56. if ( this->Values[ctt_END] )
  57. {
  58. testsToRunString << this->Values[ctt_END];
  59. }
  60. testsToRunString << ",";
  61. if ( this->Values[ctt_STRIDE] )
  62. {
  63. testsToRunString << this->Values[ctt_STRIDE];
  64. }
  65. handler->SetOption("TestsToRunInformation",
  66. testsToRunString.str().c_str());
  67. }
  68. if(this->Values[ctt_EXCLUDE])
  69. {
  70. handler->SetOption("ExcludeRegularExpression", this->Values[ctt_EXCLUDE]);
  71. }
  72. if(this->Values[ctt_INCLUDE])
  73. {
  74. handler->SetOption("IncludeRegularExpression", this->Values[ctt_INCLUDE]);
  75. }
  76. if(this->Values[ctt_EXCLUDE_LABEL])
  77. {
  78. handler->SetOption("ExcludeLabelRegularExpression",
  79. this->Values[ctt_EXCLUDE_LABEL]);
  80. }
  81. if(this->Values[ctt_INCLUDE_LABEL])
  82. {
  83. handler->SetOption("LabelRegularExpression",
  84. this->Values[ctt_INCLUDE_LABEL]);
  85. }
  86. if(this->Values[ctt_PARALLEL_LEVEL])
  87. {
  88. handler->SetOption("ParallelLevel",
  89. this->Values[ctt_PARALLEL_LEVEL]);
  90. }
  91. if(this->Values[ctt_SCHEDULE_RANDOM])
  92. {
  93. handler->SetOption("ScheduleRandom",
  94. this->Values[ctt_SCHEDULE_RANDOM]);
  95. }
  96. if(this->Values[ctt_STOP_TIME])
  97. {
  98. this->CTest->SetStopTime(this->Values[ctt_STOP_TIME]);
  99. }
  100. handler->SetQuiet(this->Quiet);
  101. return handler;
  102. }
  103. cmCTestGenericHandler* cmCTestTestCommand::InitializeActualHandler()
  104. {
  105. return this->CTest->GetInitializedHandler("test");
  106. }