From a2822d30899f3fc2ad96abfdf5de0d0ce4166139 Mon Sep 17 00:00:00 2001 From: Joseph Snyder Date: Tue, 3 Jun 2014 18:30:46 +0000 Subject: CTest: Rename coverage implementation for "Python" to "Cobertura" The coverage.py tool writes out an XML that conforms to the Cobertura Coverage tool standard. Rename the cmParsePythonCoverage files to instead be cmParseCoberturaCoverage. --- Source/CMakeLists.txt | 2 +- Source/CTest/cmCTestCoverageHandler.cxx | 12 +-- Source/CTest/cmCTestCoverageHandler.h | 2 +- Source/CTest/cmParseCoberturaCoverage.cxx | 119 ++++++++++++++++++++++++++++++ Source/CTest/cmParseCoberturaCoverage.h | 48 ++++++++++++ Source/CTest/cmParsePythonCoverage.cxx | 119 ------------------------------ Source/CTest/cmParsePythonCoverage.h | 48 ------------ 7 files changed, 175 insertions(+), 175 deletions(-) create mode 100644 Source/CTest/cmParseCoberturaCoverage.cxx create mode 100644 Source/CTest/cmParseCoberturaCoverage.h delete mode 100644 Source/CTest/cmParsePythonCoverage.cxx delete mode 100644 Source/CTest/cmParsePythonCoverage.h diff --git a/Source/CMakeLists.txt b/Source/CMakeLists.txt index 8ecf83c..fe6cc1b 100644 --- a/Source/CMakeLists.txt +++ b/Source/CMakeLists.txt @@ -519,7 +519,7 @@ set(CTEST_SRCS cmCTest.cxx CTest/cmParseCacheCoverage.cxx CTest/cmParseGTMCoverage.cxx CTest/cmParsePHPCoverage.cxx - CTest/cmParsePythonCoverage.cxx + CTest/cmParseCoberturaCoverage.cxx CTest/cmCTestEmptyBinaryDirectoryCommand.cxx CTest/cmCTestGenericHandler.cxx CTest/cmCTestHandlerCommand.cxx diff --git a/Source/CTest/cmCTestCoverageHandler.cxx b/Source/CTest/cmCTestCoverageHandler.cxx index cb6e56e..da27c8c 100644 --- a/Source/CTest/cmCTestCoverageHandler.cxx +++ b/Source/CTest/cmCTestCoverageHandler.cxx @@ -11,7 +11,7 @@ ============================================================================*/ #include "cmCTestCoverageHandler.h" #include "cmParsePHPCoverage.h" -#include "cmParsePythonCoverage.h" +#include "cmParseCoberturaCoverage.h" #include "cmParseGTMCoverage.h" #include "cmParseCacheCoverage.h" #include "cmCTest.h" @@ -401,7 +401,7 @@ int cmCTestCoverageHandler::ProcessHandler() { return error; } - file_count += this->HandlePythonCoverage(&cont); + file_count += this->HandleCoberturaCoverage(&cont); error = cont.Error; if ( file_count < 0 ) { @@ -779,10 +779,10 @@ int cmCTestCoverageHandler::HandlePHPCoverage( } //---------------------------------------------------------------------- -int cmCTestCoverageHandler::HandlePythonCoverage( +int cmCTestCoverageHandler::HandleCoberturaCoverage( cmCTestCoverageHandlerContainer* cont) { - cmParsePythonCoverage cov(*cont, this->CTest); + cmParseCoberturaCoverage cov(*cont, this->CTest); // Assume the coverage.xml is in the source directory std::string coverageXMLFile = this->CTest->GetBinaryDir() + "/coverage.xml"; @@ -790,14 +790,14 @@ int cmCTestCoverageHandler::HandlePythonCoverage( if(cmSystemTools::FileExists(coverageXMLFile.c_str())) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Parsing coverage.py XML file: " << coverageXMLFile + "Parsing Cobertura XML file: " << coverageXMLFile << std::endl); cov.ReadCoverageXML(coverageXMLFile.c_str()); } else { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, - "Cannot find coverage.py XML file: " << coverageXMLFile + "Cannot find Cobertura XML file: " << coverageXMLFile << std::endl); } return static_cast(cont->TotalCoverage.size()); diff --git a/Source/CTest/cmCTestCoverageHandler.h b/Source/CTest/cmCTestCoverageHandler.h index 0a0fe81..38a3353 100644 --- a/Source/CTest/cmCTestCoverageHandler.h +++ b/Source/CTest/cmCTestCoverageHandler.h @@ -76,7 +76,7 @@ private: int HandlePHPCoverage(cmCTestCoverageHandlerContainer* cont); //! Handle coverage for Python with coverage.py - int HandlePythonCoverage(cmCTestCoverageHandlerContainer* cont); + int HandleCoberturaCoverage(cmCTestCoverageHandlerContainer* cont); //! Handle coverage for mumps int HandleMumpsCoverage(cmCTestCoverageHandlerContainer* cont); diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx new file mode 100644 index 0000000..0f5daba --- /dev/null +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -0,0 +1,119 @@ +#include "cmStandardIncludes.h" +#include "cmSystemTools.h" +#include "cmXMLParser.h" +#include "cmParseCoberturaCoverage.h" +#include +#include + +//---------------------------------------------------------------------------- +class cmParseCoberturaCoverage::XMLParser: public cmXMLParser +{ +public: + XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont) + : CTest(ctest), Coverage(cont) + { + } + + virtual ~XMLParser() + { + } + +protected: + + virtual void StartElement(const std::string& name, const char** atts) + { + if(name == "class") + { + int tagCount = 0; + while(true) + { + if(strcmp(atts[tagCount], "filename") == 0) + { + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Reading file: " + << atts[tagCount+1] << std::endl); + this->CurFileName = this->Coverage.SourceDir + "/" + + atts[tagCount+1]; + cmsys::ifstream fin(this->CurFileName.c_str()); + if(!fin) + { + this->CurFileName = this->Coverage.BinaryDir + "/" + + atts[tagCount+1]; + fin.open(this->CurFileName.c_str()); + if (!fin) + { + cmCTestLog(this->CTest, ERROR_MESSAGE, + "Python Coverage: Error opening " << this->CurFileName + << std::endl); + this->Coverage.Error++; + break; + } + } + + std::string line; + FileLinesType& curFileLines = + this->Coverage.TotalCoverage[this->CurFileName]; + curFileLines.push_back(-1); + while(cmSystemTools::GetLineFromStream(fin, line)) + { + curFileLines.push_back(-1); + } + + break; + } + ++tagCount; + } + } + else if(name == "line") + { + int tagCount = 0; + int curNumber = -1; + int curHits = -1; + while(true) + { + if(strcmp(atts[tagCount], "hits") == 0) + { + curHits = atoi(atts[tagCount+1]); + } + else if(strcmp(atts[tagCount], "number") == 0) + { + curNumber = atoi(atts[tagCount+1]); + } + + if(curHits > -1 && curNumber > 0) + { + FileLinesType& curFileLines = + this->Coverage.TotalCoverage[this->CurFileName]; + curFileLines[curNumber-1] = curHits; + break; + } + ++tagCount; + } + } + } + + virtual void EndElement(const std::string&) {} + +private: + + typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector + FileLinesType; + cmCTest* CTest; + cmCTestCoverageHandlerContainer& Coverage; + std::string CurFileName; + +}; + + +cmParseCoberturaCoverage::cmParseCoberturaCoverage( + cmCTestCoverageHandlerContainer& cont, + cmCTest* ctest) + :Coverage(cont), CTest(ctest) +{ +} + +bool cmParseCoberturaCoverage::ReadCoverageXML(const char* xmlFile) +{ + cmParseCoberturaCoverage::XMLParser parser(this->CTest, this->Coverage); + parser.ParseFile(xmlFile); + return true; +} diff --git a/Source/CTest/cmParseCoberturaCoverage.h b/Source/CTest/cmParseCoberturaCoverage.h new file mode 100644 index 0000000..4204b10 --- /dev/null +++ b/Source/CTest/cmParseCoberturaCoverage.h @@ -0,0 +1,48 @@ +/*============================================================================ + CMake - Cross Platform Makefile Generator + Copyright 2000-2009 Kitware, Inc. + + Distributed under the OSI-approved BSD License (the "License"); + see accompanying file Copyright.txt for details. + + This software is distributed WITHOUT ANY WARRANTY; without even the + implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + See the License for more information. +============================================================================*/ + +#ifndef cmParseCoberturaCoverage_h +#define cmParseCoberturaCoverage_h + +#include "cmStandardIncludes.h" +#include "cmCTestCoverageHandler.h" + +/** \class cmParsePythonCoverage + * \brief Parse coverage.py Python coverage information + * + * This class is used to parse the output of the coverage.py tool that + * is currently maintained by Ned Batchelder. That tool has a command + * that produces xml output in the format typically output by the common + * Java-based Cobertura coverage application. This helper class parses + * that XML file to fill the coverage-handler container. + */ +class cmParseCoberturaCoverage +{ +public: + + //! Create the coverage parser by passing in the coverage handler + //! container and the cmCTest object + cmParseCoberturaCoverage(cmCTestCoverageHandlerContainer& cont, + cmCTest* ctest); + + //! Read the XML produced by running `coverage xml` + bool ReadCoverageXML(const char* xmlFile); + +private: + + class XMLParser; + cmCTestCoverageHandlerContainer& Coverage; + cmCTest* CTest; + std::string CurFileName; +}; + +#endif diff --git a/Source/CTest/cmParsePythonCoverage.cxx b/Source/CTest/cmParsePythonCoverage.cxx deleted file mode 100644 index 817b8dc..0000000 --- a/Source/CTest/cmParsePythonCoverage.cxx +++ /dev/null @@ -1,119 +0,0 @@ -#include "cmStandardIncludes.h" -#include "cmSystemTools.h" -#include "cmXMLParser.h" -#include "cmParsePythonCoverage.h" -#include -#include - -//---------------------------------------------------------------------------- -class cmParsePythonCoverage::XMLParser: public cmXMLParser -{ -public: - XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont) - : CTest(ctest), Coverage(cont) - { - } - - virtual ~XMLParser() - { - } - -protected: - - virtual void StartElement(const std::string& name, const char** atts) - { - if(name == "class") - { - int tagCount = 0; - while(true) - { - if(strcmp(atts[tagCount], "filename") == 0) - { - cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Reading file: " - << atts[tagCount+1] << std::endl); - this->CurFileName = this->Coverage.SourceDir + "/" + - atts[tagCount+1]; - cmsys::ifstream fin(this->CurFileName.c_str()); - if(!fin) - { - this->CurFileName = this->Coverage.BinaryDir + "/" + - atts[tagCount+1]; - fin.open(this->CurFileName.c_str()); - if (!fin) - { - cmCTestLog(this->CTest, ERROR_MESSAGE, - "Python Coverage: Error opening " << this->CurFileName - << std::endl); - this->Coverage.Error++; - break; - } - } - - std::string line; - FileLinesType& curFileLines = - this->Coverage.TotalCoverage[this->CurFileName]; - curFileLines.push_back(-1); - while(cmSystemTools::GetLineFromStream(fin, line)) - { - curFileLines.push_back(-1); - } - - break; - } - ++tagCount; - } - } - else if(name == "line") - { - int tagCount = 0; - int curNumber = -1; - int curHits = -1; - while(true) - { - if(strcmp(atts[tagCount], "hits") == 0) - { - curHits = atoi(atts[tagCount+1]); - } - else if(strcmp(atts[tagCount], "number") == 0) - { - curNumber = atoi(atts[tagCount+1]); - } - - if(curHits > -1 && curNumber > 0) - { - FileLinesType& curFileLines = - this->Coverage.TotalCoverage[this->CurFileName]; - curFileLines[curNumber-1] = curHits; - break; - } - ++tagCount; - } - } - } - - virtual void EndElement(const std::string&) {} - -private: - - typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector - FileLinesType; - cmCTest* CTest; - cmCTestCoverageHandlerContainer& Coverage; - std::string CurFileName; - -}; - - -cmParsePythonCoverage::cmParsePythonCoverage( - cmCTestCoverageHandlerContainer& cont, - cmCTest* ctest) - :Coverage(cont), CTest(ctest) -{ -} - -bool cmParsePythonCoverage::ReadCoverageXML(const char* xmlFile) -{ - cmParsePythonCoverage::XMLParser parser(this->CTest, this->Coverage); - parser.ParseFile(xmlFile); - return true; -} diff --git a/Source/CTest/cmParsePythonCoverage.h b/Source/CTest/cmParsePythonCoverage.h deleted file mode 100644 index 668c7f9..0000000 --- a/Source/CTest/cmParsePythonCoverage.h +++ /dev/null @@ -1,48 +0,0 @@ -/*============================================================================ - CMake - Cross Platform Makefile Generator - Copyright 2000-2009 Kitware, Inc. - - Distributed under the OSI-approved BSD License (the "License"); - see accompanying file Copyright.txt for details. - - This software is distributed WITHOUT ANY WARRANTY; without even the - implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - See the License for more information. -============================================================================*/ - -#ifndef cmParsePythonCoverage_h -#define cmParsePythonCoverage_h - -#include "cmStandardIncludes.h" -#include "cmCTestCoverageHandler.h" - -/** \class cmParsePythonCoverage - * \brief Parse coverage.py Python coverage information - * - * This class is used to parse the output of the coverage.py tool that - * is currently maintained by Ned Batchelder. That tool has a command - * that produces xml output in the format typically output by the common - * Java-based Cobertura coverage application. This helper class parses - * that XML file to fill the coverage-handler container. - */ -class cmParsePythonCoverage -{ -public: - - //! Create the coverage parser by passing in the coverage handler - //! container and the cmCTest object - cmParsePythonCoverage(cmCTestCoverageHandlerContainer& cont, - cmCTest* ctest); - - //! Read the XML produced by running `coverage xml` - bool ReadCoverageXML(const char* xmlFile); - -private: - - class XMLParser; - cmCTestCoverageHandlerContainer& Coverage; - cmCTest* CTest; - std::string CurFileName; -}; - -#endif -- cgit v0.12 From 50daf239b001ddda61449044e75bb98651e99d21 Mon Sep 17 00:00:00 2001 From: Joseph Snyder Date: Thu, 29 May 2014 17:47:31 +0000 Subject: CTest: Generalize Cobertura coverage format handling Add support for Cobertura coverage files written by Java. Add a test which uses the report from a Java run of Cobertura to calculate coverage. In the documentation of CTEST_COVERAGE_COMMAND, give a sample .sh file to merge the Cobertura .ser files and generate the XML report from the merged file. --- Help/variable/CTEST_COVERAGE_COMMAND.rst | 55 ++++++++++ Source/CTest/cmParseCoberturaCoverage.cxx | 67 ++++++++++-- Source/CTest/cmParseCoberturaCoverage.h | 3 + Tests/CMakeLists.txt | 18 ++++ Tests/CoberturaCoverage/DartConfiguration.tcl.in | 8 ++ Tests/CoberturaCoverage/coverage.xml.in | 112 +++++++++++++++++++++ .../src/main/java/org/cmake/CoverageTest.java | 52 ++++++++++ 7 files changed, 306 insertions(+), 9 deletions(-) create mode 100644 Tests/CoberturaCoverage/DartConfiguration.tcl.in create mode 100644 Tests/CoberturaCoverage/coverage.xml.in create mode 100644 Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java diff --git a/Help/variable/CTEST_COVERAGE_COMMAND.rst b/Help/variable/CTEST_COVERAGE_COMMAND.rst index 1a8e499..a669dd7 100644 --- a/Help/variable/CTEST_COVERAGE_COMMAND.rst +++ b/Help/variable/CTEST_COVERAGE_COMMAND.rst @@ -3,3 +3,58 @@ CTEST_COVERAGE_COMMAND Specify the CTest ``CoverageCommand`` setting in a :manual:`ctest(1)` dashboard client script. + +Cobertura +''''''''' + +Using `Cobertura`_ as the coverage generation within your multi-module +Java project can generate a series of XML files. + +The Cobertura Coverage parser expects to read the coverage data from a +single XML file which contains the coverage data for all modules. +Cobertura has a program with the ability to merge given cobertura.ser files +and then another program to generate a combined XML file from the previous +merged file. For command line testing, this can be done by hand prior to +CTest looking for the coverage files. For script builds, +set the ``CTEST_COVERAGE_COMMAND`` variable to point to a file which will +perform these same steps, such as a .sh or .bat file. + +.. code-block:: cmake + + set(CTEST_COVERAGE_COMMAND .../run-coverage-and-consolidate.sh) + +where the ``run-coverage-and-consolidate.sh`` script is perhaps created by +the :command:`configure_file` command and might contain the following code: + +.. code-block:: bash + + #!/usr/bin/env bash + CoberturaFiles="$(find "/path/to/source" -name "cobertura.ser")" + SourceDirs="$(find "/path/to/source" -name "java" -type d)" + cobertura-merge --datafile coberturamerge.ser $CoberturaFiles + cobertura-report --datafile coberturamerge.ser --destination . \ + --format xml $SourceDirs + +The script uses ``find`` to capture the paths to all of the cobertura.ser files +found below the project's source directory. It keeps the list of files and +supplies it as an argument to the ``cobertura-merge`` program. The ``--datafile`` +argument signifies where the result of the merge will be kept. + +The combined ``coberturamerge.ser`` file is then used to generate the XML report +using the ``cobertura-report`` program. The call to the cobertura-report program +requires some named arguments. + +``--datafila`` + path to the merged .ser file + +``--destination`` + path to put the output files(s) + +``--format`` + file format to write output in: xml or html + +The rest of the supplied arguments consist of the full paths to the +/src/main/java directories of each module within the souce tree. These +directories are needed and should not be forgotten. + +.. _`Cobertura`: http://cobertura.github.io/cobertura/ diff --git a/Source/CTest/cmParseCoberturaCoverage.cxx b/Source/CTest/cmParseCoberturaCoverage.cxx index 0f5daba..6b98056 100644 --- a/Source/CTest/cmParseCoberturaCoverage.cxx +++ b/Source/CTest/cmParseCoberturaCoverage.cxx @@ -12,6 +12,10 @@ public: XMLParser(cmCTest* ctest, cmCTestCoverageHandlerContainer& cont) : CTest(ctest), Coverage(cont) { + this->InSources = false; + this->InSource = false; + this->FilePaths.push_back(this->Coverage.SourceDir); + this->CurFileName = ""; } virtual ~XMLParser() @@ -20,9 +24,44 @@ public: protected: + + virtual void EndElement(const std::string& name) + { + if(name == "source") + { + this->InSource=false; + } + else if (name == "sources") + { + this->InSources=false; + } + } + + virtual void CharacterDataHandler(const char* data, int length) + { + std::string tmp; + tmp.insert(0,data,length); + if (this->InSources && this->InSource) + { + this->FilePaths.push_back(tmp); + cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Adding Source: " + << tmp << std::endl); + } + } + virtual void StartElement(const std::string& name, const char** atts) { - if(name == "class") + std::string FoundSource; + std::string finalpath = ""; + if(name == "source") + { + this->InSource = true; + } + else if(name == "sources") + { + this->InSources = true; + } + else if(name == "class") { int tagCount = 0; while(true) @@ -30,11 +69,19 @@ protected: if(strcmp(atts[tagCount], "filename") == 0) { cmCTestLog(this->CTest, HANDLER_VERBOSE_OUTPUT, "Reading file: " - << atts[tagCount+1] << std::endl); - this->CurFileName = this->Coverage.SourceDir + "/" + - atts[tagCount+1]; + << atts[tagCount+1]<< std::endl); + std::string filename = atts[tagCount+1]; + for(size_t i=0;i < FilePaths.size();i++) + { + finalpath = FilePaths[i] + "/" + filename; + if(cmSystemTools::FileExists(finalpath.c_str())) + { + this->CurFileName = finalpath; + break; + } + } cmsys::ifstream fin(this->CurFileName.c_str()); - if(!fin) + if(this->CurFileName == "" || !fin ) { this->CurFileName = this->Coverage.BinaryDir + "/" + atts[tagCount+1]; @@ -48,7 +95,6 @@ protected: break; } } - std::string line; FileLinesType& curFileLines = this->Coverage.TotalCoverage[this->CurFileName]; @@ -83,7 +129,9 @@ protected: { FileLinesType& curFileLines = this->Coverage.TotalCoverage[this->CurFileName]; - curFileLines[curNumber-1] = curHits; + { + curFileLines[curNumber-1] = curHits; + } break; } ++tagCount; @@ -91,10 +139,11 @@ protected: } } - virtual void EndElement(const std::string&) {} - private: + bool InSources; + bool InSource; + std::vector FilePaths; typedef cmCTestCoverageHandlerContainer::SingleFileCoverageVector FileLinesType; cmCTest* CTest; diff --git a/Source/CTest/cmParseCoberturaCoverage.h b/Source/CTest/cmParseCoberturaCoverage.h index 4204b10..ff5954d 100644 --- a/Source/CTest/cmParseCoberturaCoverage.h +++ b/Source/CTest/cmParseCoberturaCoverage.h @@ -34,6 +34,9 @@ public: cmParseCoberturaCoverage(cmCTestCoverageHandlerContainer& cont, cmCTest* ctest); + bool inSources; + bool inSource; + std::vector filepaths; //! Read the XML produced by running `coverage xml` bool ReadCoverageXML(const char* xmlFile); diff --git a/Tests/CMakeLists.txt b/Tests/CMakeLists.txt index 8d2b7fc..05442a1 100644 --- a/Tests/CMakeLists.txt +++ b/Tests/CMakeLists.txt @@ -2184,6 +2184,24 @@ ${CMake_BINARY_DIR}/bin/cmake -DDIR=dev -P ${CMake_SOURCE_DIR}/Utilities/Release "Process file.*foo.py.*Total LOC:.*13.*Percentage Coverage: 84.62.*" ENVIRONMENT COVFILE=) + # Adding a test case for non-python Cobertura Coverage + configure_file( + "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/DartConfiguration.tcl.in" + "${CMake_BINARY_DIR}/Testing/CoberturaCoverage/DartConfiguration.tcl") + configure_file( + "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/coverage.xml.in" + "${CMake_BINARY_DIR}/Testing/CoberturaCoverage/coverage.xml") + file(COPY "${CMake_SOURCE_DIR}/Tests/CoberturaCoverage/src" + DESTINATION "${CMake_BINARY_DIR}/Testing/CoberturaCoverage") + add_test(NAME CTestCoberturaCoverage + COMMAND cmake -E chdir + ${CMake_BINARY_DIR}/Testing/CoberturaCoverage + $ -T Coverage --debug) + set_tests_properties(CTestCoberturaCoverage PROPERTIES + PASS_REGULAR_EXPRESSION + "Process file.*CoverageTest.java.*Total LOC:.*18.*Percentage Coverage: 72.22.*" + ENVIRONMENT COVFILE=) + function(add_config_tests cfg) set(base "${CMake_BINARY_DIR}/Tests/CTestConfig") diff --git a/Tests/CoberturaCoverage/DartConfiguration.tcl.in b/Tests/CoberturaCoverage/DartConfiguration.tcl.in new file mode 100644 index 0000000..954f59a --- /dev/null +++ b/Tests/CoberturaCoverage/DartConfiguration.tcl.in @@ -0,0 +1,8 @@ +# This file is configured by CMake automatically as DartConfiguration.tcl +# If you choose not to use CMake, this file may be hand configured, by +# filling in the required variables. + + +# Configuration directories and files +SourceDirectory: ${CMake_SOURCE_DIR}/Testing/CoberturaCoverage +BuildDirectory: ${CMake_BINARY_DIR}/Testing/CoberturaCoverage diff --git a/Tests/CoberturaCoverage/coverage.xml.in b/Tests/CoberturaCoverage/coverage.xml.in new file mode 100644 index 0000000..b3f6691 --- /dev/null +++ b/Tests/CoberturaCoverage/coverage.xml.in @@ -0,0 +1,112 @@ + + + + + + ${CMake_BINARY_DIR}/Testing/CoberturaCoverage/src/main/java/ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java b/Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java new file mode 100644 index 0000000..4fb43c6 --- /dev/null +++ b/Tests/CoberturaCoverage/src/main/java/org/cmake/CoverageTest.java @@ -0,0 +1,52 @@ +package org.cmake.Coverage; + +import java.io.Serializable; +import java.util.Map; +import java.util.List; +import java.awt.*; + +public class CoverageTest { + + public static String VarOne = "test1"; + public static String VarTwo = "test2"; + private Integer IntOne = 4; + + public static Boolean equalsVarOne(String inString) { + + if(VarOne.equals(inString)){ + return true; + } + else { + return false; + } + } + + public static boolean equalsVarTwo(String inString){ + + if(VarTwo.equals(inString)){ + return true; + } + else { + return false; + } + } + + private Integer timesIntOne(Integer inVal){ + + return inVal * IntOne; + } + + public static boolean whileLoop(Integer StopInt){ + + Integer i = 0; + while(i < StopInt){ + i=i+1; + } + if (i.equals(5)){ + return true; + } + else { + return false; + } + } +} -- cgit v0.12