cmCTestTestCommand.cxx 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  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_TEST_LOAD] = "TEST_LOAD";
  26. this->Arguments[ctt_LAST] = 0;
  27. this->Last = ctt_LAST;
  28. }
  29. cmCTestGenericHandler* cmCTestTestCommand::InitializeHandler()
  30. {
  31. const char* ctestTimeout =
  32. this->Makefile->GetDefinition("CTEST_TEST_TIMEOUT");
  33. double timeout = this->CTest->GetTimeOut();
  34. if ( ctestTimeout )
  35. {
  36. timeout = atof(ctestTimeout);
  37. }
  38. else
  39. {
  40. if ( timeout <= 0 )
  41. {
  42. // By default use timeout of 10 minutes
  43. timeout = 600;
  44. }
  45. }
  46. this->CTest->SetTimeOut(timeout);
  47. cmCTestGenericHandler* handler = this->InitializeActualHandler();
  48. if ( this->Values[ctt_START] || this->Values[ctt_END] ||
  49. this->Values[ctt_STRIDE] )
  50. {
  51. std::ostringstream testsToRunString;
  52. if ( this->Values[ctt_START] )
  53. {
  54. testsToRunString << this->Values[ctt_START];
  55. }
  56. testsToRunString << ",";
  57. if ( this->Values[ctt_END] )
  58. {
  59. testsToRunString << this->Values[ctt_END];
  60. }
  61. testsToRunString << ",";
  62. if ( this->Values[ctt_STRIDE] )
  63. {
  64. testsToRunString << this->Values[ctt_STRIDE];
  65. }
  66. handler->SetOption("TestsToRunInformation",
  67. testsToRunString.str().c_str());
  68. }
  69. if(this->Values[ctt_EXCLUDE])
  70. {
  71. handler->SetOption("ExcludeRegularExpression", this->Values[ctt_EXCLUDE]);
  72. }
  73. if(this->Values[ctt_INCLUDE])
  74. {
  75. handler->SetOption("IncludeRegularExpression", this->Values[ctt_INCLUDE]);
  76. }
  77. if(this->Values[ctt_EXCLUDE_LABEL])
  78. {
  79. handler->SetOption("ExcludeLabelRegularExpression",
  80. this->Values[ctt_EXCLUDE_LABEL]);
  81. }
  82. if(this->Values[ctt_INCLUDE_LABEL])
  83. {
  84. handler->SetOption("LabelRegularExpression",
  85. this->Values[ctt_INCLUDE_LABEL]);
  86. }
  87. if(this->Values[ctt_PARALLEL_LEVEL])
  88. {
  89. handler->SetOption("ParallelLevel",
  90. this->Values[ctt_PARALLEL_LEVEL]);
  91. }
  92. if(this->Values[ctt_SCHEDULE_RANDOM])
  93. {
  94. handler->SetOption("ScheduleRandom",
  95. this->Values[ctt_SCHEDULE_RANDOM]);
  96. }
  97. if(this->Values[ctt_STOP_TIME])
  98. {
  99. this->CTest->SetStopTime(this->Values[ctt_STOP_TIME]);
  100. }
  101. // Test load is determined by: TEST_LOAD argument,
  102. // or CTEST_TEST_LOAD script variable, or ctest --test-load
  103. // command line argument... in that order.
  104. unsigned long testLoad;
  105. const char* ctestTestLoad
  106. = this->Makefile->GetDefinition("CTEST_TEST_LOAD");
  107. if(this->Values[ctt_TEST_LOAD] && *this->Values[ctt_TEST_LOAD])
  108. {
  109. if (!cmSystemTools::StringToULong(this->Values[ctt_TEST_LOAD], &testLoad))
  110. {
  111. testLoad = 0;
  112. cmCTestLog(this->CTest, WARNING, "Invalid value for 'TEST_LOAD' : "
  113. << this->Values[ctt_TEST_LOAD] << std::endl);
  114. }
  115. }
  116. else if(ctestTestLoad && *ctestTestLoad)
  117. {
  118. if (!cmSystemTools::StringToULong(ctestTestLoad, &testLoad))
  119. {
  120. testLoad = 0;
  121. cmCTestLog(this->CTest, WARNING,
  122. "Invalid value for 'CTEST_TEST_LOAD' : " <<
  123. ctestTestLoad << std::endl);
  124. }
  125. }
  126. else
  127. {
  128. testLoad = this->CTest->GetTestLoad();
  129. }
  130. handler->SetTestLoad(testLoad);
  131. handler->SetQuiet(this->Quiet);
  132. return handler;
  133. }
  134. cmCTestGenericHandler* cmCTestTestCommand::InitializeActualHandler()
  135. {
  136. return this->CTest->GetInitializedHandler("test");
  137. }