File: Test.xsl

package info (click to toggle)
dart 0.20020805-2
  • links: PTS
  • area: main
  • in suites: sarge
  • size: 3,688 kB
  • ctags: 172
  • sloc: tcl: 4,979; perl: 213; makefile: 61; cpp: 42; sh: 2
file content (290 lines) | stat: -rw-r--r-- 12,281 bytes parent folder | download
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
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
    version="1.0"
    xmlns:lxslt="http://xml.apache.org/xslt"
    xmlns:redirect="org.apache.xalan.lib.Redirect"
    extension-element-prefixes="redirect">

  <!--
       Use DashboardStamp as a parameter, default to most recent
       The proper flags to Xalan are in the form -PARAM DashboardStamp "string('foo')"
       -->
  <xsl:param name="DashboardStamp" select="string('MostRecentResults-Nightly')"/>
  <xsl:param name="TestDocDir">.</xsl:param>
  <xsl:variable name="DashboardDir" select="concat('../../../../Dashboard/', $DashboardStamp)"/>
  <xsl:include href="DashboardConfig.xsl"/>
  <!--
	Set the output method to html.  This style sheet outputs both html
	and possibly base64 files.  The html output method is incorrect for
	the base64 files but it does not seem to impact the conversions.
	If the output method is xml, then a standard xml header is created and
	we cannot decode the base64 file. 
	-->	
  <xsl:output method="html"/> 

  <xsl:template match="/">
    <xsl:call-template name="Summary"/>
    <xsl:call-template name="DashboardHeader">
      <xsl:with-param name="Title">Test Log <xsl:value-of select="/Site/@Name"/> -- <xsl:value-of select="/Site/@BuildName"/></xsl:with-param>
      <xsl:with-param name="IconDir">../../../../Icons</xsl:with-param>
      <xsl:with-param name="DashboardDir" select="$DashboardDir"/>
    </xsl:call-template>
    <h2>Testing started on <xsl:value-of select="Site/Testing/StartDateTime"/></h2>
    <p>
      <b>Site Name: </b> <xsl:value-of select="/Site/@Name"/>
    </p>
    <p>
      <b>Build Name: </b> <xsl:value-of select="/Site/@BuildName"/>
    </p>
    <br/>
    <h3>
      <xsl:value-of select="count(Site/Testing/Test[@Status='passed'])"/> passed, 
      <xsl:value-of select="count(Site/Testing/Test[@Status='failed'])"/> failed,
      <xsl:value-of select="count(Site/Testing/Test[@Status='notrun'])"/> not run
    </h3>
    <br/>
    <table cellspacing="0">
      <tr>
        <th>Name</th>
        <th>Status</th>
        <th>Detail</th>
      </tr>
      <xsl:for-each select="Site/Testing/Test">
        <xsl:sort select="@Status='notrun'" order="descending"/>
        <xsl:sort select="@Status='failed'" order="descending"/>
        <xsl:sort select="@Status='passed'" order="descending"/>
        <xsl:sort select="Name" order="ascending"/>
        <xsl:if test="@Status='notrun'">
         <tr>
          <xsl:if test="position() mod 2 = 0">
            <xsl:attribute name="class">tr-even</xsl:attribute>
          </xsl:if>
          <td>
            <a>
              <xsl:attribute name="href">
                <xsl:call-template name="TranslateTestName">
                  <xsl:with-param name="Prefix"><xsl:value-of select="$DashboardDir"/>/TestDetail/</xsl:with-param>
                  <xsl:with-param name="TestName" select="FullName"/>
                  <xsl:with-param name="Postfix">.html</xsl:with-param>
                </xsl:call-template>
              </xsl:attribute>
              <xsl:value-of select="Name"/>
            </a>
          </td>
          <td>
            <xsl:attribute name="class">error</xsl:attribute>
            Not Run
          </td>
          <td></td>
         </tr>
        </xsl:if>
        <xsl:if test="@Status='failed'">
         <tr>
          <xsl:if test="position() mod 2 = 0">
            <xsl:attribute name="class">tr-even</xsl:attribute>
          </xsl:if>
          <td>
            <a>
              <xsl:attribute name="href">
                <xsl:call-template name="TranslateTestName">
                  <xsl:with-param name="Prefix"><xsl:value-of select="$DashboardDir"/>/TestDetail/</xsl:with-param>
                  <xsl:with-param name="TestName" select="FullName"/>
                  <xsl:with-param name="Postfix">.html</xsl:with-param>
                </xsl:call-template>
              </xsl:attribute><xsl:value-of select="Name"/>
            </a>
          </td>
          <td>
            <xsl:attribute name="class">warning</xsl:attribute>
            <a>
              <xsl:attribute name="href">
                <xsl:call-template name="TranslateTestName">
                  <xsl:with-param name="Prefix">Results/</xsl:with-param>
                  <xsl:with-param name="TestName" select="FullName"/>
                  <xsl:with-param name="Postfix">.html</xsl:with-param>
                </xsl:call-template>
              </xsl:attribute>
                Failed
            </a>
          </td>
          <td>
            <xsl:choose>
               <xsl:when test="Results/NamedMeasurement[@name='Completion Status'] = 'Timeout'">
                   Timeout
               </xsl:when>
               <xsl:when test="Results/NamedMeasurement[@name='Exit Code']">
                <xsl:value-of select="Results/NamedMeasurement[@name='Exit Code']"/>
               </xsl:when>
            </xsl:choose>
          </td>
         </tr>
        </xsl:if>
        <xsl:if test="@Status='passed'">
         <tr>
          <xsl:if test="position() mod 2 = 0">
            <xsl:attribute name="class">tr-even</xsl:attribute>
          </xsl:if>
          <td>
            <a>
              <xsl:attribute name="href">
                <xsl:call-template name="TranslateTestName">
                  <xsl:with-param name="Prefix"><xsl:value-of select="$DashboardDir"/>/TestDetail/</xsl:with-param>
                  <xsl:with-param name="TestName" select="FullName"/>
                  <xsl:with-param name="Postfix">.html</xsl:with-param>
                </xsl:call-template>
              </xsl:attribute>
              <xsl:value-of select="Name"/>
            </a>
          </td>
          <td>
            <xsl:attribute name="class">pass</xsl:attribute>
            <a>
              <xsl:attribute name="href">
                <xsl:call-template name="TranslateTestName">
                  <xsl:with-param name="Prefix">Results/</xsl:with-param>
                  <xsl:with-param name="TestName" select="FullName"/>
                  <xsl:with-param name="Postfix">.html</xsl:with-param>
                </xsl:call-template>
              </xsl:attribute>
                Passed
            </a>
          </td>
          <td></td>
         </tr>
        </xsl:if>
      </xsl:for-each>
    </table>
    
    <xsl:for-each select="//Testing/Test">
      <xsl:call-template name="Test"/>
    </xsl:for-each>

    <xsl:call-template name="DashboardFooter">
      <xsl:with-param name="IconDir">../../../../Icons</xsl:with-param>
    </xsl:call-template>

  </xsl:template>
    
  <xsl:template name="Test">
      <redirect:write select="concat(string('{$TestDocDir}'), '/Results/', translate ( FullName, '/.', '__' ) , '.html' )" file="dan.html">
      <xsl:call-template name="DashboardHeader">
        <xsl:with-param name="Title">Test results for <xsl:value-of select="Name"/></xsl:with-param>
        <xsl:with-param name="IconDir">../../../../../Icons</xsl:with-param>
        <xsl:with-param name="DashboardDir">../<xsl:value-of select="$DashboardDir"/></xsl:with-param>
      </xsl:call-template>
      <p>
        <b>Site Name: </b> <xsl:value-of select="/Site/@Name"/>
      </p>
      <p>
        <b>Build Name: </b> <xsl:value-of select="/Site/@BuildName"/>
      </p>
      <a>
        <xsl:attribute name="href">
          <xsl:call-template name="TranslateTestName">
            <xsl:with-param name="Prefix">../<xsl:value-of select="$DashboardDir"/>/TestDetail/</xsl:with-param>
            <xsl:with-param name="TestName" select="FullName"/>
            <xsl:with-param name="Postfix">.html</xsl:with-param>
          </xsl:call-template>
        </xsl:attribute>
        <xsl:value-of select="Name"/> 
      </a>
      <xsl:choose>
        <xsl:when test="contains('failed',@Status)">
          <font>
            <xsl:attribute name="color"><xsl:value-of select="$WarningColor"/></xsl:attribute>
            Failed
          </font>
        </xsl:when>
        <xsl:when test="contains('passed',@Status)">
          <font>
            <xsl:attribute name="color"><xsl:value-of select="$NormalColor"/></xsl:attribute>
            Passed
          </font>
        </xsl:when>
      </xsl:choose>
	
      <br/><br/><br/>
      <table>
        <xsl:for-each select="Results/NamedMeasurement">
	  <xsl:sort select="@type"/>
	  <xsl:sort select="@name"/>
          <xsl:call-template name="NamedMeasurements"/>
        </xsl:for-each>
      </table>
      <br/><br/><br/>
      <b>Test output</b>
      <pre>
        <xsl:value-of select="Results/Measurement/Value" disable-output-escaping="yes"/>
      </pre>
      <xsl:call-template name="DashboardFooter">
	<xsl:with-param name="IconDir">../../../../../Icons</xsl:with-param>
      </xsl:call-template>
    </redirect:write>
  </xsl:template>
    
