Make BRAG point to the results of UH parser instead of intermediate artifacts
authorDario Sestito <darios@symbian.org>
Mon, 08 Feb 2010 18:57:42 +0000
changeset 882 6ae47dc5d707
parent 881 82070405cb6e
child 883 1281d0f13d9b
Make BRAG point to the results of UH parser instead of intermediate artifacts
common/build.postbuild.xml
common/tools/brag/brag.xsl
common/tools/brag/uh2brag.pl
--- a/common/build.postbuild.xml	Fri Feb 05 15:59:33 2010 +0000
+++ b/common/build.postbuild.xml	Mon Feb 08 18:57:42 2010 +0000
@@ -422,10 +422,10 @@
       </for>
 
       <!-- Cook the raptor analysis further to produce something in the right format for the BRAG system -->
-      <exec executable="perl" output="${build.log.dir}/summary/Raptor_BRAG.xml" logError="yes">
-        <arg value="${sf.common.config.dir}/tools/brag/raptorToBRAG.pl"/>
-        <arg value="--raptorsummary"/>
-        <arg value="${build.log.dir}/raptorbits/summary.csv"/>
+      <exec executable="perl" output="${build.log.dir}/summary/Uh_BRAG.xml" logError="yes">
+        <arg value="${sf.common.config.dir}/tools/brag/uh2brag.pl"/>
+        <arg value="--index"/>
+        <arg value="${build.log.dir}/html/index.html"/>
       </exec>
       <!-- And copy the XSL so the output can be transformed by a browser -->
       <copy file="${sf.common.config.dir}/tools/brag/brag.xsl" toDir="${build.log.dir}/summary/"/>
--- a/common/tools/brag/brag.xsl	Fri Feb 05 15:59:33 2010 +0000
+++ b/common/tools/brag/brag.xsl	Mon Feb 08 18:57:42 2010 +0000
@@ -13,10 +13,10 @@
 	<body>
 	<h1>Build Status</h1>
 
-	<xsl:variable name="criticalCount" select="count(phase/step/failures[@level='critical']/failure)"/>
-	<xsl:variable name="majorCount" select="count(phase/step/failures[@level='major']/failure)"/>
-	<xsl:variable name="minorCount" select="count(phase/step/failures[@level='minor']/failure)"/>
-	<xsl:variable name="unknownCount" select="count(phase/step/failures[@level!='critical' and @level!='major' and @level!='minor']/failure)"/>
+	<xsl:variable name="criticalCount" select="count(phase/step/failures[@level='critical']/failure)+sum(phase/step/failures[@level='critical']/@count)"/>
+	<xsl:variable name="majorCount" select="count(phase/step/failures[@level='major']/failure)+sum(phase/step/failures[@level='major']/@count)"/>
+	<xsl:variable name="minorCount" select="count(phase/step/failures[@level='minor']/failure)+sum(phase/step/failures[@level='minor']/@count)"/>
+	<xsl:variable name="unknownCount" select="count(phase/step/failures[@level!='critical' and @level!='major' and @level!='minor']/failure)+sum(phase/step/failures[@level!='critical' and @level!='major' and @level!='minor']/@count)"/>
 
 	<h2>
 	Overall BRAGG staus: 
@@ -35,7 +35,7 @@
 	<tr><td>Major</td><td><xsl:value-of select="$majorCount"/></td></tr>
 	<tr><td>Minor</td><td><xsl:value-of select="$minorCount"/></td></tr>
 	<tr><td>Unknown</td><td><xsl:value-of select="$unknownCount"/></td></tr>
-	<tr><th>Grand total</th><th><xsl:value-of select="count(phase/step/failures/failure)"/></th></tr>
+	<tr><th>Grand total</th><th><xsl:value-of select="$criticalCount+$majorCount+$minorCount+$unknownCount"/></th></tr>
 	</table>
 
 	<h2>Breakdown by phase/step</h2>
@@ -47,12 +47,27 @@
 		</tr>
 		<xsl:for-each select="step">
 			<tr>
