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