common/tools/brag/raptorToBRAG.pl
author Simon Howkins <simonh@symbian.org>
Wed, 14 Oct 2009 10:45:17 +0100
changeset 660 5a3e7da0fee9
parent 605 2907b286c72a
child 665 ddca63d8e13c
permissions -rw-r--r--
Replaced section "Package failures by phase/step/severity" with "Package failures by package/severity" Added internal links from the package/severity breakdown to the peices of the new section.
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     1
#!perl -w
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     2
#
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     3
# Copyright (c) 2009 Symbian Foundation Ltd
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     4
# This component and the accompanying materials are made available
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     5
# under the terms of the License "Eclipse Public License v1.0"
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     6
# which accompanies this distribution, and is available
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     7
# at the URL "http://www.eclipse.org/legal/epl-v10.html".
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     8
#
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
     9
# Initial Contributors:
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    10
# Symbian Foundation Ltd - initial contribution.
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    11
#
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    12
# Contributors:
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    13
#
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    14
# Description:
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    15
# Generate the BRAG-compatible XML summary of the Raptor log from the CSV output of the raptor parser
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    16
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    17
use strict;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    18
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    19
use Getopt::Long;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    20
use Text::CSV;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    21
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    22
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    23
my $raptorSummary;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    24
my $help = 0;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    25
GetOptions((
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    26
	'raptorsummary=s' => \$raptorSummary,
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    27
	'help!' => \$help
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    28
));
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    29
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    30
$help = 1 if (!$raptorSummary);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    31
if ($help)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    32
{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    33
	print "Generate an XML summary of the Raptor build from a summary.csv file\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    34
	print "Usage: perl summarize.pl --raptorsummary=CSV\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    35
	exit(0);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    36
}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    37
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    38
# Start to build structure to be output as XML (same format as XML::Parser would create for us)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    39
my $xmlNewline = bless { Text => "\n" }, "Characters";
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    40
my $buildStatus =
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    41
[
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    42
	bless
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    43
	{
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    44
		Kids =>
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    45
		[
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    46
			$xmlNewline,
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    47
			bless
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    48
			{
605
2907b286c72a Adjusted capitalisation to make the final output more aesthetically pleasing.
Simon Howkins <simonh@symbian.org>
parents: 569
diff changeset
    49
				name => "Build",
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    50
				Kids => [ $xmlNewline ]
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    51
			}, "phase",
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    52
		]
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    53
	}, "buildStatus"
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    54
];
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    55
# Get a shortcut reference to the bit we will use a lot
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
    56
