~roger-booth/mysql-proxy/laminator

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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
<!-- $%BEGINLICENSE%$
 Copyright (C) 2008 MySQL AB, 2008 Sun Microsystems, Inc

 This program is free software; you can redistribute it and/or modify
 it under the terms of the GNU General Public License as published by
 the Free Software Foundation; version 2 of the License.

 This program is distributed in the hope that it will be useful,
 but WITHOUT ANY WARRANTY; without even the implied warranty of
 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 GNU General Public License for more details.

 You should have received a copy of the GNU General Public License
 along with this program; if not, write to the Free Software
 Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

 $%ENDLICENSE%$ -->
<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet version="1.0"
                xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    <!--
        jsled@mysql.com, 2008-06-17.  Convert mysql-lb's gtester output into
        junit-style report xml for hudson to consume.
    -->
    <xsl:output method="xml" cdata-section-elements="system-out system-err failure" indent="yes"/>
    <xsl:template match="/gtester/testbinary/testcase">
        <testcase>
            <xsl:attribute name="time">
                <xsl:value-of select="./duration/text()"/>
            </xsl:attribute>
            <xsl:attribute name="classname">
                <xsl:value-of select="concat('com.mysql.proxy.', translate(../@path, '/', '_'))"/>
            </xsl:attribute>
            <!-- translate some names (above and below) to try and get
                 somewhat closer to java-style package names, which hudson
                 keys off of for the ui -->
            <xsl:attribute name="name">
                <xsl:value-of select="translate(@path, '/-', '_')"/>
            </xsl:attribute>
            <xsl:if test="./status[@result='failed']">
                <failure>
                    <xsl:apply-templates select="./error"/>
                </failure>
            </xsl:if>
        </testcase><xsl:text>
</xsl:text>
    </xsl:template>
    <!-- what a convoluted way to say "or". :( -->
    <xsl:template match="/gtester/testbinary/testcase/child::*[self::error or self::message]">
        <xsl:value-of select="./text()"/>
        <xsl:text>
</xsl:text>
    </xsl:template>
    <xsl:template match="text()"/>
    <xsl:template match="/">
        <testsuite errors="0" failures="0" name="com.mysql.proxy.testsuite.All">
            <xsl:attribute name="time">
                <xsl:value-of select="./gtester/testbinary/duration"/>
            </xsl:attribute>
            <xsl:attribute name="tests">
                <xsl:value-of select="count(/gtester/testbinary/testcase)"/>
            </xsl:attribute>
            <xsl:attribute name="failures">
                <xsl:value-of select="count(/gtester/testbinary/testcase/status[@result=&quot;failed&quot;])"/>
            </xsl:attribute>
<xsl:text>
</xsl:text>
            <xsl:apply-templates select="/gtester/testbinary/testcase"/>
            <system-out><xsl:text>
</xsl:text>
                <xsl:apply-templates select="/gtester/testbinary/testcase/message"/>
            </system-out>
            <system-err><xsl:text>
</xsl:text>
                <xsl:apply-templates select="/gtester/testbinary/testcase/error"/>
            </system-err>
        </testsuite>
    </xsl:template>
</xsl:stylesheet>