cmCTestGenericHandler.cxx 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 "cmCTestGenericHandler.h"
  14. #include "cmCTest.h"
  15. //----------------------------------------------------------------------
  16. cmCTestGenericHandler::cmCTestGenericHandler()
  17. {
  18. this->HandlerVerbose = false;
  19. this->CTest = 0;
  20. this->SubmitIndex = 0;
  21. }
  22. //----------------------------------------------------------------------
  23. cmCTestGenericHandler::~cmCTestGenericHandler()
  24. {
  25. }
  26. //----------------------------------------------------------------------
  27. void cmCTestGenericHandler::SetOption(const char* op, const char* value)
  28. {
  29. if ( !op )
  30. {
  31. return;
  32. }
  33. if ( !value )
  34. {
  35. cmCTestGenericHandler::t_StringToString::iterator remit
  36. = this->Options.find(op);
  37. if ( remit != this->Options.end() )
  38. {
  39. this->Options.erase(remit);
  40. }
  41. return;
  42. }
  43. this->Options[op] = value;
  44. }
  45. //----------------------------------------------------------------------
  46. void cmCTestGenericHandler::Initialize()
  47. {
  48. this->Options.clear();
  49. }
  50. //----------------------------------------------------------------------
  51. const char* cmCTestGenericHandler::GetOption(const char* op)
  52. {
  53. cmCTestGenericHandler::t_StringToString::iterator remit
  54. = this->Options.find(op);
  55. if ( remit == this->Options.end() )
  56. {
  57. return 0;
  58. }
  59. return remit->second.c_str();
  60. }
  61. //----------------------------------------------------------------------
  62. bool cmCTestGenericHandler::StartResultingXML(const char* name,
  63. cmGeneratedFileStream& xofs)
  64. {
  65. if ( !name )
  66. {
  67. cmCTestLog(this->CTest, ERROR_MESSAGE,
  68. "Cannot create resulting XML file without providing the name"
  69. << std::endl;);
  70. return false;
  71. }
  72. cmOStringStream ostr;
  73. ostr << name;
  74. if ( this->SubmitIndex > 0 )
  75. {
  76. ostr << "_" << this->SubmitIndex;
  77. }
  78. ostr << ".xml";
  79. if( !this->CTest->OpenOutputFile(this->CTest->GetCurrentTag(),
  80. ostr.str().c_str(), xofs, true) )
  81. {
  82. cmCTestLog(this->CTest, ERROR_MESSAGE,
  83. "Cannot create resulting XML file: " << ostr.str().c_str()
  84. << std::endl);
  85. return false;
  86. }
  87. this->CTest->AddSubmitFile(ostr.str().c_str());
  88. return true;
  89. }
  90. //----------------------------------------------------------------------
  91. bool cmCTestGenericHandler::StartLogFile(const char* name,
  92. cmGeneratedFileStream& xofs)
  93. {
  94. if ( !name )
  95. {
  96. cmCTestLog(this->CTest, ERROR_MESSAGE,
  97. "Cannot create log file without providing the name" << std::endl;);
  98. return false;
  99. }
  100. cmOStringStream ostr;
  101. ostr << "Last" << name;
  102. if ( this->SubmitIndex > 0 )
  103. {
  104. ostr << "_" << this->SubmitIndex;
  105. }
  106. if ( !this->CTest->GetCurrentTag().empty() )
  107. {
  108. ostr << "_" << this->CTest->GetCurrentTag();
  109. }
  110. ostr << ".log";
  111. if( !this->CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) )
  112. {
  113. cmCTestLog(this->CTest, ERROR_MESSAGE, "Cannot create log file: "
  114. << ostr.str().c_str() << std::endl);
  115. return false;
  116. }
  117. return true;
  118. }