summaryrefslogtreecommitdiff
path: root/test/make-html.pl
diff options
context:
space:
mode:
authorVladimir Vukicevic <vladimir@pobox.com>2006-09-09 18:55:46 -0700
committerU-CYCLONE\Vladimir Vukicevic <vladimir@cyclone.(none)>2006-09-09 18:55:46 -0700
commit9735cb9a246627c9e4710c0f7d2955e3e0fbec69 (patch)
tree2ef3ab7edee11b79be0f9b56b0a32d9eb0185ff4 /test/make-html.pl
parent97f26c523590dcb208a7c0e4d00fd66f4ca58605 (diff)
Improve make-html.pl, add self-contained output format
Setting CAIRO_TEST_SHOW_INLINE in the environment before running make-html.pl will generate a html file with all the logs and necessary images inlined as data URI's.
Diffstat (limited to 'test/make-html.pl')
-rwxr-xr-xtest/make-html.pl100
1 files changed, 81 insertions, 19 deletions
diff --git a/test/make-html.pl b/test/make-html.pl
index 82d2edfb..299f07f4 100755
--- a/test/make-html.pl
+++ b/test/make-html.pl
@@ -24,6 +24,8 @@
# Author: Vladimir Vukicevic <vladimir@pobox.com>
#
+use MIME::Base64;
+
##
## Takes all the *.log files in the current directory (or those provided
## on the command line) and spits out html to stdout that can be used to
@@ -31,26 +33,32 @@
##
# show reference images
-my $config_show_ref = 0;
+$config_show_ref = $ENV{'CAIRO_TEST_SHOW_REF'} || 0;
# show fail images
-my $config_show_fail = 1;
+$config_show_fail = $ENV{'CAIRO_TEST_SHOW_FAIL'} || 1;
# show all results, even passes
-my $config_show_all = 0;
+$config_show_all = $ENV{'CAIRO_TEST_SHOW_ALL'} || 0;
-# end of config options
+# include test results inline
+$config_show_inline = $ENV{'CAIRO_TEST_SHOW_INLINE'} || 0;
-my $tests = {};
+# end of config options
-my $teststats = {};
+$tests = {};
+$teststats = {};
+$logs = {};
if ($#ARGV >= 0) { @files = @ARGV; } else { @files = <*.log>; }
foreach (<@files>) {
- (open LOG, "$_") || next;
+ my $testname;
+ my $fn = $_;
+ (open LOG, $fn) || next;
while (<LOG>) {
- next unless /^TEST: (.*) TARGET: (.*) FORMAT: (.*) OFFSET: (.*) RESULT: (.*)$/;
+ next unless /^TEST: (.*) TARGET: (.*) FORMAT: (.*) OFFSET: (.*) RESULT: ([A-Z]*).*$/;
+ $testname = $1 if !defined($testname);
$tests->{$1} = {} unless $tests->{$1};
$tests->{$1}->{$2} = {} unless $tests->{$1}->{$2};
$tests->{$1}->{$2}->{$3} = {} unless $tests->{$1}->{$2}->{$3};
@@ -61,6 +69,13 @@ foreach (<@files>) {
($teststats->{$2}->{$5})++;
}
close LOG;
+
+ (open LOG, $fn) || die "I could open it earlier, but I can't now: $!";
+ {
+ local $/;
+ $logs->{$testname} = <LOG>;
+ }
+ close LOG;
}
my $targeth = {};
@@ -92,6 +107,26 @@ sub printl {
print @_, "\n";
}
+# convert file into a data URI
+sub file_to_data {
+ my ($ctype,$fname) = @_;
+ my $fdata;
+ open FILE, $fname || return "data:" . $ctype . ",";
+ {
+ local $/;
+ $fdata = encode_base64(<FILE>);
+ }
+ close FILE;
+ return "data:" . $ctype . ";base64," . $fdata;
+}
+
+# convert string into a data URI
+sub string_to_data {
+ my ($ctype,$str) = @_;
+ $str =~ s/([^A-Za-z0-9])/sprintf("%%%02X", ord($1))/seg;
+ return "data:" . $ctype . "," . $str;
+}
+
printl '<html><head>';
printl '<title>Cairo Test Results</title>';
printl '<style type="text/css">';
@@ -109,6 +144,8 @@ printl '.UNTESTEDstr { color: #555; }';
printl 'img { max-width: 15em; min-width: 3em; margin: 3px; }';
printl 'td { vertical-align: top; }';
printl '</style>';
+printl '</script>';
+printl '</head>';
printl '<body>';
printl '<table border="1">';
@@ -128,7 +165,7 @@ foreach my $target (@targets) {
print '<span class="PASSstr">', $teststats->{$target}->{"PASS"}, '</span>/';
print '<span class="FAILstr">', $teststats->{$target}->{"FAIL"} + $teststats->{$target}->{"CRASHED"}, '</span>/';
print '<span class="XFAILstr">', $teststats->{$target}->{"XFAIL"}, '</span>/';
- print '<span class="UNTESTEDstr">', $teststats->{$target}->{"UNTESTED"}; '</span>';
+ print '<span class="UNTESTEDstr">', $teststats->{$target}->{"UNTESTED"}, '</span>';
print '</td>';
}
printl '</tr>';
@@ -160,6 +197,23 @@ sub testfiles {
"diff" => "$test-$target$fmtstr$offstr-diff.png");
}
+sub img_for {
+ my ($fn, $withlink) = @_;
+
+ if ($config_show_inline) {
+ $fn = file_to_data("image/png", $fn);
+ # never return links, people can just right-click view image,
+ # and we don't clutter the document
+ return '<img src="' . $fn . '">';
+ } else {
+ if ($withlink) {
+ return '<a href="' . $fn . '"><img src="' . $fn . '"></a>';
+ } else {
+ return '<img src="' . $fn . '">';
+ }
+ }
+}
+
foreach my $test (sort(keys %$tests)) {
foreach my $offset (@offsets) {
foreach my $format (@formats) {
@@ -172,27 +226,26 @@ foreach my $test (sort(keys %$tests)) {
if ($testres) {
my %testfiles = testfiles($test, $target, $format, $offset);
$testline .= "<td class=\"$testres\">";
- $stats{$target}{$testres}++;
+ $teststats{$target}{$testres}++;
if ($testres eq "PASS") {
if ($config_show_all) {
- $testline .= "<a href=\"" . $testfiles{"out"} . "\"><img src=\"" . $testfiles{"out"} . "\"></a>";
+ $testline .= img_for($testfiles{'out'},1);
}
} elsif ($testres eq "FAIL") {
if ($config_show_fail || $config_show_all) {
- $testline .= "<a href=\"" . $testfiles{"out"} . "\"><img src=\"" . $testfiles{"out"} . "\"></a>";
- #$testline .= "<hr size=\"1\">";
+ $testline .= img_for($testfiles{'out'},1);
$testline .= " ";
- $testline .= "<a href=\"" . $testfiles{"diff"} . "\"><img src=\"" . $testfiles{"diff"} . "\"></a>";
+ $testline .= img_for($testfiles{'diff'},1);
}
} elsif ($testres eq "CRASHED") {
$testline .= "!!!CRASHED!!!";
} elsif ($testres eq "XFAIL") {
#nothing
if ($config_show_all) {
- $testline .= "<a href=\"" . $testfiles{"out"} . "\"><img src=\"" . $testfiles{"out"} . "\"></a>";
+ $testline .= img_for($testfiles{'out'},1);
#$testline .= "<hr size=\"1\">";
$testline .= " ";
- $testline .= "<a href=\"" . $testfiles{"diff"} . "\"><img src=\"" . $testfiles{"diff"} . "\"></a>";
+ $testline .= img_for($testfiles{'diff'},1);
}
} elsif ($testres eq "UNTESTED") {
#nothing
@@ -210,11 +263,20 @@ foreach my $test (sort(keys %$tests)) {
}
my $testref = testref($test, $format);
- print '<tr><td>', "<a href=\"$testref\">", $test, ' (', $format, '/', $offset, ')</a>',
- "(<a href=\"$test.log\">log</a>)", '</td>';
+ print '<tr><td>';
+
+ if ($config_show_inline) {
+ print "$test ($format/$offset) ";
+ print "(<a href=\"" . string_to_data("text/plain",$logs->{$test}) . "\">log</a>)";
+ } else {
+ print "<a href=\"$testref\">", $test, ' (', $format, '/', $offset, ')</a> ';
+ print "(<a href=\"$test.log\">log</a>)";
+ }
+
+ print '</td>';
if ($config_show_ref) {
- print "<td><a href=\"$testref\"><img src=\"$testref\"></img></a></td>";
+ print "<td>" . img_for($testref,1) . "</td>";
}
print $testline;