File: checkstyle2junit.xslt

package info (click to toggle)
apparmor 4.1.7-1
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 29,908 kB
  • sloc: ansic: 24,959; python: 24,916; cpp: 9,143; sh: 8,175; yacc: 2,061; makefile: 1,908; lex: 1,215; pascal: 1,147; perl: 1,033; ruby: 365; lisp: 282; exp: 250; java: 212; xml: 159
file content (44 lines) | stat: -rw-r--r-- 1,356 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:output encoding="UTF-8" method="xml"></xsl:output>

  <xsl:template match="/">
    <testsuite>
      <xsl:attribute name="tests">
        <xsl:value-of select="count(.//file)" />
      </xsl:attribute>
      <xsl:attribute name="failures">
        <xsl:value-of select="count(.//error)" />
      </xsl:attribute>
      <xsl:for-each select="//checkstyle">
        <xsl:apply-templates />
      </xsl:for-each>
    </testsuite>
  </xsl:template>

  <xsl:template match="file">
    <testcase>
      <xsl:attribute name="classname">
        <xsl:value-of select="@name" />
      </xsl:attribute>
      <xsl:attribute name="name">
        <xsl:value-of select="@name" />
      </xsl:attribute>
      <xsl:apply-templates select="node()" />
    </testcase>
  </xsl:template>

  <xsl:template match="error">
    <failure>
      <xsl:attribute name="type">
        <xsl:value-of select="@source" />
      </xsl:attribute>
      <xsl:text>Line </xsl:text>
      <xsl:value-of select="@line" />
      <xsl:text>: </xsl:text>
      <xsl:value-of select="@message" />
      <xsl:text> See https://www.shellcheck.net/wiki/</xsl:text>
      <xsl:value-of select="substring(@source, '12')" />
    </failure>
  </xsl:template>
</xsl:stylesheet>