my $buildPhase = $buildStatus->[0]->{Kids}->[-1];
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    57
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    58
# READ SUMMARY.CSV FILE
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    59
open(CSV, $raptorSummary);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    60
my $csv = Text::CSV->new();
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    61
while (my $line = <CSV>)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    62
{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    63
	chomp $line;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    64
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    65
	unless ($csv->parse($line))
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    66
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    67
		my $err = $csv->error_input();
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    68
		warn "Failed to parse $raptorSummary line line $. as CSV '$line': $err  Skipping\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    69
		next;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    70
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    71
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    72
	my @keys = qw{category subcategory severity config component phase recipe file linenum};
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    73
	my @values = $csv->fields();
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    74
	unless (scalar @keys == scalar @keys)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    75
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    76
		warn "WARNING: line does not match expected format at $raptorSummary line $.. Skipping\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    77
		next;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    78
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    79
	
556
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
    80
	# Populate the hash using a hash slice
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    81
	my $failure = {};
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    82
	@{$failure}{@keys} = @values;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    83
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    84
	if (!$failure->{category})
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    85
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    86
		warn "WARNING: summary line without a category at $raptorSummary line $.. Skipping\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    87
		next;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    88
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    89
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    90
	if ($failure->{category} =~ m{^recipe_failure$}i and !$failure->{component})
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    91
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    92
		warn "WARNING: recipe_failure with component field empty at $raptorSummary line $.. Skipping\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    93
		next;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    94
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    95
	$failure->{subcategory} ||= 'uncategorized';
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    96
	$failure->{severity} ||= 'unknown';
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    97
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    98
	# Look through the steps to see if we already have one to match this config
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
    99
	my $step;
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
   100
	foreach (@{$buildPhase->{Kids}})
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   101
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   102
		next unless ref $_ eq "step";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   103
		if ($_->{name} eq $failure->{config})
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   104
		{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   105
			$step = $_;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   106
			last;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   107
		}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   108
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   109
	unless ($step)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   110
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   111
		# First item found in this step - create step entry
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   112
		$step = bless { name => $failure->{config}, Kids => [ $xmlNewline ] }, "step";
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
   113
		push @{$buildPhase->{Kids}}, $step, $xmlNewline;
556
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   114
		# Also create empty <failures> tags with severities in a sensible order
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   115
		foreach my $severity (qw{critical major minor})
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   116
		{
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   117
			my $failureSet = bless { level => $severity, Kids => [ $xmlNewline ] }, "failures";
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   118
			push @{$step->{Kids}}, $failureSet, $xmlNewline;
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   119
		}
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   120
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   121
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   122
	# Look through the sets of failures in this step to see if we hve one which matches this severity
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   123
	my $failureSet;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   124
	foreach (@{$step->{Kids}})
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   125
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   126
		next unless ref $_ eq "failures";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   127
		if ($_->{level} eq $failure->{severity})
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   128
		{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   129
			$failureSet = $_;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   130
			last;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   131
		}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   132
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   133
	unless ($failureSet)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   134
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   135
		# First item found at this severity - create failures entry
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   136
		$failureSet = bless { level => $failure->{severity}, Kids => [ $xmlNewline ] }, "failures";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   137
		push @{$step->{Kids}}, $failureSet, $xmlNewline;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   138
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   139
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   140
	# Now create the failure itself, and add it to this failure set
556
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   141
	my $failureItem = bless {
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   142
#		href => "",
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   143
		Kids => [ bless { Text => $failure->{subcategory} }, "Characters" ]
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   144
	}, "failure";
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   145
	if ($failure->{component})
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   146
	{
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   147
		$failure->{component} =~ s{^(/sf/.*?/.*?)/.*$}{$1};
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   148
		$failureItem->{package} = $failure->{component};
fa2414b24dc4 Added package attribute (when failure is package specific).
Simon Howkins <simonh@symbian.org>
parents: 547
diff changeset
   149
	}
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   150
	push @{$failureSet->{Kids}}, $failureItem, $xmlNewline;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   151
}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   152
close(CSV);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   153
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   154
# Print XML
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   155
print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   156
print "<?xml-stylesheet type='text/xsl' href='brag.xsl'?>\n";
569
5af7cc0d44a1 Adfjusted XML format used, so there's a document-level tag - <buildStatus> which can wrap multiple <phase> tags.
Simon Howkins <simonh@symbian.org>
parents: 556
diff changeset
   157
printTree($buildStatus->[0]);
547
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   158
print "\n";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   159
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   160
exit(0);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   161
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   162
sub printTree
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   163
{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   164
	my $tree = shift or die;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   165
	die unless ref $tree;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   166
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   167
	my $tagName = ref $tree;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   168
	$tagName =~ s{^main::}{};
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   169
	if ($tagName eq "Characters")
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   170
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   171
		print $tree->{Text};
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   172
		return;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   173
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   174
	
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   175
	print "<$tagName";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   176
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   177
	foreach my $attr (
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   178
		sort {
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   179
			my $order = "name level start stop href";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   180
			my $ixA = index $order, $a;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   181
			my $ixB = index $order, $b;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   182
			die "$a $b" if $ixA + $ixB == -2;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   183
			$ixA - $ixB;
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   184
		}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   185
		grep {
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   186
			! ref $tree->{$_}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   187
		}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   188
		keys %$tree)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   189
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   190
		print " $attr=\"$tree->{$attr}\"";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   191
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   192
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   193
	my $children = $tree->{Kids} || [];
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   194
	if (scalar @$children)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   195
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   196
		print ">";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   197
		foreach my $child (@$children)
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   198
		{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   199
			printTree($child);
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   200
		}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   201
		print "</$tagName";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   202
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   203
	else
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   204
	{
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   205
		print "/"
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   206
	}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   207
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   208
	print ">";
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   209
}
19f9d5fc6406 Added really basic failure extraction and BRAG calculation to build.
Simon Howkins <simonh@symbian.org>
parents:
diff changeset
   210