cmCTestSubmitCommand.cxx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158
  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. if ( !ctestDropMethod )
  28. {
  29. ctestDropMethod = "http";
  30. }
  31. if ( !ctestDropSite )
  32. {
  33. ctestDropSite = "public.kitware.com";
  34. }
  35. if ( !ctestDropLocation )
  36. {
  37. ctestDropLocation = "/cgi-bin/HTTPUploadDartFile.cgi";
  38. }
  39. if ( !ctestTriggerSite )
  40. {
  41. ctestTriggerSite
  42. = "http://public.kitware.com/cgi-bin/Submit-Random-TestingResults.cgi";
  43. cmCTestLog(this->CTest, HANDLER_OUTPUT, "* Use default trigger site: "
  44. << ctestTriggerSite << std::endl;);
  45. }
  46. this->CTest->SetCTestConfiguration("DropMethod", ctestDropMethod);
  47. this->CTest->SetCTestConfiguration("DropSite", ctestDropSite);
  48. this->CTest->SetCTestConfiguration("DropLocation", ctestDropLocation);
  49. this->CTest->SetCTestConfiguration("TriggerSite", ctestTriggerSite);
  50. this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
  51. "DropSiteUser", "CTEST_DROP_SITE_USER");
  52. this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
  53. "DropSitePassword", "CTEST_DROP_SITE_PASSWORD");
  54. this->CTest->SetCTestConfigurationFromCMakeVariable(this->Makefile,
  55. "ScpCommand", "CTEST_SCP_COMMAND");
  56. const char* notesFilesVariable
  57. = this->Makefile->GetDefinition("CTEST_NOTES_FILES");
  58. if (notesFilesVariable)
  59. {
  60. std::vector<std::string> notesFiles;
  61. std::vector<cmStdString> newNotesFiles;
  62. cmSystemTools::ExpandListArgument(notesFilesVariable,notesFiles);
  63. std::vector<std::string>::iterator it;
  64. for ( it = notesFiles.begin();
  65. it != notesFiles.end();
  66. ++ it )
  67. {
  68. newNotesFiles.push_back(*it);
  69. }
  70. this->CTest->GenerateNotesFile(newNotesFiles);
  71. }
  72. const char* extraFilesVariable
  73. = this->Makefile->GetDefinition("CTEST_EXTRA_SUBMIT_FILES");
  74. if (extraFilesVariable)
  75. {
  76. std::vector<std::string> extraFiles;
  77. std::vector<cmStdString> newExtraFiles;
  78. cmSystemTools::ExpandListArgument(extraFilesVariable,extraFiles);
  79. std::vector<std::string>::iterator it;
  80. for ( it = extraFiles.begin();
  81. it != extraFiles.end();
  82. ++ it )
  83. {
  84. newExtraFiles.push_back(*it);
  85. }
  86. if ( !this->CTest->SubmitExtraFiles(newExtraFiles))
  87. {
  88. this->SetError("problem submitting extra files.");
  89. return 0;
  90. }
  91. }
  92. cmCTestGenericHandler* handler
  93. = this->CTest->GetInitializedHandler("submit");
  94. if ( !handler )
  95. {
  96. this->SetError("internal CTest error. Cannot instantiate submit handler");
  97. return 0;
  98. }
  99. // If a PARTS option was given, select only the named parts for submission.
  100. if(!this->Parts.empty())
  101. {
  102. static_cast<cmCTestSubmitHandler*>(handler)->SelectParts(this->Parts);
  103. }
  104. return handler;
  105. }
  106. //----------------------------------------------------------------------------
  107. bool cmCTestSubmitCommand::CheckArgumentKeyword(std::string const& arg)
  108. {
  109. // Look for arguments specific to this command.
  110. if(arg == "PARTS")
  111. {
  112. this->ArgumentDoing = ArgumentDoingParts;
  113. return true;
  114. }
  115. // Look for other arguments.
  116. return this->Superclass::CheckArgumentKeyword(arg);
  117. }
  118. //----------------------------------------------------------------------------
  119. bool cmCTestSubmitCommand::CheckArgumentValue(std::string const& arg)
  120. {
  121. // Handle states specific to this command.
  122. if(this->ArgumentDoing == ArgumentDoingParts)
  123. {
  124. cmCTest::Part p = this->CTest->GetPartFromName(arg.c_str());
  125. if(p != cmCTest::PartCount)
  126. {
  127. this->Parts.insert(p);
  128. }
  129. else
  130. {
  131. cmOStringStream e;
  132. e << "Part name \"" << arg << "\" is invalid.";
  133. this->Makefile->IssueMessage(cmake::FATAL_ERROR, e.str());
  134. this->ArgumentDoing = ArgumentDoingError;
  135. }
  136. return true;
  137. }
  138. // Look for other arguments.
  139. return this->Superclass::CheckArgumentValue(arg);
  140. }