Просмотр исходного кода

support for partial match in test case names

[SVN r25027]
Aleksey Gurtovoy 21 лет назад
Родитель
Сommit
ebeabf63e7

+ 113 - 106
tools/regression/xsl_reports/xsl/v2/add_expected_results.xsl

@@ -13,123 +13,130 @@
 
 
 -->
 -->
 
 
-<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
-  <xsl:output method="xml" encoding="utf-8"/>
-  
-  <xsl:param name="expected_results_file"/>
-  <xsl:param name="failures_markup_file"/>
-  <xsl:variable name="expected_results" select="document( $expected_results_file )" />
-  <xsl:variable name="failures_markup" select="document( $failures_markup_file )" />
-
-  <xsl:template match="/">
-    <xsl:apply-templates/>
-  </xsl:template>
+<xsl:stylesheet 
+    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
+    xmlns:meta="http://www.meta-comm.com"
+    exclude-result-prefixes="meta"
+    version="1.0">
+
+    <xsl:import href="common.xsl"/>
   
   
-  <xsl:template match="test-log">
-    <xsl:variable name="library" select="@library"/>
-    <xsl:variable name="test-name" select="@test-name"/>
-    <xsl:variable name="toolset" select="@toolset"/>
-
-    <xsl:element name="{local-name()}">
-      <xsl:apply-templates select="@*"/>
-
-      <xsl:variable name="actual_result">
-        <xsl:choose>
-          <!-- Hack: needs to be researched (and removed). See M.Wille's incident. -->
-          <xsl:when test="run/@result='succeed' and lib/@result='fail'">
-            <xsl:text>success</xsl:text>
-          </xsl:when>
-          <xsl:when test="./*/@result = 'fail'" >
-            <xsl:text>fail</xsl:text>
-          </xsl:when>
-          <xsl:otherwise>
-            <xsl:text>success</xsl:text>
-          </xsl:otherwise>
-        </xsl:choose>                     
-      </xsl:variable>
-
-      <xsl:variable name="expected_results_test_case" select="$expected_results//*/test-result[ @library=$library and ( @test-name=$test-name or @test-name='*' ) and @toolset = $toolset]"/>
-      <xsl:variable name="failures_markup" select="$failures_markup//library[@name=$library]/test[@name = $test-name or @name = '*']/mark-failure[  ( toolset/@name = $toolset or toolset/@name = '*' ) ]"/>
-      <xsl:variable name="is_new">
-         <xsl:choose>
-            <xsl:when test="$expected_results_test_case">
-               <xsl:text>no</xsl:text>
+    <xsl:output method="xml" encoding="utf-8"/>
+      
+    <xsl:param name="expected_results_file"/>
+    <xsl:param name="failures_markup_file"/>
+    <xsl:variable name="expected_results" select="document( $expected_results_file )" />
+    <xsl:variable name="failures_markup" select="document( $failures_markup_file )" />
+
+    <xsl:template match="/">
+        <xsl:apply-templates/>
+    </xsl:template>
+      
+    <xsl:template match="test-log">
+        <xsl:variable name="library" select="@library"/>
+        <xsl:variable name="test-name" select="@test-name"/>
+        <xsl:variable name="toolset" select="@toolset"/>
+
+        <xsl:element name="{local-name()}">
+        <xsl:apply-templates select="@*"/>
+
+        <xsl:variable name="actual_result">
+            <xsl:choose>
+            <!-- Hack: needs to be researched (and removed). See M.Wille's incident. -->
+            <xsl:when test="run/@result='succeed' and lib/@result='fail'">
+                <xsl:text>success</xsl:text>
+            </xsl:when>
+            <xsl:when test="./*/@result = 'fail'" >
+                <xsl:text>fail</xsl:text>
             </xsl:when>
             </xsl:when>
