summaryrefslogtreecommitdiff
path: root/tests/autotest-report.pl
blob: 7f269c9c10d1494a44d448ffe36c12f3415d452b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
#!/usr/bin/perl

# parse build log
%results = ();
%toolsets = ();
%defines = ();
%configurations = ();

sub insertindex
{
	my ($hash, $key) = @_;

	$$hash{$key} = scalar(keys %$hash) unless defined $$hash{$key};
}

while (<>)
{
	### autotest i386-freebsd-64int gcc release [wchar] result 0 97.78 98.85
	if (/^### autotest (\S+) (\S+) (\S+) \[(.*?)\] result (\S+) (\S*) (\S*)/)
	{
		my ($platform, $toolset, $configuration, $defineset, $result, $coverage_pugixml, $coverage_pugixpath) = ($1, $2, $3, $4, $5, $6, $7);

		die "Detected duplicate build information $_\n" if defined $results{"$toolset $platform"}{$configuration}{$defineset};

		my $fulltool = "$toolset $platform";
		my $fullconf = "$configuration $defineset";

		$results{$fulltool}{$fullconf}{result} = $result;
		$results{$fulltool}{$fullconf}{coverage_pugixml} = $coverage_pugixml;
		$results{$fulltool}{$fullconf}{coverage_pugixpath} = $coverage_pugixpath;

		&insertindex(\%toolsets, $fulltool);

		$defines{$_} = 1 foreach (split /,/, $defineset);
		&insertindex(\%configurations, $fullconf);
	}
}

# make arrays of toolsets and configurations
@toolsetarray = ();
@configurationarray = ();

$toolsetarray[$toolsets{$_}] = $_ foreach (keys %toolsets);
$configurationarray[$configurations{$_}] = $_ foreach (keys %configurations);

# print header
print <<END;
<html><head><title>pugixml autotest report</title></head><body>
<h3>pugixml autotest report</h3>
<table border=1 cellspacing=0 cellpadding=4>
END

# print configuration header (release/debug)
print "<tr><td align='right'>configuration</td>";
print "<td>".(split /\s+/)[0]."</td>" foreach (@configurationarray);
print "</tr>\n";

# print defines header (one row for each define)
foreach $define (sort {$a cmp $b} keys %defines)
{
	print "<tr><td align='right'><small>$define</small></td>";

	foreach (@configurationarray)
	{
		my $present = ($_ =~ /\b$define\b/);
		my $color = $present ? "#cccccc" : "#ffffff";
		print "<td bgcolor='$color' align='center'>" . ($present ? "+" : "&nbsp;") . "</td>";
	}
	print "</tr>\n";
}

# print data (one row for each toolset)
foreach $tool (@toolsetarray)
{
	print "<tr><td>$tool</td>";

	foreach (@configurationarray)
	{
		my $info = $results{$tool}{$_};

		if (!defined $$info{result})
		{
			print "<td bgcolor='#cccccc'>&nbsp;</td>";
		}
		elsif ($$info{result} == 0)
		{
			my ($coverage_pugixml, $coverage_pugixpath) = ($$info{coverage_pugixml}, $$info{coverage_pugixpath});

			print "<td bgcolor='#00ff00' align='center'>pass";
				
			if ($coverage_pugixml > 0 || $coverage_pugixpath > 0)
			{
				print "<br><font size='-2'>" . ($coverage_pugixml + 0) . "%<br>" . ($coverage_pugixpath + 0) . "%</font>";
			}

			print "</td>";
		}
		else
		{
			print "<td bgcolor='#ff0000' align='center'>fail</td>"
		}
	}

	print "</tr>\n";
}

# print footer
$date = localtime;

print <<END;
</table><br>
Generated on $date
</body></html>
END