summaryrefslogtreecommitdiff
path: root/tests/autotest-report.pl
blob: 8ed8dd9ba5c329ec6281875dc66665822e2a765f (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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
#!/usr/bin/perl

# pretty-printing
sub prettytoolset
{
	my $toolset = shift;

	return "Borland C++ 5.82" if ($toolset eq 'bcc');
	return "Metrowerks CodeWarrior 8" if ($toolset eq 'cw');
	return "Digital Mars C++ 8.51" if ($toolset eq 'dmc');
	return "Sun C++ 5.10" if ($toolset eq 'suncc');

	return "Intel C++ Compiler $1.0" if ($toolset =~ /^ic(\d+)$/);
	return "Intel C++ Compiler $1.0 x64" if ($toolset =~ /^ic(\d+)_x64$/);
	return "MinGW (GCC $1.$2)" if ($toolset =~ /^mingw(\d)(\d)$/);
	return "MinGW (GCC $1.$2) x64" if ($toolset =~ /^mingw(\d)(\d)_x64$/);
	return "Microsoft Visual C++ 7.1" if ($toolset eq 'msvc71');
	return "Microsoft Visual C++ $1.0" if ($toolset =~ /^msvc(\d+)$/);
	return "Microsoft Visual C++ $1.0 x64" if ($toolset =~ /^msvc(\d+)_x64$/);
	return "GNU C++ Compiler $1" if ($toolset =~ /^gcc(.*)$/);

	$toolset;
}

sub prettyplatform
{
	my $platform = shift;

	return "solaris" if ($platform =~ /solaris/);

	return "macos" if ($platform =~ /darwin/);

	return "linux64" if ($platform =~ /64-linux/);
	return "linux32" if ($platform =~ /86-linux/);

	return "fbsd64" if ($platform =~ /64-freebsd/);
	return "fbsd32" if ($platform =~ /86-freebsd/);

	return "win64" if ($platform =~ /MSWin32-x64/);
	return "win32" if ($platform =~ /MSWin32/);

	$platform;
}

# 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+) \[(.*?)\] (.*)/)
	{
		my ($platform, $toolset, $configuration, $defineset, $info) = ($1, $2, $3, $4, $5);

		my $fulltool = &prettyplatform($platform) . ' ' . &prettytoolset($toolset);
		my $fullconf = "$configuration $defineset";

		if ($info =~ /^prepare/)
		{
			$results{$fulltool}{$fullconf}{result} = 1;
		}
		elsif ($info =~ /^success/)
		{
			$results{$fulltool}{$fullconf}{result} = 0;
		}
		elsif ($info =~ /^coverage (\S+) (\S+)/)
		{
			$results{$fulltool}{$fullconf}{"coverage_$1"} = $2;
		}
		else
		{
			print STDERR "Unrecognized autotest infoline $_";
		}

		&insertindex(\%toolsets, $fulltool);

		$defines{$_} = 1 foreach (split /,/, $defineset);
		&insertindex(\%configurations, $fullconf);
	}
	elsif (/^### autotest revision (\d+)/)
	{
		if (defined $revision && $revision != $1)
		{
			print STDERR "Autotest build report contains several revisions: $revision, $1\n";
		}
		else
		{
			$revision = $1;
		}
	}
}

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

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

# print header
$stylesheet = <<END;
table.autotest { border: 1px solid black; border-left: none; border-top: none; }
table.autotest td { border: 1px solid black; border-right: none; border-bottom: none; }
END

print <<END;
<html><head><title>pugixml autotest report</title><style type="text/css"><!-- $stylesheet --></style></head><body>
<h3>pugixml autotest report</h3>
<table border=1 cellspacing=0 cellpadding=4 class="autotest">
END

# print configuration header (release/debug)
print "<tr><td align='right' colspan=2>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' colspan=2><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)
{
	my ($platform, $toolset) = split(/\s+/, $tool, 2);
	print "<tr><td style='border-right: none' align='center'><small>$platform</small></td><td style='border-left: none'>$toolset</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 from Subversion r$revision
</body></html>
END