-            <xsl:otherwise>yes</xsl:otherwise>
-         </xsl:choose>
-      </xsl:variable>
-
-      <xsl:variable name="expected_result">
-        <xsl:choose>
-          <xsl:when test='count( $failures_markup ) &gt; 0'>
-            <xsl:text>fail</xsl:text>
-          </xsl:when>
-          
-          <xsl:otherwise>
+            <xsl:otherwise>
+                <xsl:text>success</xsl:text>
+            </xsl:otherwise>
+            </xsl:choose>                     
+        </xsl:variable>
+
+        <xsl:variable name="expected_results_test_case" select="$expected_results//*/test-result[ @library=$library and ( @test-name=$test-name or @test-name='*' ) and @toolset = $toolset]"/>
+        <xsl:variable name="failures_markup" select="$failures_markup//library[@name=$library]/test[meta:re_match(@name, $test-name)]/mark-failure[  ( toolset/@name = $toolset or toolset/@name = '*' ) ]"/>
+        <xsl:variable name="is_new">
+            <xsl:choose>
+                <xsl:when test="$expected_results_test_case">
+                <xsl:text>no</xsl:text>
+                </xsl:when>
+                <xsl:otherwise>yes</xsl:otherwise>
+            </xsl:choose>
+        </xsl:variable>
+
+        <xsl:variable name="expected_result">
             <xsl:choose>
             <xsl:choose>
-              <xsl:when test="$expected_results_test_case and $expected_results_test_case/@result = 'fail'">
+            <xsl:when test='count( $failures_markup ) &gt; 0'>
                 <xsl:text>fail</xsl:text>
                 <xsl:text>fail</xsl:text>
-              </xsl:when>
+            </xsl:when>
               
               
-              <xsl:otherwise>success</xsl:otherwise>
+            <xsl:otherwise>
+                <xsl:choose>
+                <xsl:when test="$expected_results_test_case and $expected_results_test_case/@result = 'fail'">
+                    <xsl:text>fail</xsl:text>
+                </xsl:when>
+                  
+                <xsl:otherwise>success</xsl:otherwise>
+                </xsl:choose>
+            </xsl:otherwise>
             </xsl:choose>
             </xsl:choose>
-          </xsl:otherwise>
-        </xsl:choose>
-      </xsl:variable>
+        </xsl:variable>
 
 
-      <xsl:variable name="status">
-        <xsl:choose>
-          <xsl:when test="count( $failures_markup ) &gt; 0">
+        <xsl:variable name="status">
             <xsl:choose>
             <xsl:choose>
-              <xsl:when test="$expected_result = $actual_result">expected</xsl:when>
-              <xsl:otherwise>unexpected</xsl:otherwise>
+            <xsl:when test="count( $failures_markup ) &gt; 0">
+                <xsl:choose>
+                <xsl:when test="$expected_result = $actual_result">expected</xsl:when>
+                <xsl:otherwise>unexpected</xsl:otherwise>
+                </xsl:choose>
+            </xsl:when>
+
+            <xsl:otherwise>
+                <xsl:choose>
+                <xsl:when test="$expected_result = $actual_result">expected</xsl:when>
+                <xsl:otherwise>unexpected</xsl:otherwise>
+                </xsl:choose>
+            </xsl:otherwise>
+              
             </xsl:choose>
             </xsl:choose>
-          </xsl:when>
+        </xsl:variable>
 
 
-          <xsl:otherwise>
+        <xsl:variable name="notes">
             <xsl:choose>
             <xsl:choose>
-              <xsl:when test="$expected_result = $actual_result">expected</xsl:when>
-              <xsl:otherwise>unexpected</xsl:otherwise>
+            <xsl:when test='count( $failures_markup ) &gt; 0'>
+                <xsl:for-each select="$failures_markup/note">
+                <xsl:copy-of select="."/>
+                </xsl:for-each>
+                <!--        <xsl:copy-of select="$expected_results_test_case/node()"/>-->
+            </xsl:when>
+
+              
             </xsl:choose>
             </xsl:choose>