+			<xsl:choose>
+			<xsl:when test="@detailshref">
+			<td colspan='2'>Step: <a><xsl:attribute name="href"><xsl:value-of select="@detailshref"/></xsl:attribute><xsl:value-of select="@name"/></a></td>
+			</xsl:when>
+			<xsl:otherwise>
 			<td colspan='2'>Step: <xsl:value-of select="@name"/></td>
+			</xsl:otherwise>
+			</xsl:choose>
 			</tr>
 			<xsl:for-each select="failures">
 				<tr>
 				<td>Failures: <xsl:value-of select="@level"/></td>
+				
+				<xsl:choose>
+				<xsl:when test="@count">
+				<td>Number: <xsl:value-of select="@count"/></td>
+				</xsl:when>
+				<xsl:otherwise>
 				<td>Number: <xsl:value-of select="count(failure)"/></td>
+				</xsl:otherwise>
+				</xsl:choose>
 				</tr>
 			</xsl:for-each>
 		</xsl:for-each>
@@ -60,48 +75,9 @@
 
 	</table>
 
-	<!-- If any failures are tied to a specific package... -->
-	<xsl:if test="phase/step/failures/failure[@package]">
-		<h2>Breakdown by package</h2>
-		<table border="1">
-		<tr><th>Package</th><th>Total failures</th></tr>
-		<!-- Use the Muenchian Method to get a set of distinct packages -->
-		<xsl:for-each select="phase/step/failures/failure[generate-id(.) = generate-id(key('packages', @package))]">
-			<xsl:sort select="@package"/>
-			<tr>
-			<td><a><xsl:attribute name="href"><xsl:value-of select="concat('#package', @package)"/></xsl:attribute><xsl:value-of select="@package"/></a></td>
-			<td><xsl:value-of select="count(key('packages', @package))"/></td>
-			</tr>
-		</xsl:for-each>
-		</table>
-
-		<h2>Breakdown by package/severity</h2>
-		<xsl:for-each select="phase/step/failures[@level]/failure[generate-id(.) = generate-id(key('packages', @package))]">
-			<xsl:sort select="@package"/>
-			<xsl:variable name="package" select="@package"/>
-			<a><xsl:attribute name="name"><xsl:value-of select="concat('package', $package)"/></xsl:attribute>
-			<h3><xsl:value-of select="$package"/></h3>
-			</a>
-			<table border="1">
-			<tr><th>Severity</th><th>Count</th></tr>
-			<xsl:for-each select="/buildStatus/phase/step/failures[generate-id(.) = generate-id(key('severities', @level))]">
-				<xsl:variable name="severity" select="@level"/>
-				<tr>
-				<td><a>
-				<xsl:if test="count(/buildStatus/phase/step/failures[@level = $severity]/failure[@package = $package]) != 0">
-					<xsl:attribute name="href"><xsl:value-of select="concat('#', $severity, $package)"/></xsl:attribute>
-				</xsl:if>
-				<xsl:value-of select="$severity"/></a></td>
-				<td><xsl:value-of select="count(key('packageANDseverity', concat($severity, $package)))"/></td>
-				</tr>
-			</xsl:for-each>
-			</table>
-		</xsl:for-each>
-	</xsl:if>
-
 	<h2>Floating failures by phase/step/severity</h2>
 	<xsl:if test="count(phase/step/failures/failure/@package) = count(phase/step/failures/failure)">
-		<p>No errors independent of package</p>
+		<p>No failures to show. Please also check the <a href="../html/index.html">Raptor build summary</a> for details on that part of the build</p>
 	</xsl:if>
 	<xsl:for-each select="phase[count(step/failures/failure/@package) != count(step/failures/failure)]">
 		<h3>Phase: <xsl:value-of select="@name"/></h3>
@@ -126,39 +102,6 @@
 		</xsl:for-each>
 	</xsl:for-each>
 
