Skip to content

Commit

Permalink
convert back and forth coveragexml formats
Browse files Browse the repository at this point in the history
  • Loading branch information
nilleb committed Jul 30, 2015
1 parent 11249bc commit 702a6d5
Show file tree
Hide file tree
Showing 3 changed files with 4,363 additions and 4,168 deletions.
@@ -0,0 +1,79 @@
<xsl:output method="xml" indent="yes"/>

<xsl:template match="results">
<CoverageDSPriv>
<xsl:for-each select="module">
<Module>
<ModuleName><xsl:value-of select="@name"/></ModuleName>
<BlocksCovered><xsl:value-of select="@blocks_covered"/></BlocksCovered>
<BlocksNotCovered><xsl:value-of select="@blocks_not_covered"/></BlocksNotCovered>
<LinesCovered><xsl:value-of select="@lines_covered"/></LinesCovered>
<LinesPartiallyCovered><xsl:value-of select="@lines_partially_covered"/></LinesPartiallyCovered>
<LinesNotCovered><xsl:value-of select="@lines_not_covered"/></LinesNotCovered>
<xsl:apply-templates/>
<Module>
</xsl:foreach>
</CoverageDSPriv>
</xsl:template>

<xsl:template match="functions">
<NamespaceTable>
<Class>
<Method>
<MethodName><xsl:value-of select="@name"/><xsl:text>()</xsl-text></MethodName>
<BlocksCovered><xsl:value-of select="@blocks_covered"/></BlocksCovered>
<BlocksNotCovered><xsl:value-of select="@blocks_not_covered"/></BlocksNotCovered>
<LinesCovered><xsl:value-of select="@lines_covered"/></LinesCovered>
<LinesPartiallyCovered><xsl:value-of select="@lines_partially_covered"/></LinesPartiallyCovered>
<LinesNotCovered><xsl:value-of select="@lines_not_covered"/></LinesNotCovered>
<xsl:apply-templates/>
</Method>
</Class>
</NamespaceTable>
</xsl:template>

<xsl:template match="ranges">
<Lines>
<SourceFileID><xsl:value-of select="@source_id"/></SourceFileID>
<Coverage>
<xsl:value-of>
<xsl:choose>
<xsl:when test="@covered=yes">0</xsl:when>
<xsl:when test="@covered=partial">1</xsl:when>
<xsl:when test="@covered=no">2</xsl:when>
</xsl:choose>
</xsl:value-of>
</Coverage>
<LnStart><xsl:value-of select="@start_line"></LnStart>
<LnEnd><xsl:value-of select="@end_line"></LnEnd>
<ColStart><xsl:value-of select="@start_column"></ColStart>
<ColEnd><xsl:value-of select="@end_column"></ColEnd>
</Lines>
</xsl:template>

<xsl:template match="CoverageDSPriv">
<results>
<modules>
<xsl:for-each select="Module">
<xsl:element name="module">
<xsl:for-each select="NamespaceTable">
<xsl:for-each select="Class">
<source_files>
<xsl:for-each select="../../../SourceFileNames">
<xsl:element name="source_file">
<xsl:attribute name="id">
<xsl:value-of select="SourceFileID"/>
</xsl:attribute>
<xsl:attribute name="path">
<xsl:value-of select="SourceFileName"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</source_files>
</xsl:for-each>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</modules>
</results>
</xsl:template>
@@ -0,0 +1,116 @@
<xsl:output method="xml" indent="yes"/>