<xsl:template name="NamedMeasurements">
   <tr>
     <th><xsl:attribute name="class">measurement</xsl:attribute><xsl:value-of select="@name"/></th>
     <td>
       <xsl:choose>
	  <xsl:when test="contains(@type,'numeric') or contains(@type,'text/string')">
	     <xsl:value-of select="Value"/>
	  </xsl:when>

	  <xsl:when test="contains(@type,'link/url')">
	     <a><xsl:attribute name="href"><xsl:value-of select="Value"/></xsl:attribute><xsl:value-of select="Value"/></a>
	  </xsl:when>

	  <xsl:when test="contains(@type,'link/image')">
	     <img><xsl:attribute name="src"><xsl:value-of select="Value"/></xsl:attribute><xsl:value-of select="Value"/></img>
	  </xsl:when>

	  <xsl:when test="contains(@type,'image/png') and contains(@encoding,'base64')">
             <redirect:write select="concat(string('{$TestDocDir}'), '/Results/', translate ( ../../FullName, '/.', '__' ) , translate(@name, '/. ', '___') , '.png.base64' )" file="dan.html">
  	       <xsl:value-of select="Value"/>
	     </redirect:write>
	     <img><xsl:attribute name="src"><xsl:value-of select="concat(translate ( ../../FullName, '/.', '__' ) , translate(@name, '/. ', '___') , '.png' )"/></xsl:attribute></img>
	  </xsl:when>
	  <xsl:when test="contains(@type,'image/jpeg') and contains(@encoding,'base64')">
             <redirect:write select="concat(string('{$TestDocDir}'), '/Results/', translate ( ../../FullName, '/.', '__' ) , translate(@name, '/. ', '___') , '.jpg.base64' )" file="dan.html">
  	       <xsl:value-of select="Value"/>
	     </redirect:write>
	     <img><xsl:attribute name="src"><xsl:value-of select="concat(translate ( ../../FullName, '/.', '__' ) , translate(@name, '/. ', '___') , '.jpg' )"/></xsl:attribute></img>
	  </xsl:when>
       </xsl:choose>	
     </td>
   </tr>