-	<h2>Package failures by package/severity</h2>
-	<xsl:if test="count(phase/step/failures/failure/@package) = 0">
-		<p>No errors specific to a package</p>
-	</xsl:if>
-	<xsl:for-each select="phase/step/failures[@level]/failure[generate-id(.) = generate-id(key('packages', @package))]">
-		<xsl:sort select="@package"/>
-		<xsl:variable name="package" select="@package"/>
-		<a><xsl:attribute name="name"><xsl:value-of select="concat('package', $package)"/></xsl:attribute>
-		<h3><xsl:value-of select="$package"/></h3>
-		</a>
-		<xsl:for-each select="/buildStatus/phase/step/failures[generate-id(.) = generate-id(key('severities', @level))]">
-			<xsl:variable name="severity" select="@level"/>
-			<xsl:if test="count(/buildStatus/phase/step/failures[@level = $severity]/failure[@package = $package]) != 0">
-				<dl><dt><a><xsl:attribute name="name"><xsl:value-of select="concat($severity, $package)"/></xsl:attribute>
-					<xsl:value-of select="$severity"/> (<xsl:value-of select="count(/buildStatus/phase/step/failures[@level = $severity]/failure[@package = $package])"/>)
-				</a></dt><dd>
-				<ul>
-				<xsl:for-each select="/buildStatus/phase/step/failures[@level = $severity]/failure[@package = $package]">
-					<xsl:sort select="@package"/>
-					<li><xsl:value-of select="effect"/></li>
-					<xsl:if test="@unreported_causes != '0'">
-						<br/>(Too much text to show everything; <xsl:value-of select="@unreported_causes"/> lines not shown.)
-					</xsl:if>
-					<xsl:for-each select="causes">
-						<pre><xsl:value-of select="."/></pre>
-					</xsl:for-each>
-				</xsl:for-each>
-				</ul>
-				</dd></dl>
-			</xsl:if>
-		</xsl:for-each>
-	</xsl:for-each>
-
 	</body>
 	</html>
 </xsl:template>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/common/tools/brag/uh2brag.pl	Mon Feb 08 18:57:42 2010 +0000
@@ -0,0 +1,74 @@
+#!perl -w
+#
+# Copyright (c) 2009 Symbian Foundation Ltd
+# This component and the accompanying materials are made available
+# under the terms of the License "Eclipse Public License v1.0"
+# which accompanies this distribution, and is available
+# at the URL "http://www.eclipse.org/legal/epl-v10.html".
+#
+# Initial Contributors:
+# Symbian Foundation Ltd - initial contribution.
+#
+# Contributors:
+#
+# Description:
+# Generate a BRAG-compatible XML summary from an index.html file coming out of the uh parser
+
+use strict;
+
+use Getopt::Long;
+
+my $raptorSummary;
+my $help = 0;
+GetOptions((
+	'index=s' => \$raptorSummary,
+	'help!' => \$help
+));
+
+$help = 1 if (!$raptorSummary);
+if ($help)
+{
+	print "Generate an XML summary of the Raptor build from a summary.csv file\n";
+	print "Usage: perl summarize.pl --index=INDEXFILE\n";
+	exit(0);
+}
+
+my $criticals = 0;
+my $majors = 0;
+my $minors = 0;
+my $unknowns = 0;
+
+# READ INDEX.HTML FILE
+if (open(INDEX, $raptorSummary))
+{
+	while (my $line = <INDEX>)
+	{
+		if ($line =~ m{<tr><td><a href='.*'>.*</a></td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td><td>(\d+)</td></tr>})
+		{
+			$criticals += $1 if ($1);
+			$majors += $2 if ($2);
+			$minors += $3 if ($3);
+			$unknowns += $4 if ($4);
+		}
+	}
+	close(INDEX);
+}
+
+# Print XML
+print <<_END;
+<?xml version=\"1.0\" encoding=\"UTF-8\"?>
+<?xml-stylesheet type='text/xsl' href='brag.xsl'?>
+<buildStatus>
+<phase name="Build">
+<step name=\"Raptor Build\" detailshref=\"..\\html\\index.html\">
+<failures level=\"critical\" count=\"$criticals\"/>
+<failures level=\"major\" count=\"$majors\"/>
+<failures level=\"minor\" count=\"$minors\"/>
+<failures level=\"unknown\" count=\"$unknowns\"/>
+</step>
+</phase>
+</buildStatus>
+_END
+
+exit(0);
+