common/tools/brag/raptorToBRAG.pl
changeset 569 5af7cc0d44a1
parent 556 fa2414b24dc4
child 605 2907b286c72a
equal deleted inserted replaced
568:a1d3b0c3227b 569:5af7cc0d44a1
    35 	exit(0);
    35 	exit(0);
    36 }
    36 }
    37 
    37 
    38 # Start to build structure to be output as XML (same format as XML::Parser would create for us)
    38 # Start to build structure to be output as XML (same format as XML::Parser would create for us)
    39 my $xmlNewline = bless { Text => "\n" }, "Characters";
    39 my $xmlNewline = bless { Text => "\n" }, "Characters";
    40 my $data = [bless {name => "build", Kids => [ $xmlNewline ] }, "stage"];
    40 my $buildStatus =
       
    41 [
       
    42 	bless
       
    43 	{
       
    44 		Kids =>
       
    45 		[
       
    46 			$xmlNewline,
       
    47 			bless
       
    48 			{
       
    49 				name => "build",
       
    50 				Kids => [ $xmlNewline ]
       
    51 			}, "phase",
       
    52 		]
       
    53 	}, "buildStatus"
       
    54 ];
    41 # Get a shortcut reference to the bit we will use a lot
    55 # Get a shortcut reference to the bit we will use a lot
    42 my $buildStage = $data->[0];
    56 my $buildPhase = $buildStatus->[0]->{Kids}->[-1];
    43 
    57 
    44 # READ SUMMARY.CSV FILE
    58 # READ SUMMARY.CSV FILE
    45 open(CSV, $raptorSummary);
    59 open(CSV, $raptorSummary);
    46 my $csv = Text::CSV->new();
    60 my $csv = Text::CSV->new();
    47 while (my $line = <CSV>)
    61 while (my $line = <CSV>)
    81 	$failure->{subcategory} ||= 'uncategorized';
    95 	$failure->{subcategory} ||= 'uncategorized';
    82 	$failure->{severity} ||= 'unknown';
    96 	$failure->{severity} ||= 'unknown';
    83 	
    97 	
    84 	# Look through the steps to see if we already have one to match this config
    98 	# Look through the steps to see if we already have one to match this config
    85 	my $step;
    99 	my $step;
    86 	foreach (@{$buildStage->{Kids}})
   100 	foreach (@{$buildPhase->{Kids}})
    87 	{
   101 	{
    88 		next unless ref $_ eq "step";
   102 		next unless ref $_ eq "step";
    89 		if ($_->{name} eq $failure->{config})
   103 		if ($_->{name} eq $failure->{config})
    90 		{
   104 		{
    91 			$step = $_;
   105 			$step = $_;
    94 	}
   108 	}
    95 	unless ($step)
   109 	unless ($step)
    96 	{
   110 	{
    97 		# First item found in this step - create step entry
   111 		# First item found in this step - create step entry
    98 		$step = bless { name => $failure->{config}, Kids => [ $xmlNewline ] }, "step";
   112 		$step = bless { name => $failure->{config}, Kids => [ $xmlNewline ] }, "step";
    99 		push @{$buildStage->{Kids}}, $step, $xmlNewline;
   113 		push @{$buildPhase->{Kids}}, $step, $xmlNewline;
   100 		# Also create empty <failures> tags with severities in a sensible order
   114 		# Also create empty <failures> tags with severities in a sensible order
   101 		foreach my $severity (qw{critical major minor})
   115 		foreach my $severity (qw{critical major minor})
   102 		{
   116 		{
   103 			my $failureSet = bless { level => $severity, Kids => [ $xmlNewline ] }, "failures";
   117 			my $failureSet = bless { level => $severity, Kids => [ $xmlNewline ] }, "failures";
   104 			push @{$step->{Kids}}, $failureSet, $xmlNewline;
   118 			push @{$step->{Kids}}, $failureSet, $xmlNewline;
   138 close(CSV);
   152 close(CSV);
   139 
   153 
   140 # Print XML
   154 # Print XML
   141 print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
   155 print "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
   142 print "<?xml-stylesheet type='text/xsl' href='brag.xsl'?>\n";
   156 print "<?xml-stylesheet type='text/xsl' href='brag.xsl'?>\n";
   143 printTree($data->[0]);
   157 printTree($buildStatus->[0]);
   144 print "\n";
   158 print "\n";
   145 
   159 
   146 exit(0);
   160 exit(0);
   147 
   161 
   148 sub printTree
   162 sub printTree