-          </xsl:otherwise>
-          
-        </xsl:choose>
-      </xsl:variable>
-
-      <xsl:variable name="notes">
-        <xsl:choose>
-          <xsl:when test='count( $failures_markup ) &gt; 0'>
-            <xsl:for-each select="$failures_markup/note">
-              <xsl:copy-of select="."/>
-            </xsl:for-each>
-            <!--        <xsl:copy-of select="$expected_results_test_case/node()"/>-->
-          </xsl:when>
-
-          
-        </xsl:choose>
-      </xsl:variable>
-
-      <xsl:attribute name="result"><xsl:value-of select="$actual_result"/></xsl:attribute>
-      <xsl:attribute name="expected-result"><xsl:value-of select="$expected_result"/></xsl:attribute>
-      <xsl:attribute name="status"><xsl:value-of select="$status"/></xsl:attribute>
-      <xsl:attribute name="is-new"><xsl:value-of select="$is_new"/></xsl:attribute>
-      <!--<a><xsl:value-of select="count( $failures_markup )"/></a>-->
-      <xsl:element name="notes"><xsl:copy-of select="$notes"/></xsl:element>
-
-
-      <xsl:apply-templates select="node()" />
-    </xsl:element>
-  </xsl:template>
-
-  <xsl:template match="*">
-    <xsl:element name="{local-name()}">
-      <xsl:apply-templates select="@*"/>
-      <xsl:apply-templates select="node()" />
-    </xsl:element>
-  </xsl:template>
-
-  <xsl:template match="@*">
-    <xsl:copy-of select="." />
-  </xsl:template>
+        </xsl:variable>
+
+        <xsl:attribute name="result"><xsl:value-of select="$actual_result"/></xsl:attribute>
+        <xsl:attribute name="expected-result"><xsl:value-of select="$expected_result"/></xsl:attribute>
+        <xsl:attribute name="status"><xsl:value-of select="$status"/></xsl:attribute>
+        <xsl:attribute name="is-new"><xsl:value-of select="$is_new"/></xsl:attribute>
+        <!--<a><xsl:value-of select="count( $failures_markup )"/></a>-->
+        <xsl:element name="notes"><xsl:copy-of select="$notes"/></xsl:element>
+
+
+        <xsl:apply-templates select="node()" />
+        </xsl:element>
+    </xsl:template>
+
+    <xsl:template match="*">
+        <xsl:element name="{local-name()}">
+        <xsl:apply-templates select="@*"/>
+        <xsl:apply-templates select="node()" />
+        </xsl:element>
+    </xsl:template>
+
+    <xsl:template match="@*">
+        <xsl:copy-of select="." />
+    </xsl:template>
 
 
 </xsl:stylesheet>
 </xsl:stylesheet>

+ 27 - 0
tools/regression/xsl_reports/xsl/v2/common.xsl

@@ -140,6 +140,33 @@
         <func:result select="$explicit_markup//library[ @name = $library ]/mark-unusable[ toolset/@name = $toolset or toolset/@name='*' ]"/>
         <func:result select="$explicit_markup//library[ @name = $library ]/mark-unusable[ toolset/@name = $toolset or toolset/@name='*' ]"/>
     </func:function>
     </func:function>
 
 
+    <func:function name="meta:re_match">
+        <xsl:param name="pattern"/>
+        <xsl:param name="text"/>
+        
+        <func:result>
+            <xsl:choose>
+                <xsl:when test="not( contains( $pattern, '*' ) )">
+                    <xsl:value-of select="$text = $pattern"/>
+                </xsl:when>
+                <xsl:when test="$pattern = '*'">
+                    <xsl:value-of select="1 = 1"/>
+                </xsl:when>
+                <xsl:when test="substring( $pattern, 1, 1 ) = '*' and substring( $pattern, string-length($pattern), 1 ) = '*' ">
+                    <xsl:value-of select="contains( $text, substring( $pattern, 2, string-length($pattern) - 2 ) ) "/>
+                </xsl:when>
+                <xsl:when test="substring( $pattern, 1, 1 ) = '*'">
+                    <xsl:variable name="pattern_tail" select="substring( $pattern, 2, string-length($pattern) - 1 )"/>
+                    <xsl:value-of select="substring( $text, string-length($text) - string-length($pattern_tail) + 1, string-length($pattern_tail) ) = $pattern_tail"/>
+                </xsl:when>
+                <xsl:when test="substring( $pattern, string-length($pattern), 1 ) = '*' ">
+                    <xsl:variable name="pattern_head" select="substring( $pattern, 1, string-length($pattern) - 2 )"/>
+                    <xsl:value-of select="substring( $text, 1, string-length($pattern_head) ) = $pattern_head "/>
+                </xsl:when>
+            </xsl:choose>
+        </func:result>
+    </func:function>
+
     <!-- path -->
     <!-- path -->
 
 
     <func:function name="meta:encode_path">
     <func:function name="meta:encode_path">

粤ICP备19079148号