cmCTestUploadHandler.cxx 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  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. cmCTest::SetOfStrings::const_iterator it;
  41. ofs << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
  42. << "<?xml-stylesheet type=\"text/xsl\" "
  43. "href=\"Dart/Source/Server/XSL/Build.xsl "
  44. "<file:///Dart/Source/Server/XSL/Build.xsl> \"?>\n"
  45. << "<Site BuildName=\""
  46. << this->CTest->GetCTestConfiguration("BuildName")
  47. << "\" BuildStamp=\""
  48. << this->CTest->GetCurrentTag() << "-"
  49. << this->CTest->GetTestModelString() << "\" Name=\""
  50. << this->CTest->GetCTestConfiguration("Site") << "\" Generator=\"ctest"
  51. << cmVersion::GetCMakeVersion()
  52. << "\">\n";
  53. this->CTest->AddSiteProperties(ofs);
  54. ofs << "<Upload>\n";
  55. for ( it = this->Files.begin(); it != this->Files.end(); it ++ )
  56. {
  57. cmCTestLog(this->CTest, OUTPUT,
  58. "\tUpload file: " << it->c_str() << std::endl);
  59. ofs << "<File filename=\"" << cmXMLSafe(*it) << "\">\n"
  60. << "<Content encoding=\"base64\">\n";
  61. ofs << this->CTest->Base64EncodeFile(*it);
  62. ofs << "\n</Content>\n"
  63. << "</File>\n";
  64. }
  65. ofs << "</Upload>\n"
  66. << "</Site>\n";
  67. return 0;
  68. }