<xsl:template match="CoverageDSPriv">
<results>
<modules>
<xsl:for-each select="Module">
<xsl:element name="module">
<xsl:attribute name="name">
<xsl:value-of select="ModuleName"/>
</xsl:attribute>
<xsl:attribute name="path">
<xsl:value-of select="ModuleName"/>
</xsl:attribute>
<xsl:attribute name="block_coverage">
<xsl:value-of select="BlocksCovered div (BlocksCovered + BlocksNotCovered) * 100"/>
</xsl:attribute>
<xsl:attribute name="line_coverage">
<xsl:value-of select="LinesCovered div (LinesCovered + LinesPartiallyCovered + LinesNotCovered) * 100"/>
</xsl:attribute>
<xsl:attribute name="blocks_covered">
<xsl:value-of select="BlocksCovered"/>
</xsl:attribute>
<xsl:attribute name="blocks_not_covered">
<xsl:value-of select="BlocksNotCovered"/>
</xsl:attribute>
<xsl:attribute name="lines_covered">
<xsl:value-of select="LinesCovered"/>
</xsl:attribute>
<xsl:attribute name="lines_partially_covered">
<xsl:value-of select="LinesPartiallyCovered"/>
</xsl:attribute>
<xsl:attribute name="lines_not_covered">
<xsl:value-of select="LinesNotCovered"/>
</xsl:attribute>
<xsl:for-each select="NamespaceTable">
<xsl:for-each select="Class">
<functions>
<xsl:for-each select="Method">
<xsl:element name="function">
<xsl:attribute name="name">
<xsl:value-of select="substring-before(MethodName, '()')"/>
</xsl:attribute>
<xsl:attribute name="type_name">
<xsl:value-of select="../ClassName"/>
</xsl:attribute>
<xsl:attribute name="block_coverage">
<xsl:value-of select="BlocksCovered div (BlocksCovered + BlocksNotCovered) * 100"/>
</xsl:attribute>
<xsl:attribute name="line_coverage">
<xsl:value-of select="LinesCovered div (LinesCovered + LinesPartiallyCovered + LinesNotCovered) * 100"/>
</xsl:attribute>
<xsl:attribute name="blocks_covered">
<xsl:value-of select="BlocksCovered"/>
</xsl:attribute>
<xsl:attribute name="blocks_not_covered">
<xsl:value-of select="BlocksNotCovered"/>
</xsl:attribute>
<xsl:attribute name="lines_covered">
<xsl:value-of select="LinesCovered"/>
</xsl:attribute>
<xsl:attribute name="lines_partially_covered">
<xsl:value-of select="LinesPartiallyCovered"/>
</xsl:attribute>
<xsl:attribute name="lines_not_covered">
<xsl:value-of select="LinesNotCovered"/>
</xsl:attribute>
<ranges>
<xsl:for-each select="Lines">
<xsl:element name="range">
<xsl:attribute name="source_id">
<xsl:value-of select="SourceFileID"/>
</xsl:attribute>
<xsl:attribute name="covered">
<xsl:choose>
<xsl:when test="Coverage=0">yes</xsl:when>
<xsl:when test="Coverage=1">partial</xsl:when>
<xsl:when test="Coverage=2">no</xsl:when>
</xsl:choose>
</xsl:attribute>
<xsl:attribute name="start_line">
<xsl:value-of select="LnStart"/>
</xsl:attribute>
<xsl:attribute name="start_column">
<xsl:value-of select="ColStart"/>
</xsl:attribute>
<xsl:attribute name="end_line">
<xsl:value-of select="LnEnd"/>
</xsl:attribute>
<xsl:attribute name="end_column">
<xsl:value-of select="ColEnd"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</ranges>
</xsl:element>
</xsl:for-each>
</functions>
<source_files>
<xsl:for-each select="../../../SourceFileNames">
<xsl:element name="source_file">
<xsl:attribute name="id">
<xsl:value-of select="SourceFileID"/>
</xsl:attribute>
<xsl:attribute name="path">
<xsl:value-of select="SourceFileName"/>
</xsl:attribute>
</xsl:element>
</xsl:for-each>
</source_files>
</xsl:for-each>
</xsl:for-each>
</xsl:element>
</xsl:for-each>
</modules>
</results>
</xsl:template>

0 comments on commit 702a6d5

Please sign in to comment.