cmCTestUploadHandler.cxx 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /*============================================================================
  2. CMake - Cross Platform Makefile Generator
  3. Copyright 2000-2009 Kitware, Inc.
  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 "cmCTestUploadHandler.h"
  11. #include "cmGeneratedFileStream.h"
  12. #include "cmVersion.h"
  13. #include "cmXMLSafe.h"
  14. //----------------------------------------------------------------------------
  15. cmCTestUploadHandler::cmCTestUploadHandler()
  16. {
  17. this->Initialize();
  18. }
  19. //----------------------------------------------------------------------------
  20. void cmCTestUploadHandler::Initialize()
  21. {
  22. this->Superclass::Initialize();
  23. this->Files.clear();
  24. }
  25. void cmCTestUploadHandler::SetFiles(const cmCTest::SetOfStrings& files)
  26. {
  27. this->Files = files;
  28. }
  29. //----------------------------------------------------------------------------
  30. int cmCTestUploadHandler::ProcessHandler()
  31. {
  32. cmGeneratedFileStream ofs;
  33. if ( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(),
  34. "Upload.xml", ofs))
  35. {
  36. cmCTestLog(this->CTest, ERROR_MESSAGE,
  37. "Cannot open Upload.xml file" << std::endl);
  38. return -1;
  39. }
  40. std::string buildname = cmCTest::SafeBuildIdField(
  41. this->CTest->GetCTestConfiguration("BuildName"));
  42. cmCTest::SetOfStrings::const_iterator it;
  43. ofs << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
  44. << "<?xml-stylesheet type=\"text/xsl\" "
  45. "href=\"Dart/Source/Server/XSL/Build.xsl "
  46. "<file:///Dart/Source/Server/XSL/Build.xsl> \"?>\n"
  47. << "<Site BuildName=\""
  48. << buildname
  49. << "\" BuildStamp=\""
  50. << this->CTest->GetCurrentTag() << "-"
  51. << this->CTest->GetTestModelString() << "\" Name=\""
  52. << this->CTest->GetCTestConfiguration("Site") << "\" Generator=\"ctest"
  53. << cmVersion::GetCMakeVersion()
  54. << "\">\n";
  55. this->CTest->AddSiteProperties(ofs);
  56. ofs << "<Upload>\n";
  57. for ( it = this->Files.begin(); it != this->Files.end(); it ++ )
  58. {
  59. cmCTestOptionalLog(this->CTest, OUTPUT,
  60. "\tUpload file: " << *it << std::endl, this->Quiet);
  61. ofs << "<File filename=\"" << cmXMLSafe(*it) << "\">\n"
  62. << "<Content encoding=\"base64\">\n";
  63. ofs << this->CTest->Base64EncodeFile(*it);
  64. ofs << "\n</Content>\n"
  65. << "</File>\n";
  66. }
  67. ofs << "</Upload>\n"
  68. << "</Site>\n";
  69. return 0;
  70. }