cmCTestSubmitCommand.cxx 7.3 KB

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