cmCTestSubmitCommand.cxx 7.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  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 "cmCTestSubmitCommand.h"
  11. #include "cmCTest.h"
  12. #include "cmCTestGenericHandler.h"
  13. #include "cmCTestSubmitHandler.h"
  14. cmCTestGenericHandler* cmCTestSubmitCommand::InitializeHandler()
  15. {
  16. const char* ctestDropMethod
  17. = this->Makefile->GetDefinition("CTEST_DROP_METHOD");
  18. const char* ctestDropSite
  19. = this->Makefile->GetDefinition("CTEST_DROP_SITE");
  20. const char* ctestDropLocation
  21. = this->Makefile->GetDefinition("CTEST_DROP_LOCATION");
  22. const char* ctestTriggerSite
  23. = this->Makefile->GetDefinition("CTEST_TRIGGER_SITE");
  24. bool ctestDropSiteCDash
  25. = this->Makefile->IsOn("CTEST_DROP_SITE_CDASH");
  26. if ( !ctestDropMethod )
  27. {
  28. ctestDropMethod = "http";
  29. }
  30. if ( !ctestDropSite )
  31. {
  32. // error: CDash requires CTEST_DROP_SITE definition
  33. // in CTestConfig.cmake
  34. }
  35. if ( !ctestDropLocation )
  36. {
  37. // error: CDash requires CTEST_DROP_LOCATION definition
  38. // in CTestConfig.cmake
  39. }
  40. this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod);
  41. this->CTest->SetCTestConfiguration("DropSite", ctestDropSite);
  42. this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation);
  43. this->CTest->SetCTestConfiguration("IsCDash",
  44. ctestDropSiteCDash ? "TRUE" : "FALSE");
  45. // Only propagate TriggerSite for non-CDash projects:
  46. //
  47. if ( !ctestDropSiteCDash )
  48. {
  49. this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite);
  50. }
  51. this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
  52. "CurlOptions", "CTEST_CURL_OPTIONS");
  53. this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
  54. "DropSiteUser", "CTEST_DROP_SITE_USER");
  55. this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
  56. "DropSitePassword", "CTEST_DROP_SITE_PASSWORD");
  57. this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
  58. "ScpCommand", "CTEST_SCP_COMMAND");
  59. const char* notesFilesVariable
  60. = this->Makefile->GetDefinition("CTEST_NOTES_FILES");
  61. if (notesFilesVariable)
  62. {
  63. std::vector<std::string> notesFiles;
  64. cmCTest::VectorOfStrings newNotesFiles;
  65. cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles);
  66. newNotesFiles.insert(newNotesFiles.end(),
  67. notesFiles.begin(), notesFiles.end());
  68. this->CTest->GenerateNotesFile(newNotesFiles);
  69. }
  70. const char* extraFilesVariable
  71. = this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
  72. if (extraFilesVariable)
  73. {
  74. std::vector<std::string> extraFiles;
  75. cmCTest::VectorOfStrings newExtraFiles;
  76. cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles);
  77. newExtraFiles.insert(newExtraFiles.end(),
  78. extraFiles.begin(), extraFiles.end());
  79. if ( !this->CTest->SubmitExtraFiles(newExtraFiles))
  80. {
  81. this->SetError("problem submitting extra files.");
  82. return 0;
  83. }
  84. }
  85. cmCTestGenericHandler* handler
  86. = this->CTest->GetInitializedHandler("submit");
  87. if ( !handler )
  88. {
  89. this->SetError("internal CTest error. Cannot instantiate submit handler");
  90. return 0;
  91. }
  92. // If no FILES or PARTS given, *all* PARTS are submitted by default.
  93. //
  94. // If FILES are given, but not PARTS, only the FILES are submitted
  95. // and *no* PARTS are submitted.
  96. // (This is why we select the empty "noParts" set in the
  97. // FilesMentioned block below...)
  98. //
  99. // If PARTS are given, only the selected PARTS are submitted.
  100. //
  101. // If both PARTS and FILES are given, only the selected PARTS *and*
  102. // all the given FILES are submitted.
  103. // If given explicit FILES to submit, pass them to the handler.
  104. //
  105. if(this->FilesMentioned)
  106. {
  107. // Intentionally select *no* PARTS. (Pass an empty set.) If PARTS
  108. // were also explicitly mentioned, they will be selected below...
  109. // But FILES with no PARTS mentioned should just submit the FILES
  110. // without any of the default parts.
  111. //
  112. std::set<cmCTest::Part> noParts;
  113. static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(noParts);
  114. static_cast<cmCTestSubmitHandler*>(handler)->SelectFiles(this->Files);
  115. }
  116. // If a PARTS option was given, select only the named parts for submission.
  117. //
  118. if(this->PartsMentioned)
  119. {
  120. static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts);
  121. }
  122. static_cast<cmCTestSubmitHandler*>(handler)->SetOption("RetryDelay",
  123. this->RetryDelay.c_str());
  124. static_cast<cmCTestSubmitHandler*>(handler)->SetOption("RetryCount",
  125. this->RetryCount.c_str());
  126. static_cast<cmCTestSubmitHandler*>(handler)->SetOption("InternalTest",
  127. this->InternalTest ? "ON" : "OFF");
  128. return handler;
  129. }
  130. //----------------------------------------------------------------------------
  131. bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
  132. {
  133. // Look for arguments specific to this command.
  134. if(arg == "PARTS")
  135. {
  136. this->ArgumentDoing = ArgumentDoingParts;
  137. this->PartsMentioned = true;
  138. return true;
  139. }
  140. if(arg == "FILES")
  141. {
  142. this->ArgumentDoing = ArgumentDoingFiles;
  143. this->FilesMentioned = true;
  144. return true;
  145. }
  146. if(arg == "RETRY_COUNT")
  147. {
  148. this->ArgumentDoing = ArgumentDoingRetryCount;
  149. return true;
  150. }
  151. if(arg == "RETRY_DELAY")
  152. {
  153. this->ArgumentDoing = ArgumentDoingRetryDelay;
  154. return true;
  155. }
  156. if(arg == "INTERNAL_TEST_CHECKSUM")
  157. {
  158. this->InternalTest = true;
  159. return true;
  160. }
  161. // Look for other arguments.
  162. return this->Superclass::CheckArgumentKeyword(arg);
  163. }
  164. //----------------------------------------------------------------------------
  165. bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
  166. {
  167. // Handle states specific to this command.
  168. if(this->ArgumentDoing == ArgumentDoingParts)
  169. {
  170. cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str());
  171. if(p != cmCTest::PartCount)
  172. {
  173. this->Parts.insert(p);
  174. }
  175. else
  176. {
  177. std::ostringstream e;
  178. e << "Part name \"" << arg << "\" is invalid.";
  179. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  180. this->ArgumentDoing = ArgumentDoingError;
  181. }
  182. return true;
  183. }
  184. if(this->ArgumentDoing == ArgumentDoingFiles)
  185. {
  186. std::string filename(arg);
  187. if(cmSystemTools::FileExists(filename.c_str()))
  188. {
  189. this->Files.insert(filename);
  190. }
  191. else
  192. {
  193. std::ostringstream e;
  194. e << "File \"" << filename << "\" does not exist. Cannot submit "
  195. << "a non-existent file.";
  196. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  197. this->ArgumentDoing = ArgumentDoingError;
  198. }
  199. return true;
  200. }
  201. if(this->ArgumentDoing == ArgumentDoingRetryCount)
  202. {
  203. this->RetryCount = arg;
  204. return true;
  205. }
  206. if(this->ArgumentDoing == ArgumentDoingRetryDelay)
  207. {
  208. this->RetryDelay = arg;
  209. return true;
  210. }
  211. // Look for other arguments.
  212. return this->Superclass::CheckArgumentValue(arg);
  213. }