Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
authorSimon Howkins <simonh@symbian.org>
Thu, 01 Oct 2009 17:21:32 +0100
changeset 569 5af7cc0d44a1
parent 568 a1d3b0c3227b
child 570 e5e6ae6bf38f
Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
common/tools/brag/brag.xsl
common/tools/brag/raptorToBRAG.pl
--- a/common/tools/brag/brag.xsl	Fri Oct 02 12:17:26 2009 +0100
+++ b/common/tools/brag/brag.xsl	Thu Oct 01 17:21:32 2009 +0100
@@ -2,20 +2,20 @@
 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fn="http://www.w3.org/2005/xpath-functions">
 
 <!-- Initialise keys (sort of like hashes?) to enable us to list distinct packages/severities -->
-<xsl:key name="packages" match="stage/step/failures/failure" use="@package"/>
-<xsl:key name="severities" match="stage/step/failures" use="@severity"/>
+<xsl:key name="packages" match="failure" use="@package"/>
+<xsl:key name="severities" match="failures" use="@severity"/>
 
 <!-- Main template -->
-<xsl:template match="/">
+<xsl:template match="/buildStatus">
 	<html>
 	<head><title>Build Status</title></head>
 	<body>
 	<h1>Build Status</h1>
 
-	<xsl:variable name="criticalCount" select="count(stage/step/failures[@level='critical']/failure)"/>
-	<xsl:variable name="majorCount" select="count(stage/step/failures[@level='major']/failure)"/>
-	<xsl:variable name="minorCount" select="count(stage/step/failures[@level='minor']/failure)"/>
-	<xsl:variable name="unknownCount" select="count(stage/step/failures[@level!='critical' and @level!='major' and @level!='minor']/failure)"/>
+	<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)"/>
 
 	<h2>
 	Overall BRAG staus: 
@@ -34,15 +34,15 @@
 	<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(stage/step/failures/failure)"/></th></tr>
+	<tr><th>Grand total</th><th><xsl:value-of select="count(phase/step/failures/failure)"/></th></tr>
 	</table>
 
-	<h2>Breakdown by stage/step</h2>
+	<h2>Breakdown by phase/step</h2>
 	<table border="1">
 
-	<xsl:for-each select="stage">
+	<xsl:for-each select="phase">
 		<tr>
-		<th colspan='2'>Stage: <xsl:value-of select="@name"/></th>
+		<th colspan='2'>Phase: <xsl:value-of select="@name"/></th>
 		</tr>
 		<xsl:for-each select="step">
 			<tr>
@@ -60,12 +60,12 @@
 	</table>
 
 	<!-- If any failures are tied to a specific package... -->
-	<xsl:if test="stage/step/failures/failure[@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="stage/step/failures/failure[generate-id(.) = generate-id(key('packages', @package))]">
+		<xsl:for-each select="phase/step/failures/failure[generate-id(.) = generate-id(key('packages', @package))]">
 			<xsl:sort select="@package"/>
 			<tr><td><xsl:value-of select="@package"/></td><td><xsl:value-of select="count(key('packages', @package))"/></td></tr>
 		</xsl:for-each>
--- a/common/tools/brag/raptorToBRAG.pl	Fri Oct 02 12:17:26 2009 +0100
+++ b/common/tools/brag/raptorToBRAG.pl	Thu Oct 01 17:21:32 2009 +0100
@@ -37,9 +37,23 @@
 
 # Start to build structure to be output as XML (same format as XML::Parser would create for us)
 my $xmlNewline = bless { Text => "\n" }, "Characters";
-my $data = [bless {name => "build", Kids => [ $xmlNewline ] }, "stage"];
+my $buildStatus =
+[
+	bless
+	{
+		Kids =>
+		[
+			$xmlNewline,
+			bless
+			{
+				name => "build",
+				Kids => [ $xmlNewline ]
+			}, "phase",
+		]
+	}, "buildStatus"
+];
 # Get a shortcut reference to the bit we will use a lot
-my $buildStage = $data->[0];
+my $buildPhase = $buildStatus->[0]->{Kids}->[-1];
 
 # READ SUMMARY.CSV FILE
 open(CSV, $raptorSummary);
@@ -83,7 +97,7 @@
 	
 	# Look through the steps to see if we already have one to match this config
 	my $step;
-	foreach (@{$buildStage->{Kids}})
+	foreach (@{$buildPhase->{Kids}})
 	{
 		next unless ref $_ eq "step";
 		if ($_->{name} eq $failure->{config})
@@ -96,7 +110,7 @@
 	{
 		# First item found in this step - create step entry
 		$step = bless { name => $failure->{config}, Kids => [ $xmlNewline ] }, "step";
-		push @{$buildStage->{Kids}}, $step, $xmlNewline;
+		push @{$buildPhase->{Kids}}, $step, $xmlNewline;
 		# Also create empty <failures> tags with severities in a sensible order
 		foreach my $severity (qw{critical major minor})
 		{
@@ -140,7 +154,7 @@
 # Print XML
 print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
 print "<?xml-stylesheet type='text/xsl' href='brag.xsl'?>\n";
-printTree($data->[0]);
+printTree($buildStatus->[0]);
 print "\n";
 
 exit(0);