summaryrefslogtreecommitdiff
path: root/tools/regression/xsl_reports/xsl/add_expected_results.xsl
blob: 6771f0034f2900523d067a9b17366ac7050421bf (plain)
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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<?xml version="1.0" encoding="utf-8"?>
<!--

Copyright MetaCommunications, Inc. 2003-2004.

Distributed under the Boost Software License, Version 1.0. (See
accompanying file LICENSE_1_0.txt or copy at
http://www.boost.org/LICENSE_1_0.txt)

-->

<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:meta="http://www.meta-comm.com"
    exclude-result-prefixes="meta"
    version="1.0">

    <xsl:import href="common.xsl"/>
  
    <xsl:output method="xml" encoding="utf-8"/>
      
    <xsl:param name="expected_results_file"/>
    <xsl:param name="failures_markup_file"/>
    <xsl:variable name="expected_results" select="document( $expected_results_file )" />
    <xsl:variable name="failures_markup" select="document( $failures_markup_file )" />

    <xsl:template match="/">
        <xsl:apply-templates/>
    </xsl:template>
      
    <xsl:template match="test-log">
        <xsl:variable name="library" select="@library"/>
        <xsl:variable name="test-name" select="@test-name"/>
        <xsl:variable name="toolset" select="@toolset"/>

        <xsl:element name="{local-name()}">
        <xsl:apply-templates select="@*"/>

        <xsl:variable name="actual_result">
            <xsl:choose>
            <!-- Hack: needs to be researched (and removed). See M.Wille's incident. -->
            <xsl:when test="run/@result='succeed' and lib/@result='fail'">
                <xsl:text>success</xsl:text>
            </xsl:when>
            <xsl:when test="./*/@result = 'fail'" >
                <xsl:text>fail</xsl:text>
            </xsl:when>
            <xsl:otherwise>
                <xsl:text>success</xsl:text>
            </xsl:otherwise>
            </xsl:choose>                     
        </xsl:variable>

        <xsl:variable name="expected_results_test_case" select="$expected_results//*/test-result[ @library=$library and ( @test-name=$test-name or @test-name='*' ) and @toolset = $toolset]"/>
        <xsl:variable name="new_failures_markup" select="$failures_markup//library[@name=$library]/mark-expected-failures[ meta:re_match( test/@name, $test-name ) and meta:re_match( toolset/@name, $toolset ) ]"/>
        <xsl:variable name="failures_markup" select="$failures_markup//library[@name=$library]/test[ meta:re_match( @name, $test-name ) ]/mark-failure[ meta:re_match( toolset/@name, $toolset ) ]"/>
        <xsl:variable name="is_new">
            <xsl:choose>
                <xsl:when test="$expected_results_test_case">
                <xsl:text>no</xsl:text>
                </xsl:when>
                <xsl:otherwise>yes</xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="expected_result">
            <xsl:choose>
            <xsl:when test='count( $failures_markup ) &gt; 0 or count( $new_failures_markup ) &gt; 0'>
                <xsl:text>fail</xsl:text>
            </xsl:when>
              
            <xsl:otherwise>
                <xsl:choose>
                <xsl:when test="$expected_results_test_case and $expected_results_test_case/@result = 'fail'">
                    <xsl:text>fail</xsl:text>
                </xsl:when>
                  
                <xsl:otherwise>success</xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="status">
            <xsl:choose>
            <xsl:when test="count( $failures_markup ) &gt; 0 or count( $new_failures_markup ) &gt; 0">
                <xsl:choose>
                <xsl:when test="$expected_result = $actual_result">expected</xsl:when>
                <xsl:otherwise>unexpected</xsl:otherwise>
                </xsl:choose>
            </xsl:when>

            <xsl:otherwise>
                <xsl:choose>
                <xsl:when test="$expected_result = $actual_result">expected</xsl:when>
                <xsl:otherwise>unexpected</xsl:otherwise>
                </xsl:choose>
            </xsl:otherwise>
              
            </xsl:choose>
        </xsl:variable>

        <xsl:variable name="notes">
            <xsl:choose>

            <xsl:when test='count( $failures_markup ) &gt; 0'>
                <xsl:for-each select="$failures_markup/note">
                <xsl:copy-of select="."/>
                </xsl:for-each>
            </xsl:when>

            <xsl:when test='count( $new_failures_markup ) &gt; 0'>
                <xsl:for-each select="$new_failures_markup/note">
                <xsl:copy-of select="."/>
                </xsl:for-each>
            </xsl:when>
              
            </xsl:choose>
        </xsl:variable>

        <xsl:attribute name="result"><xsl:value-of select="$actual_result"/></xsl:attribute>
        <xsl:attribute name="expected-result"><xsl:value-of select="$expected_result"/></xsl:attribute>
        <xsl:attribute name="status"><xsl:value-of select="$status"/></xsl:attribute>
        <xsl:attribute name="is-new"><xsl:value-of select="$is_new"/></xsl:attribute>
        <!--<a><xsl:value-of select="count( $failures_markup )"/></a>-->
        <xsl:element name="notes"><xsl:copy-of select="$notes"/></xsl:element>


        <xsl:apply-templates select="node()" />
        </xsl:element>
    </xsl:template>

    <xsl:template match="*">
        <xsl:element name="{local-name()}">
        <xsl:apply-templates select="@*"/>
        <xsl:apply-templates select="node()" />
        </xsl:element>
    </xsl:template>

    <xsl:template match="@*">
        <xsl:copy-of select="." />
    </xsl:template>

</xsl:stylesheet>