cmCTestTestCommand.cxx 3.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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_LAST] = 0;
  25. this->Last = ctt_LAST;
  26. }
  27. cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
  28. {
  29. const char* ctestTimeout =
  30. this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT");
  31. double timeout = this->CTest->GetTimeOut();
  32. if ( ctestTimeout )
  33. {
  34. timeout = atof(ctestTimeout);
  35. }
  36. else
  37. {
  38. if ( timeout <= 0 )
  39. {
  40. // By default use timeout of 10 minutes
  41. timeout = 600;
  42. }
  43. }
  44. this->CTest->SetTimeOut(timeout);
  45. cmCTestGenericHandler* handler = this->InitializeActualHandler();
  46. if ( this->Values[ctt_START] || this->Values[ctt_END] ||
  47. this->Values[ctt_STRIDE] )
  48. {
  49. cmOStringStream testsToRunString;
  50. if ( this->Values[ctt_START] )
  51. {
  52. testsToRunString << this->Values[ctt_START];
  53. }
  54. testsToRunString << ",";
  55. if ( this->Values[ctt_END] )
  56. {
  57. testsToRunString << this->Values[ctt_END];
  58. }
  59. testsToRunString << ",";
  60. if ( this->Values[ctt_STRIDE] )
  61. {
  62. testsToRunString << this->Values[ctt_STRIDE];
  63. }
  64. handler->SetOption("TestsToRunInformation",
  65. testsToRunString.str().c_str());
  66. }
  67. if(this->Values[ctt_EXCLUDE])
  68. {
  69. handler->SetOption("ExcludeRegularExpression", this->Values[ctt_EXCLUDE]);
  70. }
  71. if(this->Values[ctt_INCLUDE])
  72. {
  73. handler->SetOption("IncludeRegularExpression", this->Values[ctt_INCLUDE]);
  74. }
  75. if(this->Values[ctt_EXCLUDE_LABEL])
  76. {
  77. handler->SetOption("ExcludeLabelRegularExpression",
  78. this->Values[ctt_EXCLUDE_LABEL]);
  79. }
  80. if(this->Values[ctt_INCLUDE_LABEL])
  81. {
  82. handler->SetOption("LabelRegularExpression",
  83. this->Values[ctt_INCLUDE_LABEL]);
  84. }
  85. if(this->Values[ctt_PARALLEL_LEVEL])
  86. {
  87. handler->SetOption("ParallelLevel",
  88. this->Values[ctt_PARALLEL_LEVEL]);
  89. }
  90. if(this->Values[ctt_SCHEDULE_RANDOM])
  91. {
  92. handler->SetOption("ScheduleRandom",
  93. this->Values[ctt_SCHEDULE_RANDOM]);
  94. }
  95. return handler;
  96. }
  97. cmCTestGenericHandler* cmCTestTestCommand::InitializeActualHandler()
  98. {
  99. return this->CTest->GetInitializedHandler("test");
  100. }