cmCTestCoverageHandler.h 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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. 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. #ifndef cmCTestCoverageHandler_h
  14. #define cmCTestCoverageHandler_h
  15. #include "cmCTestGenericHandler.h"
  16. #include "cmListFileCache.h"
  17. #include <cmsys/RegularExpression.hxx>
  18. class cmGeneratedFileStream;
  19. /** \class cmCTestCoverageHandler
  20. * \brief A class that handles coverage computaiton for ctest
  21. *
  22. */
  23. class cmCTestCoverageHandler : public cmCTestGenericHandler
  24. {
  25. public:
  26. cmTypeMacro(cmCTestCoverageHandler, cmCTestGenericHandler);
  27. /*
  28. * The main entry point for this class
  29. */
  30. int ProcessHandler();
  31. cmCTestCoverageHandler();
  32. virtual void Initialize();
  33. /**
  34. * This method is called when reading CTest custom file
  35. */
  36. void PopulateCustomVectors(cmMakefile *mf);
  37. private:
  38. bool ShouldIDoCoverage(const char* file, const char* srcDir,
  39. const char* binDir);
  40. bool StartCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount);
  41. void EndCoverageLogFile(cmGeneratedFileStream& ostr, int logFileCount);
  42. struct cmCTestCoverage
  43. {
  44. cmCTestCoverage()
  45. {
  46. this->AbsolutePath = "";
  47. this->FullPath = "";
  48. this->Covered = false;
  49. this->Tested = 0;
  50. this->UnTested = 0;
  51. this->Lines.clear();
  52. this->Show = false;
  53. }
  54. cmCTestCoverage(const cmCTestCoverage& rhs) :
  55. AbsolutePath(rhs.AbsolutePath),
  56. FullPath(rhs.FullPath),
  57. Covered(rhs.Covered),
  58. Tested(rhs.Tested),
  59. UnTested(rhs.UnTested),
  60. Lines(rhs.Lines),
  61. Show(rhs.Show)
  62. {
  63. }
  64. cmCTestCoverage& operator=(const cmCTestCoverage& rhs)
  65. {
  66. this->AbsolutePath = rhs.AbsolutePath;
  67. this->FullPath = rhs.FullPath;
  68. this->Covered = rhs.Covered;
  69. this->Tested = rhs.Tested;
  70. this->UnTested = rhs.UnTested;
  71. this->Lines = rhs.Lines;
  72. this->Show = rhs.Show;
  73. return *this;
  74. }
  75. std::string AbsolutePath;
  76. std::string FullPath;
  77. bool Covered;
  78. int Tested;
  79. int UnTested;
  80. std::vector<int> Lines;
  81. bool Show;
  82. };
  83. std::vector<cmStdString> CustomCoverageExclude;
  84. std::vector<cmsys::RegularExpression> CustomCoverageExcludeRegex;
  85. typedef std::map<std::string, cmCTestCoverage> CoverageMap;
  86. };
  87. #endif