Salome HOME
fix automatic switch '.sh' to '.bat' for script windows file
[tools/sat.git] / src / xsl / test_history.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 }
78
79 </style>
80 <script language="JavaScript"><![CDATA[
81       function Toggle(id) {
82         collapsealltext();
83         var element = document.getElementById(id);
84
85         if ( element.style.display == "none" )
86           element.style.display = "block";
87         else 
88           element.style.display = "none";
89       }
90
91         function collapseall() {
92           var divlist = document.getElementsByName("mod");
93           for (i = 0; i < divlist.length; i++)
94           {
95               divlist[i].style.display = "none";
96           }
97           }
98         function collapsealltext() {
99           var divlist = document.getElementsByName("text");
100           for (i = 0; i < divlist.length; i++)
101           {
102               divlist[i].style.display = "none";
103           }          
104       }
105
106     ]]></script>
107 </head>
108
109 <body class="def">
110     
111   <xsl:apply-templates select="//product" mode="test" />
112
113   <br/>
114   <br/>
115
116   </body>
117   </html>
118 </xsl:template>
119
120 <xsl:template match="product" mode="test">
121
122   <h3>Tests</h3>
123     
124   <xsl:for-each select="tests/testbase">
125     <b>test base <xsl:value-of select="@name" /></b><br/><br/>
126     <a name="test"/>
127     <xsl:apply-templates select="." mode="test-base" />
128   </xsl:for-each>
129
130 </xsl:template>
131
132 <xsl:template match="testbase" mode="test-base">
133   <table>
134     <!-- Header -->
135     <tr bgcolor="#9acd32">
136       <th width="150">grid</th>
137       <th width="100">success</th>
138       <th width="200"></th>
139       <th width="100">total</th>
140       <th width="100">pass</th>
141       <th width="100">failed</th>
142       <th width="100">timeout</th>
143       <th width="100">known failures</th>
144       <th width="100">not run</th>
145       <th width="100">N/A</th>
146       <th width="100">Time</th>
147     </tr>
148         
149     <xsl:for-each select="./grid">
150     <xsl:if test="@executed_last_time='yes'">
151      
152       <xsl:variable name="total" select="count(.//test)"/>
153       <xsl:variable name="failureCount" select="count(.//test[@res='KO'])"/>
154       <xsl:variable name="successCount" select="count(.//test[@res='OK'])"/>
155       <xsl:variable name="timeoutCount" select="count(.//test[@res='TIMEOUT'])"/>
156       <xsl:variable name="knownFailures" select="count(.//test[@res='KF'])"/>
157       <xsl:variable name="notApplicable" select="count(.//test[@res='NA'])"/>
158       <xsl:variable name="ignoreCount" select="$total - $successCount - $failureCount - $knownFailures - $notApplicable"/>
159       <xsl:variable name="successRate" select="$successCount div $total"/>
160
161       <tr>
162         <td><a href="#test" class="node" title="voir">
163           <xsl:attribute name="onclick">javascript:collapseall();Toggle('mod_<xsl:value-of select="../@name"/>.<xsl:value-of select="@name"/>');</xsl:attribute>
164           <xsl:attribute name="id">img_<xsl:value-of select="@name"/></xsl:attribute><xsl:value-of select="@name"/>&#160;</a>
165         </td>
166
167         <td align="right">
168           <xsl:call-template name="display-percent">
169             <xsl:with-param name="value" select="$successRate"/>
170           </xsl:call-template>
171         </td>
172         <td width="210px" align="center">
173           <!-- Progress bar -->
174           <xsl:if test="round($successCount * 200 div $total) != 0">
175             <span class="covered">
176               <xsl:attribute name="style">width:<xsl:value-of select="round($successCount * 200 div $total)"/>px</xsl:attribute>&#160;
177             </span>
178           </xsl:if>
179           <xsl:if test="round($failureCount * 200 div $total) != 0">
180             <span class="uncovered">
181               <xsl:attribute name="style">width:<xsl:value-of select="round($failureCount * 200 div $total)"/>px</xsl:attribute>&#160;
182             </span>
183           </xsl:if>
184           <xsl:if test="round($knownFailures * 200 div $total) != 0">
185             <span class="knownfailure">
186                 <xsl:attribute name="style">width:<xsl:value-of select="round($knownFailures * 200 div $total)"/>px</xsl:attribute>&#160;
187             </span>
188           </xsl:if>
189           <xsl:if test="round($notApplicable * 200 div $total) != 0">
190             <span class="notApplicable">
191                 <xsl:attribute name="style">width:<xsl:value-of select="round($notApplicable * 200 div $total)"/>px</xsl:attribute>&#160;
192             </span>
193           </xsl:if>
194           <xsl:if test="round($ignoreCount * 200 div $total) != 0">
195             <span class="ignored">
196               <xsl:attribute name="style">width:<xsl:value-of select="round($ignoreCount * 200 div $total)"/>px</xsl:attribute>&#160;
197             </span>
198           </xsl:if>
199         </td>
200         <td align="right"><xsl:value-of select="$total" /></td>
201         <td align="right"><xsl:value-of select="$successCount" /></td>
202         <xsl:call-template name="display-count"><xsl:with-param name="value" select="$failureCount"/></xsl:call-template>
203
204         <xsl:call-template name="display-count"><xsl:with-param name="value" select="$timeoutCount"/></xsl:call-template>
205         <xsl:call-template name="display-count"><xsl:with-param name="value" select="$knownFailures"/></xsl:call-template>
206         <xsl:call-template name="display-count"><xsl:with-param name="value" select="$ignoreCount"/></xsl:call-template>
207         <xsl:call-template name="display-count"><xsl:with-param name="value" select="$notApplicable"/></xsl:call-template>
208         <td align="right"><xsl:value-of select="format-number(sum(.//test/@exec_time), '0.0')" /></td>
209       </tr>
210     </xsl:if>
211     </xsl:for-each>
212     <!-- Summary Row -->
213     <xsl:variable name="GrandTotal" select="number(../testbase/@total)"/>
214     <xsl:variable name="TotalFailure" select="count(//test[@res='KO'])"/>
215     <xsl:variable name="TotalSuccess" select="count(//test[@res='OK'])"/>
216     <xsl:variable name="TotalTimeout" select="count(//test[@res='TIMEOUT'])"/>
217     <xsl:variable name="TotalKnownFailures" select="count(//test[@res='KF'])"/>
218     <xsl:variable name="TotalNA" select="count(//test[@res='NA'])"/>
219     <xsl:variable name="TotalIgnore" select="$GrandTotal - $TotalSuccess - $TotalFailure - $TotalKnownFailures - $TotalNA"/>
220     <xsl:variable name="TotalSuccessRate" select="$TotalSuccess div $GrandTotal"/>
221
222     <tr bgcolor="#EF9C9C">
223       <td>Total</td>
224       <td align="right">
225         <xsl:call-template name="display-percent">
226           <xsl:with-param name="value" select="$TotalSuccessRate"/>
227         </xsl:call-template>
228       </td>
229       <td width="210px" align="center">
230         <xsl:if test="round($TotalSuccess * 200 div $GrandTotal) != 0">
231           <span class="covered">
232             <xsl:attribute name="style">width:<xsl:value-of select="round($TotalSuccess * 200 div $GrandTotal)"/>px</xsl:attribute>&#160;
233           </span>
234         </xsl:if>
235         <xsl:if test="round($TotalFailure * 200 div $GrandTotal) != 0">
236           <span class="uncovered">
237             <xsl:attribute name="style">width:<xsl:value-of select="round($TotalFailure * 200 div $GrandTotal)"/>px</xsl:attribute>&#160;
238           </span>
239         </xsl:if>
240         <xsl:if test="round($TotalKnownFailures * 200 div $GrandTotal) != 0">
241           <span class="knownfailure">
242             <xsl:attribute name="style">width:<xsl:value-of select="round($TotalKnownFailures * 200 div $GrandTotal)"/>px</xsl:attribute>&#160;
243           </span>
244         </xsl:if>
245         <xsl:if test="round($TotalIgnore * 200 div $GrandTotal) != 0">
246           <span class="ignored">
247             <xsl:attribute name="style">width:<xsl:value-of select="round($TotalIgnore * 200 div $GrandTotal)"/>px</xsl:attribute>&#160;
248           </span>
249         </xsl:if>
250       </td>
251       <td align="right"><xsl:value-of select="$GrandTotal" /></td>
252       <td align="right"><xsl:value-of select="$TotalSuccess" /></td>
253       <td align="right"><xsl:value-of select="$TotalFailure" /></td>
254       <td align="right"><xsl:value-of select="$TotalTimeout" /></td>
255       <td align="right"><xsl:value-of select="$TotalKnownFailures" /></td>
256       <td align="right"><xsl:value-of select="$TotalIgnore" /></td>
257       <td align="right"><xsl:value-of select="$TotalNA" /></td>
258       <td align="right"><xsl:value-of select="format-number(sum(//test/@exec_time), '0.0')" /></td>
259     </tr>
260   </table>
261     
262   <br/>
263   <!-- Show details -->
264   <xsl:for-each select="./grid">
265     <xsl:sort select="@name" />
266     <xsl:sort select="@session" />
267     
268     <div style="display:none" name="mod"><xsl:attribute name="id">mod_<xsl:value-of select="../@name"/>.<xsl:value-of select="@name"/></xsl:attribute>
269     Tests of grid <b><xsl:value-of select="@name"/></b>
270     <table width="100%">
271       <tr bgcolor="#9acd32">
272         <th width="100">session</th>
273         <th>script</th>
274         <th width="100">result</th>
275         <th width="100">time</th>
276       </tr>
277
278       <xsl:for-each select="./session">
279       <!--<xsl:if test="@executed_last_time='yes'">-->
280             <xsl:sort select="@name" />
281
282             <tr>
283               <td align="center"><xsl:attribute name="rowspan"><xsl:value-of select="count(./test)+count(.//callback)+1" /></xsl:attribute>
284                 <xsl:value-of select="@name" />
285                 <br/>(<xsl:value-of select="format-number(sum(./test/@exec_time), '0')" /> s)
286               </td>
287             </tr>
288
289           <xsl:for-each select="./test">
290             <xsl:sort select="@script" />
291
292             <xsl:choose>
293               <xsl:when test="count(./callback) != 0">
294                 <tr>
295                   <td align="left">
296                     <xsl:attribute name="class"><xsl:value-of select="@res" /></xsl:attribute>
297                     <a href="#content" class="node">
298                             <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="@script"/>')</xsl:attribute>
299                             <xsl:attribute name="title">Click to see the script content</xsl:attribute>
300                             <xsl:value-of select="@script" />
301                     </a>
302                     &#160;
303                     <a href="#content" class="node">
304                             <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="@script"/>log')</xsl:attribute>
305                             <xsl:attribute name="title">Click to see the execution log</xsl:attribute>
306                             log
307                     </a>
308                   </td>
309                   <td align="center"><xsl:attribute name="class"><xsl:value-of select="@res" /></xsl:attribute><xsl:value-of select="@res" /></td>
310                   <td align="right"><xsl:value-of select="format-number(@exec_time, '0.0')" /></td>
311                   <xsl:for-each select="./history/previous_test">
312                     <xsl:sort select="@date_hour" order="descending"/>
313                     <td align="center"><xsl:attribute name="class"><xsl:value-of select="@res" /></xsl:attribute><xsl:value-of select="@res" /></td>
314                   </xsl:for-each>
315                 </tr>
316                 <tr>
317                   <td align="left" colspan="3" class="linkification-disabled"><xsl:value-of select="./callback" /></td>
318                 </tr>
319               </xsl:when>
320               <xsl:otherwise>
321                 <tr>
322                   <td align="left">
323                     <a href="#content" class="node">
324                             <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="@script"/>')</xsl:attribute>
325                             <xsl:attribute name="title">Click to see the script content</xsl:attribute>
326                             <xsl:value-of select="@script" />
327                     </a>
328                     &#160;
329                     <a href="#content" class="node">
330                             <xsl:attribute name="onclick">javascript:Toggle('<xsl:value-of select="@script"/>log')</xsl:attribute>
331                             <xsl:attribute name="title">Click to see the execution log</xsl:attribute>
332                             log
333                     </a>
334                   </td>
335                   <td align="center"><xsl:attribute name="class"><xsl:value-of select="@res" /></xsl:attribute><xsl:value-of select="@res" /></td>
336                   <td align="right"><xsl:value-of select="format-number(@exec_time, '0.0')" /></td>
337                   <xsl:for-each select="./history/previous_test">
338                     <xsl:sort select="@date_hour" order="descending"/>
339                     <td align="center"><xsl:attribute name="class"><xsl:value-of select="@res" /></xsl:attribute><xsl:value-of select="@res" /></td>
340                   </xsl:for-each>
341                 </tr>
342               </xsl:otherwise>
343             </xsl:choose>
344               <xsl:if test="count(./amend) != 0">
345                 <tr>
346                   <td class="ko"><b>Amended</b></td>    
347                   <td align="left" colspan="3"><xsl:value-of select="./amend" /></td>
348                 </tr>
349               </xsl:if>
350           </xsl:for-each>
351       <!--</xsl:if>-->
352       </xsl:for-each>
353     
354     </table>
355     </div>
356   <!--</xsl:if>-->
357   </xsl:for-each>
358   
359   <xsl:for-each select="./grid">
360     <xsl:for-each select="./session">
361       <xsl:for-each select="./test">
362           <div style="display:none" name="text"><xsl:attribute name="id"><xsl:value-of select="@script"/></xsl:attribute>
363             <PRE><xsl:value-of select="./content"/></PRE>
364           </div>
365           <div style="display:none" name="text"><xsl:attribute name="id"><xsl:value-of select="@script"/>log</xsl:attribute>
366             <PRE><xsl:value-of select="./out"/></PRE>
367           </div>
368       </xsl:for-each>
369     </xsl:for-each>
370   </xsl:for-each>
371   
372 </xsl:template>
373
374 <xsl:template name="display-percent">
375     <xsl:param name="value"/>
376     <xsl:value-of select="format-number($value, '00.00 %')"/>
377 </xsl:template>
378
379 <xsl:template name="display-count">
380     <xsl:param name="value"/>
381     <td align="right">
382     <xsl:if test="$value &gt; 0">
383         <xsl:value-of select="$value"/>
384     </xsl:if>
385     <xsl:if test="$value = 0"><span class="zero">0</span></xsl:if>
386     </td>
387 </xsl:template>
388
389 </xsl:stylesheet>