diff options
author | Joseph Snyder <joe.snyder@kitware.com> | 2014-05-21 19:19:35 (GMT) |
---|---|---|
committer | Joseph Snyder <joe.snyder@kitware.com> | 2014-06-12 14:38:19 (GMT) |
commit | 558c2190e89c4a62d9e279cfee2af1f77f628b9b (patch) | |
tree | f5452711f616f0a78493248978f294ad6b110db6 /Source/CTest/cmCTestCoverageHandler.cxx | |
parent | 47cde18849201c3b58479d38725b554f3ad34eaf (diff) | |
download | CMake-558c2190e89c4a62d9e279cfee2af1f77f628b9b.zip CMake-558c2190e89c4a62d9e279cfee2af1f77f628b9b.tar.gz CMake-558c2190e89c4a62d9e279cfee2af1f77f628b9b.tar.bz2 |
CTest: Add Jacoco Coverage functionality
Add the ability to parse the XML output of the Jacoco tool.
Jacoco (www.eclemma.org/jacoco) is a Java coverage tool.
Add and integrate a class for the parser and
include a test which utilizes the new parser.
Diffstat (limited to 'Source/CTest/cmCTestCoverageHandler.cxx')
-rw-r--r-- | Source/CTest/cmCTestCoverageHandler.cxx | 40 |
1 files changed, 40 insertions, 0 deletions
diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index da27c8c..76f6584 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -14,6 +14,7 @@ #include "cmParseCoberturaCoverage.h" #include "cmParseGTMCoverage.h" #include "cmParseCacheCoverage.h" +#include "cmParseJacocoCoverage.h" #include "cmCTest.h" #include "cmake.h" #include "cmMakefile.h" @@ -415,6 +416,13 @@ int cmCTestCoverageHandler::ProcessHandler() return error; } + file_count += this->HandleJacocoCoverage(&cont); + error = cont.Error; + if ( file_count < 0 ) + { + return error; + } + std::set<std::string> uncovered = this->FindUncoveredFiles(&cont); if ( file_count == 0 ) @@ -872,6 +880,38 @@ struct cmCTestCoverageHandlerLocale }; //---------------------------------------------------------------------- +int cmCTestCoverageHandler::HandleJacocoCoverage( + cmCTestCoverageHandlerContainer* cont) +{ + cmParseJacocoCoverage cov = + cmParseJacocoCoverage(*cont, this->CTest); + cmsys::Glob g; + std::vector<std::string> files; + g.SetRecurse(true); + + std::string SourceDir + = this->CTest->GetCTestConfiguration("SourceDirectory"); + std::string coverageFile = SourceDir+ "/*jacoco.xml"; + + g.FindFiles(coverageFile); + files=g.GetFiles(); + if (files.size() > 0) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Found Jacoco Files, Performing Coverage" << std::endl); + cov.LoadCoverageData(files); + } + else + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Cannot find Jacoco coverage files: " << coverageFile + << std::endl); + } + return static_cast<int>(cont->TotalCoverage.size()); +} + + +//---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestCoverageHandlerContainer* cont) { |