diff options
author | Joseph Snyder <joe.snyder@kitware.com> | 2014-10-23 21:03:30 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2014-10-29 15:27:11 (GMT) |
commit | 220e81345b68ed3ad15ef294f6de653fcd1a874c (patch) | |
tree | 759f57741cb0ba02e764515142284d6bf99ae8a1 /Source/CTest/cmCTestCoverageHandler.cxx | |
parent | a2456e157223255f0e2a71f2ddd510510e42b9e4 (diff) | |
download | CMake-220e81345b68ed3ad15ef294f6de653fcd1a874c.zip CMake-220e81345b68ed3ad15ef294f6de653fcd1a874c.tar.gz CMake-220e81345b68ed3ad15ef294f6de653fcd1a874c.tar.bz2 |
CTest: Add Javascript coverage parser
Add a coverage parser for the Blanket.js library using the JSON output of
the mocha.js test runner.
Add a test for 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 7d3c6bc..8dc22a8 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -16,6 +16,7 @@ #include "cmParseCacheCoverage.h" #include "cmParseJacocoCoverage.h" #include "cmParseDelphiCoverage.h" +#include "cmParseBlanketJSCoverage.h" #include "cmCTest.h" #include "cmake.h" #include "cmMakefile.h" @@ -424,6 +425,13 @@ int cmCTestCoverageHandler::ProcessHandler() return error; } + file_count += this->HandleBlanketJSCoverage(&cont); + error = cont.Error; + if ( file_count < 0 ) + { + return error; + } + file_count += this->HandleDelphiCoverage(&cont); error = cont.Error; if ( file_count < 0 ) @@ -927,10 +935,12 @@ int cmCTestCoverageHandler::HandleDelphiCoverage( std::vector<std::string> files; g.SetRecurse(true); + std::string BinDir = this->CTest->GetBinaryDir(); std::string coverageFile = BinDir+ "/*.html"; + g.FindFiles(coverageFile); files=g.GetFiles(); if (files.size() > 0) @@ -947,6 +957,36 @@ int cmCTestCoverageHandler::HandleDelphiCoverage( } return static_cast<int>(cont->TotalCoverage.size()); } + +//---------------------------------------------------------------------- +int cmCTestCoverageHandler::HandleBlanketJSCoverage( + cmCTestCoverageHandlerContainer* cont) + { + cmParseBlanketJSCoverage cov = + cmParseBlanketJSCoverage(*cont, this->CTest); + std::string SourceDir + = this->CTest->GetCTestConfiguration("SourceDirectory"); + + //Look for something other than output.json, still JSON extension. + std::string coverageFile = SourceDir+ "/*.json"; + cmsys::Glob g; + std::vector<std::string> files; + g.FindFiles(coverageFile); + files=g.GetFiles(); + if (files.size() > 0) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + "Found BlanketJS output JSON, Performing Coverage" << std::endl); + cov.LoadCoverageData(files); + } + else + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, + " Cannot find BlanketJS coverage files: " << coverageFile + << std::endl); + } + return static_cast<int>(cont->TotalCoverage.size()); + } //---------------------------------------------------------------------- int cmCTestCoverageHandler::HandleGCovCoverage( cmCTestCoverageHandlerContainer* cont) |