Salome HOME
Add the test command first version
[tools/sat.git] / src / xsl / test.xsl
1 <?xml version="1.0" encoding="utf-8"?>
2
3 <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
4
5 <xsl:template match="/">
6 <html>
7 <head>
8 <title>Tests of <xsl:value-of select="//product/@name" /></title>
9 <style type="text/css">
10     .def        { font-family: Arial, Verdana, "Times New Roman", Times, serif;}
11     .OK         { background-color:#00FF00; }
12     .KO         { background-color:#FF0000; }
13     .KF         { background-color:#FFA500; }
14     .NA         { background-color:#BBBBBB; }
15     .PASS       { background-color:#00FF00; }
16     .FAILED     { background-color:#F22000; }
17     .TIMEOUT    { background-color:#DFFF00; }
18     .OK2        { color:#00FF00; }
19     .KO2        { color:#F22000; font-weight: bold; }
20     .NA2        { color:#BBBBBB; }
21     .CHECK2     { color:#FFA500; }
22     .ok         { color:#00AA00; }
23     .ko         { color:#AA0000; }
24     .new        { background-color:#FF5500; }
25     .undercontrol { background-color:#AA0000; }
26     .ignored    { color:#A0A0A0; }
27     div.pqlist  { -moz-column-count: 5;
28                   overflow: auto;
29                   max-height: 250px;
30                 }
31     table.pq    { width: 100%;
32                   margin:0px;
33                   padding:0px;
34                   border-collapse: collapse;
35                   empty-cells: show;
36                   border-style: hidden;
37                 }
38     table       { margin:0px;
39                   padding:0px;
40                   border-collapse:collapse;
41                   empty-cells: show;
42                   border: solid 1px;
43                 }
44     td.KO2      { border: solid 1px black; padding: 0px; }
45     td.OK2      { border: solid 1px black; padding: 0px; }
46     td          { border: solid 1px black; padding: 1px; }
47     h2          { text-align: center; }
48     .legend     { font-weight: bold;
49                   text-align: center;
50                 }
51     span.covered { display:-moz-inline-box; display: inline-block;
52                   height:18px;
53                   vertical-align:top;
54                   background: #00df00; 
55                 }
56     span.uncovered { display:-moz-inline-box; display: inline-block;
57                   height:18px;
58                   vertical-align:top;
59                   background: #df0000; 
60                 }
61     span.ignored { display:-moz-inline-box; display: inline-block;
62                   height:18px;
63                   vertical-align:top;
64                   background: #dfff00;
65                 }
66     span.knownfailure { display:-moz-inline-box; display: inline-block;
67                   height:18px;
68                   vertical-align:top;
69                   background: #ffa500;
70                 }
71     span.notApplicable { display:-moz-inline-box; display: inline-block;
72                   height:18px;
73                   vertical-align:top;
74                   background: #bbbbbb;
75                 }
76     span.zero   { color: #A0A0A0; }
77     a.node      { color:#0000FF; text-decoration: none; visited: #FF0000; }
78
79 </style>
80 <script language="JavaScript"><![CDATA[
81       function Toggle(id) {
82         var element = document.getElementById(id);
83
84         if ( element.style.display == "none" )
85           element.style.display = "block";
86         else 
87           element.style.display = "none";
88       }
89
90         function collapseall() {
91           var divlist = document.getElementsByName("mod");
92           for (i = 0; i < divlist.length; i++)
93           {
94               divlist[i].style.display = "none";
95           }
96       }
97
98     ]]></script>
99 </head>
100
101 <body class="def">
102     
103   <xsl:apply-templates select="//product" mode="test" />
104
105   <br/>
106   <br/>
107
108   </body>
109   </html>
110 </xsl:template>
111
112 <xsl:template match="product" mode="test">
113
114   <h3>Tests</h3>
115     
116   <xsl:for-each select="tests/grid">
117     <b>grid <xsl:value-of select="@name" /></b><br/><br/>
118     <a name="test"/>
119     <xsl:apply-templates select="." mode="test-grid" />
120   </xsl:for-each>
121
122 </xsl:template>
123
124 <xsl:template match="grid" mode="test-grid">
125   <table>
126     <!-- Header -->
127     <tr bgcolor="#9acd32">
128       <th width="150">module</th>
129       <th width="100">success</th>
130       <th width="200"></th>
131       <th width="100">total</th>
132       <th width="100">pass</th>
133       <th width="100">failed</th>
134       <th width="100">timeout</th>
135       <th width="100">known failures</th>
136       <th width="100">not run</th>
137       <th width="100">N/A</th>
138       <th width="100">Time</th>
139     </tr>
140         
141     <xsl:for-each select="./module">
142       <xsl:variable name="total" select="count(.//test)"/>
143       <xsl:variable name="failureCount" select="count(.//test[@res='KO'])"/>
144       <xsl:variable name="successCount" select="count(.//test[@res='OK'])"/>
145       <xsl:variable name="timeoutCount" select="count(.//test[@res='TIMEOUT'])"/>
146       <xsl:variable name="knownFailures" select="count(.//test[@res='KF'])"/>
147       <xsl:variable name="notApplicable" select="count(.//test[@res='NA'])"/>
148       <xsl:variable name="ignoreCount" select="$total - $successCount - $failureCount - $knownFailures - $notApplicable"/>
149       <xsl:variable name="successRate" select="$successCount div $total"/>
150
151       <tr>
152         <td><a href="#test" class="node" title="voir">
153           <xsl:attribute name="onclick">javascript:collapseall();Toggle('mod_<xsl:value-of select="../@name"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
154           <xsl:attribute name="id">img_<xsl:value-of select="@name"/></xsl:attribute><xsl:value-of select="@name"/>&#160;</a>
155         </td>
156
157         <td align="right">
158           <xsl:call-template name="display-percent">
159             <xsl:with-param name="value" select="$successRate"/>
160           </xsl:call-template>
161         </td>
162         <td width="210px" align="center">
163           <!-- Progress bar -->
164           <xsl:if test="round($successCount * 200 div $total) != 0">
165             <span class="covered">
166               <xsl:attribute name="style">width:<xsl:value-of select="round($successCount * 200 div $total)"/>px</xsl:attribute>&#160;
167             </span>
168           </xsl:if>
169           <xsl:if test="round($failureCount * 200 div $total) != 0">
170             <span class="uncovered">
171               <xsl:attribute name="style">width:<xsl:value-of select="round($failureCount * 200 div $total)"/>px</xsl:attribute>&#160;
172             </span>
173           </xsl:if>
174           <xsl:if test="round($knownFailures * 200 div $total) != 0">
175             <span class="knownfailure">
176                 <xsl:attribute name="style">width:<xsl:value-of select="round($knownFailures * 200 div $total)"/>px</xsl:attribute>&#160;
177             </span>
178           </xsl:if>
179           <xsl:if test="round($notApplicable * 200 div $total) != 0">
180             <span class="notApplicable">
181                 <xsl:attribute name="style">width:<xsl:value-of select="round($notApplicable * 200 div $total)"/>px</xsl:attribute>&#160;
182             </span>
183           </xsl:if>
184           <xsl:if test="round($ignoreCount * 200 div $total) != 0">
185             <span class="ignored">
186               <xsl:attribute name="style">width:<xsl:value-of select="round($ignoreCount * 200 div $total)"/>px</xsl:attribute>&#160;
187             </span>
188           </xsl:if>
189         </td>
190         <td align="right"><xsl:value-of select="$total" /></td>
191         <td align="right"><xsl:value-of select="$successCount" /></td>
192         <xsl:call-template name="display-count"><xsl:with-param name="value" select="$failureCount"/></xsl:call-template>
193
194         <xsl:call-template name="display-count"><xsl:with-param name="value" select="$timeoutCount"/></xsl:call-template>
195         <xsl:call-template name="display-count"><xsl:with-param name="value" select="$knownFailures"/></xsl:call-template>
196         <xsl:call-template name="display-count"><xsl:with-param name="value" select="$ignoreCount"/></xsl:call-template>
197         <xsl:call-template name="display-count"><xsl:with-param name="value" select="$notApplicable"/></xsl:call-template>
198         <td align="right"><xsl:value-of select="format-number(sum(.//test/@exec_time), '0.0')" /></td>
199       </tr>
200     </xsl:for-each>
201
202     <!-- Summary Row -->
203     <xsl:variable name="GrandTotal" select="count(//test)"/>
204     <xsl:variable name="TotalFailure" select="count(//test[@res='KO'])"/>
205     <xsl:variable name="TotalSuccess" select="count(//test[@res='OK'])"/>
206     <xsl:variable name="TotalTimeout" select="count(//test[@res='TIMEOUT'])"/>
207     <xsl:variable name="TotalKnownFailures" select="count(//test[@res='KF'])"/>
208     <xsl:variable name="TotalNA" select="count(//test[@res='NA'])"/>
209     <xsl:variable name="TotalIgnore" select="$GrandTotal - $TotalSuccess - $TotalFailure - $TotalKnownFailures - $TotalNA"/>
210     <xsl:variable name="TotalSuccessRate" select="$TotalSuccess div $GrandTotal"/>
211
212     <tr bgcolor="#EF9C9C">
213       <td>Total</td>
214       <td align="right">
215         <xsl:call-template name="display-percent">
216           <xsl:with-param name="value" select="$TotalSuccessRate"/>
217         </xsl:call-template>
218       </td>
219       <td width="210px" align="center">
220         <xsl:if test="round($TotalSuccess * 200 div $GrandTotal) != 0">
221           <span class="covered">
222             <xsl:attribute name="style">width:<xsl:value-of select="round($TotalSuccess * 200 div $GrandTotal)"/>px</xsl:attribute>&#160;
223           </span>
224         </xsl:if>
225         <xsl:if test="round($TotalFailure * 200 div $GrandTotal) != 0">
226           <span class="uncovered">
227             <xsl:attribute name="style">width:<xsl:value-of select="round($TotalFailure * 200 div $GrandTotal)"/>px</xsl:attribute>&#160;
228           </span>
229         </xsl:if>
230         <xsl:if test="round($TotalKnownFailures * 200 div $GrandTotal) != 0">
231           <span class="knownfailure">
232             <xsl:attribute name="style">width:<xsl:value-of select="round($TotalKnownFailures * 200 div $GrandTotal)"/>px</xsl:attribute>&#160;
233           </span>
234         </xsl:if>
235         <xsl:if test="round($TotalIgnore * 200 div $GrandTotal) != 0">
236           <span class="ignored">
237             <xsl:attribute name="style">width:<xsl:value-of select="round($TotalIgnore * 200 div $GrandTotal)"/>px</xsl:attribute>&#160;
238           </span>
239         </xsl:if>
240       </td>
241       <td align="right"><xsl:value-of select="$GrandTotal" /></td>
242       <td align="right"><xsl:value-of select="$TotalSuccess" /></td>
243       <td align="right"><xsl:value-of select="$TotalFailure" /></td>
244       <td align="right"><xsl:value-of select="$TotalTimeout" /></td>
245       <td align="right"><xsl:value-of select="$TotalKnownFailures" /></td>
246       <td align="right"><xsl:value-of select="$TotalIgnore" /></td>
247       <td align="right"><xsl:value-of select="$TotalNA" /></td>
248       <td align="right"><xsl:value-of select="format-number(sum(//test/@exec_time), '0.0')" /></td>
249     </tr>
250   </table>
251     
252   <br/>
253   <!-- Show details -->
254   <xsl:for-each select="./module">
255     <xsl:sort select="@name" />
256     <xsl:sort select="@type" />
257
258     <div style="display:none" name="mod"><xsl:attribute name="id">mod_<xsl:value-of select="../@name"/>.<xsl:value-of select="@name"/></xsl:attribute>
259     Tests of module <b><xsl:value-of select="@name"/></b>
260     <table width="100%">
261       <tr bgcolor="#9acd32">
262         <th width="100">type</th>
263         <th>script</th>
264         <th width="100">result</th>
265         <th width="100">time</th>
266       </tr>
267
268       <xsl:for-each select="./type">
269         <xsl:sort select="@name" />
270
271         <tr>
272           <td align="center"><xsl:attribute name="rowspan"><xsl:value-of select="count(./test)+count(.//callback)+1" /></xsl:attribute>
273             <xsl:value-of select="@name" />
274             <br/>(<xsl:value-of select="format-number(sum(./test/@exec_time), '0')" /> s)
275           </td>
276         </tr>
277
278       <xsl:for-each select="./test">
279         <xsl:sort select="@script" />
280
281         <xsl:choose>
282           <xsl:when test="count(./callback) != 0">
283             <tr>
284               <td align="left"><xsl:attribute name="class"><xsl:value-of select="@res" /></xsl:attribute><xsl:value-of select="@script" /></td>
285               <td align="center"><xsl:attribute name="class"><xsl:value-of select="@res" /></xsl:attribute><xsl:value-of select="@res" /></td>
286               <td align="right"><xsl:value-of select="format-number(@exec_time, '0.0')" /></td>
287             </tr>
288             <tr>
289               <td align="left" colspan="3" class="linkification-disabled"><xsl:value-of select="./callback" /></td>
290             </tr>
291           </xsl:when>
292           <xsl:otherwise>
293             <tr>
294               <td align="left"><xsl:value-of select="@script" /></td>
295               <td align="center"><xsl:attribute name="class"><xsl:value-of select="@res" /></xsl:attribute><xsl:value-of select="@res" /></td>
296               <td align="right"><xsl:value-of select="format-number(@exec_time, '0.0')" /></td>
297             </tr>
298           </xsl:otherwise>
299         </xsl:choose>
300           <xsl:if test="count(./amend) != 0">
301             <tr>
302               <td class="ko"><b>Amended</b></td>
303               <td align="left" colspan="3"><xsl:value-of select="./amend" /></td>
304             </tr>
305           </xsl:if>
306       </xsl:for-each>
307       </xsl:for-each>
308     
309     </table>
310     </div>
311   </xsl:for-each>
312
313 </xsl:template>
314
315 <xsl:template name="display-percent">
316     <xsl:param name="value"/>
317     <xsl:value-of select="format-number($value, '00.00 %')"/>
318 </xsl:template>
319
320 <xsl:template name="display-count">
321     <xsl:param name="value"/>
322     <td align="right">
323     <xsl:if test="$value &gt; 0">
324         <xsl:value-of select="$value"/>
325     </xsl:if>
326     <xsl:if test="$value = 0"><span class="zero">0</span></xsl:if>
327     </td>
328 </xsl:template>
329
330 </xsl:stylesheet>