cmCTestGenericHandler.cxx 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124
  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. m_HandlerVerbose = false;
  19. m_CTest = 0;
  20. m_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. = m_Options.find(op);
  37. if ( remit != m_Options.end() )
  38. {
  39. m_Options.erase(remit);
  40. }
  41. return;
  42. }
  43. m_Options[op] = value;
  44. }
  45. //----------------------------------------------------------------------
  46. void cmCTestGenericHandler::Initialize()
  47. {
  48. m_Options.clear();
  49. }
  50. //----------------------------------------------------------------------
  51. const char* cmCTestGenericHandler::GetOption(const char* op)
  52. {
  53. cmCTestGenericHandler::t_StringToString::iterator remit
  54. = m_Options.find(op);
  55. if ( remit == m_Options.end() )
  56. {
  57. return 0;
  58. }
  59. return remit->second.c_str();
  60. }
  61. //----------------------------------------------------------------------
  62. bool cmCTestGenericHandler::StartResultingXML(const char* name, cmGeneratedFileStream& xofs)
  63. {
  64. if ( !name )
  65. {
  66. cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create resulting XML file without providing the name" << std::endl;);
  67. return false;
  68. }
  69. cmOStringStream ostr;
  70. ostr << name;
  71. if ( m_SubmitIndex > 0 )
  72. {
  73. ostr << "_" << m_SubmitIndex;
  74. }
  75. ostr << ".xml";
  76. if( !m_CTest->OpenOutputFile(m_CTest->GetCurrentTag(), ostr.str().c_str(), xofs, true) )
  77. {
  78. cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create resulting XML file: " << ostr.str().c_str() << std::endl);
  79. return false;
  80. }
  81. m_CTest->AddSubmitFile(ostr.str().c_str());
  82. return true;
  83. }
  84. //----------------------------------------------------------------------
  85. bool cmCTestGenericHandler::StartLogFile(const char* name, cmGeneratedFileStream& xofs)
  86. {
  87. if ( !name )
  88. {
  89. cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create log file without providing the name" << std::endl;);
  90. return false;
  91. }
  92. cmOStringStream ostr;
  93. ostr << "Last" << name;
  94. if ( m_SubmitIndex > 0 )
  95. {
  96. ostr << "_" << m_SubmitIndex;
  97. }
  98. if ( m_CTest->GetCurrentTag().c_str() )
  99. {
  100. ostr << "_" << m_CTest->GetCurrentTag();
  101. }
  102. ostr << ".log";
  103. if( !m_CTest->OpenOutputFile("Temporary", ostr.str().c_str(), xofs) )
  104. {
  105. cmCTestLog(m_CTest, ERROR_MESSAGE, "Cannot create log file: " << ostr.str().c_str() << std::endl);
  106. return false;
  107. }
  108. return true;
  109. }