</xsl:template>

<xsl:template name="Summary">
  <redirect:write select="concat(string('{$TestDocDir}'), '/TestSummary.xml' )">
    <Testing>
      <SiteName><xsl:value-of select="Site/@Name"/></SiteName>
      <BuildName><xsl:value-of select="Site/@BuildName"/></BuildName>
      <BuildStamp><xsl:value-of select="Site/@BuildStamp"/></BuildStamp>
      <StartDateTime><xsl:value-of select="Site/Testing/StartDateTime"/></StartDateTime>
      
      <PassedCount><xsl:value-of select="count(Site/Testing/Test[@Status='passed'])"/></PassedCount>
      <FailedCount><xsl:value-of select="count(Site/Testing/Test[@Status='failed'])"/></FailedCount>
      <NotRunCount><xsl:value-of select="count(Site/Testing/Test[@Status='notrun'])"/></NotRunCount>
      <EndDateTime><xsl:value-of select="Site/Testing/EndDateTime"/></EndDateTime>
      <Tests>
        <xsl:for-each select="Site/Testing/Test">
            <Test>
              <FullName><xsl:value-of select="FullName"/></FullName>
              <Status><xsl:value-of select="@Status"/></Status>
              <xsl:if test="Results/NamedMeasurement[@name='Completion Status']">
                 <CompletionStatus><xsl:value-of select="Results/NamedMeasurement[@name='Completion Status']"/></CompletionStatus>
              </xsl:if>
              <xsl:if test="Results/NamedMeasurement[@name='Exit Code']">
                 <ExitCode><xsl:value-of select="Results/NamedMeasurement[@name='Exit Code']"/></ExitCode>
              </xsl:if>
            </Test>
        </xsl:for-each>
      </Tests>
    </Testing>
  </redirect:write>
</xsl:template>

</xsl:stylesheet>