Skip to content
Permalink
Browse files

Added generating Clover xml reports

  • Loading branch information...
Kamil Pyc
Kamil Pyc committed Jun 5, 2015
1 parent 1377a4d commit eba2a55fea6d8a437c475d7e20ee97c8d0d97252
Showing with 106 additions and 1 deletion.
  1. +17 −1 getcov
  2. +89 −0 transform.xslt
18 getcov
@@ -3,7 +3,7 @@
# Copyright 2015 Jonathan M. Reid. See LICENSE.txt

usage() {
echo "usage: getcov [[-s] [-x] [-o output_dir] [-i info_file] [-v]] | [-h]]"
echo "usage: getcov [[-s] [-x] [-c] [-o output_dir] [-i info_file] [-v]] | [-h]]"
}

main() {
@@ -22,6 +22,11 @@ main() {
generate_xml=1
echo "Generate Cobertura XML"
;;
-xc|--xmlclover)
generate_xml=1
generate_xml_clover=1
echo "Generate Clover XML"
;;
-o)
shift
output_dir=$1
@@ -61,6 +66,10 @@ main() {
generate_cobertura_xml
fi

if [ "$generate_xml_clover" = "1" ]; then
generate_clover_xml
fi

generate_html_report

if [ "$show_html" = "1" ]; then
@@ -131,6 +140,13 @@ generate_html_report() {
"${LCOV_PATH}/genhtml" --output-directory . "${LCOV_INFO}"
}

generate_clover_xml () {
if [ "$verbose" = "1" ]; then
echo "XcodeCoverage: Generating Clover XML"
fi
xsltproc "${scripts}/transform.xslt" "coverage.xml" > "clover.xml"
}

show_html_report() {
if [ "$verbose" = "1" ]; then
echo "XcodeCoverage: Opening HTML report"
@@ -0,0 +1,89 @@
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml"/>
<!-- This template processes the root node ("/") -->
<xsl:template match="/">
<coverage>
<xsl:attribute name='generated'>
<xsl:value-of select='/coverage/@timestamp'/>
</xsl:attribute>
<project>
<xsl:attribute name='timestamp'>
<xsl:value-of select='/coverage/@timestamp'/>
</xsl:attribute>
<xsl:apply-templates
select='//classes'/>
<xsl:variable name='ncloc' select='count(current()//line)'/>
<xsl:call-template name='metrics'>
<xsl:with-param name='ncloc'
select="$ncloc"
/>
<xsl:with-param name='files'
select="count(current()//classes)"
/>
<xsl:with-param name='elements'
select='$ncloc'/>
<xsl:with-param name='coveredelements'
select='number($ncloc) - count(current()//line[number(@hits) = 0])'/>
</xsl:call-template>
</project>
</coverage>
</xsl:template>
<xsl:template match="class">
<file>
<xsl:attribute name='name'>
<xsl:value-of select='current()/@filename'/>
</xsl:attribute>
<xsl:for-each select='lines/line'>
<line type='stmt'>
<xsl:attribute name='num'>
<xsl:value-of select='current()/@number'/>
</xsl:attribute>
<xsl:attribute name='count'>
<xsl:value-of select='current()/@hits'/>
</xsl:attribute>
</line>
</xsl:for-each>
<xsl:variable name='ncloc' select='count(current()//line)'/>
<xsl:call-template name='metrics'>
<xsl:with-param name='ncloc'
select="$ncloc"
/>
<xsl:with-param name='files'
select="count(current()//classes)"
/>
<xsl:with-param name='elements'
select='$ncloc'/>
<xsl:with-param name='coveredelements'
select='number($ncloc) - count(current()//line[number(@hits) = 0])'/>
</xsl:call-template>
</file>
</xsl:template>
<xsl:template name='metrics'>
<xsl:param name='elements' select='number(0)'/>
<xsl:param name='coveredelements' select='number(0)'/>
<xsl:param name='files'/>
<xsl:param name='ncloc' select='number(0)'/>
<metrics>
<xsl:attribute name='ncloc'>
<xsl:value-of select='$ncloc'/>
</xsl:attribute>
<xsl:if test='number(coveredelements) != 0'>
<xsl:attribute name='coveredelements'>
<xsl:value-of select='$coveredelements'/>
</xsl:attribute>
</xsl:if>
<xsl:if test='number(elements) != 0'>
<xsl:attribute name='elements'>
<xsl:value-of select='$elements'/>
</xsl:attribute>
</xsl:if>
<xsl:if test='files != 0'>
<xsl:attribute name='files'>
<xsl:value-of select='$files'/>
</xsl:attribute>
</xsl:if>
</metrics>
</xsl:template>
</xsl:stylesheet>

0 comments on commit eba2a55

Please sign in to comment.
You can’t perform that action at this time.