GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / cruise / grailsCC.xsl
blob487936383c84524f33b9c444eab3584193b4a5da
1 <?xml version="1.0"?>
2 <!DOCTYPE xsl:stylesheet [
3 <!ENTITY space "&#32;">
4 <!ENTITY nbsp "&#160;">
5 <!ENTITY bullet "&#8226;">]>
7 <xsl:stylesheet
8 xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0"
9 xmlns:xslt="http://xml.apache.org/xslt"
11 <xsl:output method="html"/>
13 <!-- collects all task nodes with parent target into the variable $tasklist -->
14 <xsl:variable name="tasklist" select="//task"/>
16 <!-- collects all task nodes from $tasklist with attribute name="Javac" etc. -->
17 <xsl:variable name="javac.tasklist" select="$tasklist[@name='javac']"/>
18 <xsl:variable name="ejbjar.tasklist" select="$tasklist[@name='ejbjar']"/>
19 <xsl:variable name="jar.tasklist" select="$tasklist[@name='jar']"/>
20 <xsl:variable name="war.tasklist" select="$tasklist[@name='war']"/>
22 <!-- count elements in sublists -->
23 <xsl:variable name="dist.count" select="count($jar.tasklist) + count($war.tasklist)"/>
25 <!-- collect all testsuite nodes in build, regardless of depth -->
26 <xsl:variable name="testsuite.list" select="//testsuite"/>
27 <!-- count error nodes directly under testsuite -->
28 <xsl:variable name="testsuite.error.count" select="count($testsuite.list/error)"/>
30 <xsl:variable name="testcase.list" select="$testsuite.list/testcase"/>
31 <xsl:variable name="testcase.error.list" select="$testcase.list/error"/>
32 <xsl:variable name="testcase.failure.list" select="$testcase.list/failure"/>
33 <xsl:variable name="totalErrorsAndFailures" select="count($testcase.error.list) + count($testcase.failure.list)"/>
35 <!-- 1: /build/modifications, 2: /cruisecontrol/modifications -->
36 <xsl:variable name="modification.list" select="//modifications/modification"/>
37 <!-- collects all the modification sets -->
38 <xsl:key name="modificationSet" match="//modifications/modification" use="concat(user,':',comment)"/>
40 <!-- long template for the whole page, this ensures sequence -->
41 <xsl:template match="/">
42 <!-- Header Part -->
44 <xsl:choose>
45 <xsl:when test="//build/@error"> <!-- build tag contains attribute error -->
46 <h1>BUILD FAILED</h1>
47 </xsl:when>
48 <xsl:otherwise>
49 <h1>
50 <xsl:text>BUILD COMPLETE -&space;</xsl:text>
51 <!-- support CruiseControl 1.0 and 2.0 -->
52 <xsl:value-of select="build/label | //info/property[@name='label']/@value"/>
53 </h1>
54 </xsl:otherwise>
55 </xsl:choose>
57 <table>
58 <tr>
59 <th>Date of build</th>
60 <td>
61 <!-- support CruiseControl 1.0 and 2.0 -->
62 <xsl:value-of select="build/today | //info/property[@name='builddate']/@value"/>
63 </td>
64 </tr>
65 <tr>
66 <th>Time to build</th>
67 <td>
68 <xsl:value-of select="//build/@time"/>
69 </td>
70 </tr>
71 <tr>
72 <th>Last changed</th>
73 <td>
74 <xsl:value-of select="//modifications/modification/date"/>
75 </td>
76 </tr>
77 <tr>
78 <th>Last log entry</th>
79 <td>
80 <xsl:value-of select="//modifications/modification/comment"/>
81 </td>
82 </tr>
83 </table>
85 <xsl:if test="//build/@error">
86 <h2>Ant Error Message</h2>
87 <pre>
88 <xsl:value-of select="//build/@error"/>
89 </pre>
90 <pre>
91 <xsl:value-of select="//stacktrace"/>
92 </pre>
93 </xsl:if>
95 <!-- Compilation Messages -->
97 <xsl:variable name="javac.warn.messages" select="$javac.tasklist/message[@priority='warn']"/>
98 <xsl:variable name="ejbjar.warn.messages" select="$ejbjar.tasklist/message[@priority='warn']"/>
99 <xsl:variable name="total.errorMessage.count"
100 select="count($javac.warn.messages) + count($ejbjar.warn.messages)"/>
102 <!-- NOTE: total.errorMessage.count is actually the number of lines of error
103 messages. This accurately represents the number of errors ONLY if the Ant property
104 build.compiler.emacs is set to "true" -->
105 <xsl:if test="$total.errorMessage.count > 0">
106 <h2>
107 <xsl:text>Error-/Warning- Lines:&space;</xsl:text>
108 <xsl:value-of select="$total.errorMessage.count"/>
109 </h2>
111 <pre>
112 <xsl:apply-templates select="$javac.warn.messages"/>
113 </pre>
114 </xsl:if>
116 <!-- Unit Tests -->
117 <xsl:variable name="unit.passed" select="count($testcase.list)-$totalErrorsAndFailures"/>
119 <h2>Unit Tests</h2>
121 <xsl:text>Test cases:&space;</xsl:text>
123 <xsl:value-of select="count($testcase.list)"/>
124 </b>
125 <xsl:text>, passed:&space;</xsl:text>
127 <xsl:value-of select="$unit.passed"/>
128 </b>
129 <xsl:text>, failures:&space;</xsl:text>
131 <xsl:value-of select="count($testcase.failure.list)"/>
132 </b>
133 <xsl:text>, errors:&space;</xsl:text>
135 <xsl:value-of select="count($testcase.error.list)"/>
136 </b>
137 <xsl:text>.</xsl:text>
138 </p>
140 <xsl:call-template name="colorBar">
141 <xsl:with-param name="success.count" select="$unit.passed"/>
142 <xsl:with-param name="failed.count" select="$totalErrorsAndFailures"/>
143 <xsl:with-param name="total.count" select="count($testcase.list)"/>
144 <xsl:with-param name="tableID">utests</xsl:with-param>
145 </xsl:call-template>
147 <xsl:if test="count($testcase.error.list) > 0">
148 <h3>Errors</h3>
149 <ul>
150 <xsl:apply-templates select="$testcase.error.list"/>
151 </ul>
152 </xsl:if>
154 <xsl:if test="count($testcase.failure.list) > 0">
155 <h3>Failures</h3>
156 <ul>
157 <xsl:apply-templates select="$testcase.failure.list"/>
158 </ul>
159 </xsl:if>
161 <xsl:if test="$totalErrorsAndFailures > 0">
162 <h3>
163 <xsl:text>Unit Test Error Details:&space;(</xsl:text>
164 <xsl:value-of select="$totalErrorsAndFailures"/>
165 <xsl:text>)</xsl:text>
166 </h3>
167 <xsl:apply-templates select="//testsuite/testcase[.//error]"/>
168 <xsl:apply-templates select="//testsuite/testcase[.//failure]"/>
169 </xsl:if>
171 <!-- Functional Tests -->
173 <!-- functional testing vars -->
174 <xsl:variable name="cases" select="//summary/testresult"/>
175 <xsl:variable name="steps" select="//summary/testresult/results/step"/>
176 <xsl:variable name="passed" select="$cases[@successful='yes']"/>
177 <xsl:variable name="failed" select="$cases[@successful='no']"/>
179 <h2>Functional Tests</h2>
181 <xsl:text>Szenarios:&space;</xsl:text>
183 <xsl:value-of select="count($cases)"/>
184 </b>
185 <xsl:text>, passed:&space;</xsl:text>
187 <xsl:value-of select="count($passed)"/>
188 </b>
189 <xsl:text>, failed:&space;</xsl:text>
191 <xsl:value-of select="count($failed)"/>
192 </b>
193 <xsl:text>, including&space;</xsl:text>
195 <xsl:value-of select="count($steps)"/>
196 </b>
197 <xsl:text>&space;single steps.</xsl:text>
198 </p>
200 <xsl:call-template name="colorBar">
201 <xsl:with-param name="success.count" select="count($passed)"/>
202 <xsl:with-param name="failed.count" select="count($failed)"/>
203 <xsl:with-param name="total.count" select="count($cases)"/>
204 <xsl:with-param name="tableID">ftests</xsl:with-param>
205 </xsl:call-template>
207 <h2>Modifications</h2>
209 <xsl:value-of select="count($modification.list)"/>
210 <xsl:text>&space;modifications since last build.</xsl:text>
211 </p>
213 <xsl:for-each select="$modification.list[count(.|key('modificationSet',concat(user,':',comment))[1])=1]">
214 <h3>
215 <xsl:value-of select="user"/>
216 <xsl:text>:&space;</xsl:text>
217 <xsl:value-of select="comment"/>
218 <xsl:text>&space;(</xsl:text>
219 <xsl:value-of select="date"/>
220 <xsl:text>)</xsl:text>
221 </h3>
222 <ul>
223 <xsl:apply-templates select="key('modificationSet',concat(user,':',comment))"/>
224 </ul>
225 </xsl:for-each>
228 <xsl:if test="$dist.count > 0">
229 <h2>Deployments</h2>
231 <xsl:value-of select="$dist.count"/>
232 <xsl:text>&space;files deployed by this build.</xsl:text>
233 </p>
235 <ul>
236 <xsl:apply-templates select="$jar.tasklist | $war.tasklist"/>
237 </ul>
238 </xsl:if>
240 </xsl:template>
242 <xsl:template name="colorBar">
243 <xsl:param name="success.count"/>
244 <xsl:param name="failed.count"/>
245 <xsl:param name="total.count"/>
246 <xsl:param name="tableID"/>
248 <table bgcolor="white" cellspacing="0" cellpadding="0">
249 <xsl:attribute name="id">
250 <xsl:value-of select="$tableID"/>
251 </xsl:attribute>
252 <tr>
253 <xsl:if test="$success.count > 0">
254 <td bgcolor="green">
255 <xsl:attribute name="width">
256 <xsl:value-of select="concat($success.count * 100 div $total.count, '%')"/>
257 </xsl:attribute>
258 &nbsp;
259 </td>
260 </xsl:if>
262 <xsl:if test="$failed.count > 0">
263 <td bgcolor="#FFFFA0">
264 <xsl:attribute name="width">
265 <xsl:value-of select="concat($failed.count * 100 div $total.count, '%')"/>
266 </xsl:attribute>
267 &nbsp;
268 </td>
269 </xsl:if>
271 <xsl:if test="($total.count = 0) or ($total.count > ($success.count + $failed.count))">
272 <td>&nbsp;</td>
273 </xsl:if>
274 </tr>
275 </table>
276 </xsl:template>
279 <!-- UnitTest Errors/Failures -->
280 <xsl:template match="error|failure">
281 <li>
282 <xsl:call-template name="colorOddEvenRow"/>
283 <xsl:value-of select="../@name"/>
284 </li>
285 </xsl:template>
287 <!-- UnitTest Errors And Failures Detail Template -->
288 <xsl:template match="//testsuite/testcase">
289 <h4>
290 <xsl:text>Test:&space;</xsl:text>
291 <xsl:value-of select="@name"/>
292 </h4>
295 <xsl:text>Type:</xsl:text>
296 <xsl:value-of select="node()/@type"/>
297 </p>
299 <xsl:text>Message:</xsl:text>
300 <xsl:value-of select="node()/@message"/>
301 </p>
303 <PRE>
304 <xsl:value-of select="node()"/>
305 </PRE>
306 </xsl:template>
308 <!-- Compilation Error Details -->
309 <xsl:template match="message[@priority='warn']">
310 <xsl:value-of select="text()"/>
311 <br/>
312 </xsl:template>
313 <!-- Test Execution Stacktrace -->
314 <xsl:template match="stacktrace">
315 <pre>
316 <xsl:value-of select="text()"/>
317 </pre>
318 </xsl:template>
320 <!-- Modifications template -->
321 <xsl:template match="modification[file/filename]">
322 <!-- CC 2.0 -->
323 <li>
324 <xsl:call-template name="colorOddEvenRow"/>
325 <xsl:call-template name="modificationType">
326 <xsl:with-param name="type" select="file/@action"/>
327 </xsl:call-template>
329 <xsl:value-of select="file/project"/>
330 <xsl:if test="string-length(normalize-space(file/project))">
331 <xsl:text>/</xsl:text>
332 </xsl:if>
333 <xsl:value-of select="file/filename"/>
334 </li>
335 </xsl:template>
337 <xsl:template match="modification">
338 <!-- CC 1.0 -->
339 <li>
340 <xsl:call-template name="colorOddEvenRow"/>
341 <xsl:call-template name="modificationType">
342 <xsl:with-param name="type" select="@type"/>
343 </xsl:call-template>
345 <xsl:value-of select="filename"/>
346 </li>
347 </xsl:template>
349 <xsl:template name="modificationType">
350 <xsl:param name="type"/>
352 <span class="modifificationType">
353 <xsl:choose>
354 <xsl:when test="$type='modified'">&gt;</xsl:when>
355 <xsl:when test="$type='added'">+</xsl:when>
356 <xsl:when test="$type='deleted'">-</xsl:when>
357 <xsl:otherwise><xsl:value-of select="$type"/></xsl:otherwise>
358 </xsl:choose>
359 </span>
361 &nbsp;
362 </xsl:template>
364 <!-- jar and war template -->
365 <xsl:template match="task[translate(string(@name),'jJwW','')='ar']">
366 <li>
367 <xsl:call-template name="colorOddEvenRow"/>
368 <xsl:value-of select="message"/>
369 </li>
370 </xsl:template>
372 <xsl:template name="colorOddEvenRow">
373 <xsl:attribute name="class">
374 <xsl:choose>
375 <xsl:when test="position() mod 2 = 0">evenrow</xsl:when>
376 <xsl:otherwise>oddrow</xsl:otherwise>
377 </xsl:choose>
378 </xsl:attribute>
379 </xsl:template>
380 </xsl:stylesheet>