summaryrefslogtreecommitdiff
path: root/tools/regression/xsl_reports/xsl/v2/add_expected_results.xsl
blob: b519a7754fff9ee8bea39cc1f79632e173e90a5e (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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
<?xml version="1.0" encoding="utf-8"?>
<!--

Copyright MetaCommunications, Inc. 2003-2007.

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:func="http://exslt.org/functions"
    xmlns:meta="http://www.meta-comm.com"
    extension-element-prefixes="func"
    exclude-result-prefixes="func 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:param name="source"/>
    <xsl:variable name="expected_results" select="document( $expected_results_file )" />

    <func:function name="meta:is_test_log_complete">
        <xsl:param name="test_log"/>
        <xsl:variable name="type" select="$test_log/@test-type"/>
        <func:result>
            <xsl:choose>
                <xsl:when test="$type='compile' or $type='compile_fail'  or $test_log/compile/@result='fail' ">
                    <xsl:value-of select="count( $test_log/compile ) = 1 and count( $test_log/link) = 0 and count( $test_log/run) = 0"/>
                </xsl:when>
                <xsl:when test="$type='link' or $type='link_fail' or $type='' or $type='lib' or $test_log/link/@result='fail'">
                    <xsl:value-of select="count( $test_log/compile) = 1  and count( $test_log/link) = 1 and count( $test_log/run) = 0"/></xsl:when>
                <xsl:when test="$type='run' or $type='run_fail' or $type='run_pyd' or $type='run_mpi'">
                    <xsl:value-of select="count( $test_log/compile) = 1  and count( $test_log/link)  = 1 and count($test_log/run) = 1 "/>
                </xsl:when>
                <xsl:otherwise> 
                    <xsl:message terminate="yes">
                        Unknown test type "<xsl:value-of select="$type"/>"
                    </xsl:message>
                </xsl:otherwise>
            </xsl:choose>
        </func:result>            
    </func:function>


    <xsl:key name = "trk" match = "test-result" use = "concat( ../../@name, '-', ../@name, '-', @test-name )" />
    <xsl:key name = "tak" match = "toolset-alias" use = "@name" />

    <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="test_log" select="."/>
        <xsl:variable name="library" select="@library"/>
        <xsl:variable name="test-name" select="@test-name"/>
        <xsl:variable name="toolset" select="@toolset"/>

        <xsl:variable name="is_complete" select="meta:is_test_log_complete( $test_log )"/>

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

            <xsl:variable name="has_failures" select="./*/@result = 'fail'"/>
            <xsl:variable name="actual_result">
                <xsl:choose>
                    <xsl:when test="$has_failures or not( $is_complete )" >
                        <xsl:text>fail</xsl:text>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:text>success</xsl:text>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            
            <!-- 
                 Select expected_results context 
                 See http://clover.slavic.pitt.edu/~repertorium/plectogram/keys/keys.html for a good explanation.
                 
                 Briefly, for-each doesn't iterate through expected_results, it just selects expected result
                 as current context to make "key" function work.
                 -->

            <xsl:for-each select="$expected_results">

                <xsl:variable name="main_toolset" select="key( 'tak', $toolset )/../@name" />
                <xsl:variable name="toolset_name">
                    <xsl:choose>
                        <xsl:when test="$main_toolset"><xsl:value-of select="$main_toolset"/></xsl:when>
                        <xsl:otherwise><xsl:value-of select="$toolset"/></xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                <xsl:variable name="expected_results_test_case" select="key( 'trk', concat( $toolset_name, '-', $library, '-', $test-name ) )"/>
                <xsl:variable name="test_case_markup"           select="$failures_markup//library[@name=$library]/test[ meta:re_match( @name, $test-name ) ]"/>
                <xsl:variable name="test_failures_markup"       select="$test_case_markup/mark-failure/toolset[ meta:re_match( @name, $toolset ) ]/.."/>
                <xsl:variable name="test_failures_markup2"      select="$failures_markup//library[@name=$library]/mark-expected-failures/test[ meta:re_match( @name, $test-name ) ]/../toolset[ meta:re_match( @name, $toolset ) ]/.."/>

                <xsl:variable name="category">
                    <xsl:choose>
                        <xsl:when test="$test_case_markup/@category">
                            <xsl:value-of select="$test_case_markup/@category"/>
                        </xsl:when>
                        <xsl:otherwise>0</xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                
                <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="has_explicit_markup" select="count( $test_failures_markup ) > 0 or count( $test_failures_markup2 ) > 0"/>
                    
                <xsl:variable name="expected_result">
                    <xsl:choose>
                        <xsl:when test="$has_explicit_markup">
                            <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="$expected_result = $actual_result">expected</xsl:when>
                        <xsl:otherwise>unexpected</xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>

                <xsl:variable name="unexpected_success" select="$status = 'unexpected' and $actual_result = 'success'"/>
            
                <xsl:variable name="expected_reason">
                    <xsl:choose>
                        <xsl:when test="$test_failures_markup/@reason">
                            <xsl:value-of select="$test_failures_markup/@reason"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$test_failures_markup2/@reason"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:variable>


                <xsl:variable name="notes">
                    
                    <xsl:if test="$unexpected_success and $has_explicit_markup">
                        <note>
                            <span class="auto-note">
                                This test case was explicitly marked up in 
                                <a href="http://svn.boost.org/svn/boost/{$source}/status/explicit-failures-markup.xml">
                                    status/explicit-failures-markup.xml</a> file in the Boost SVN as "expected to fail",
                                but is passing. Please consult the notes/output below for more details.
                            </span>
                        </note>
                    </xsl:if>
                    
                    <xsl:if test="$has_explicit_markup and count( $test_failures_markup2/note ) = 0 and count( $test_failures_markup/note ) = 0">
                        <xsl:choose>
                            <xsl:when test="$unexpected_success">
                                <note>
                                    <span class="auto-note">
                                        No explanation was provided for this markup. Please contact the library 
                                        author(s)/maintainer(s) for more details.
                                    </span>
                                </note>
                            </xsl:when>
                            <xsl:otherwise>
                                <note>
                                    <span class="auto-note">
                                        This failure was explicitly marked as expected in 
                                        <a href="http://svn.boost.org/svn/boost/{$source}/status/explicit-failures-markup.xml">
                                            status/explicit-failures-markup.xml</a> file in the Boost SVN. 
                                        Please contact the library author(s)/maintainer(s) for the explanation of this markup.
                                    </span>
                                </note>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:if>
                    
                    <xsl:if test="count( $test_failures_markup ) > 0">
                        <xsl:for-each select="$test_failures_markup/note">
                            <xsl:copy-of select="."/>
                        </xsl:for-each>
                    </xsl:if>
                    
                    <xsl:if test="count( $test_failures_markup2 ) > 0">
                        <xsl:for-each select="$test_failures_markup2/note">
                            <xsl:copy-of select="."/>
                        </xsl:for-each>
                    </xsl:if>
                    
                    
                    <xsl:if test="$expected_results_test_case and $expected_results_test_case/@result = 'fail'">
                        <xsl:choose>
                            <xsl:when test="$unexpected_success">
                                <note>
                                    <span class="auto-note">
                                        This test case used to fail in the reference ("last-known-good") release.
                                    </span>
                                </note>
                            </xsl:when>
                            <xsl:otherwise>
                                <note>
                                    <span class="auto-note">
                                        This failure was present in the reference ("last-known-good") release.
                                    </span>
                                </note>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:if>

                    <xsl:if test="not( $is_complete ) and not( $has_failures )">
                        <note>
                            <span class="internal-error-note">
                                <b>[Reporting Tools Internal Error]</b> This test case's XML is missing one or more log entries
                                of the regression run's steps associated with the test case's type ("<xsl:value-of select="$test_log/@test-type"/>").
                                Please <a href="mailto:mailto:boost-testing@lists.boost.org">contact reporting tools 
                                maintainers</a> about this problem.
                            </span>
                        </note>
                    </xsl:if>
                </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="expected-reason"><xsl:value-of select="$expected_reason"/></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>
                <xsl:attribute name="category"><xsl:value-of select="$category"/></xsl:attribute>
                <xsl:element name="notes"><xsl:copy-of select="$notes"/></xsl:element>
                
                <xsl:apply-templates select="$test_log/node()" />
            </xsl:for-each>
        </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>