layout/tools/reftest/reftest-to-html.pl

Wed, 31 Dec 2014 06:55:50 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:55:50 +0100
changeset 2
7e26c7da4463
permissions
-rwxr-xr-x

Added tag UPSTREAM_283F7C6 for changeset ca08bd8f51b2

michael@0 1 #!/usr/bin/perl
michael@0 2
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 print <<EOD
michael@0 8 <html>
michael@0 9 <head>
michael@0 10 <title>reftest output</title>
michael@0 11 <style type="text/css">
michael@0 12 /* must be in this order */
michael@0 13 .PASS { background-color: green; }
michael@0 14 .FAIL { background-color: red; }
michael@0 15 .XFAIL { background-color: #999300; }
michael@0 16 .WEIRDPASS { background-color: #00FFED; }
michael@0 17 .PASSRANDOM { background-color: #598930; }
michael@0 18 .FAILRANDOM, td.XFAILRANDOM { background-color: #99402A; }
michael@0 19
michael@0 20 .FAILIMAGES { }
michael@0 21 img { margin: 5px; width: 80px; height: 100px; }
michael@0 22 img.testresult { border: 2px solid red; }
michael@0 23 img.testref { border: 2px solid green; }
michael@0 24 a { color: inherit; }
michael@0 25 .always { display: inline ! important; }
michael@0 26 </style>
michael@0 27 </head>
michael@0 28 <body>
michael@0 29 <p>
michael@0 30 <span class="PASS always"><input type="checkbox" checked="true" onclick="var s = document.styleSheets[0].cssRules[0].style; if (s.display == 'none') s.display = null; else s.display = 'none';">PASS</span>&nbsp;
michael@0 31 <span class="FAIL always"><input type="checkbox" checked="true" onclick="var s = document.styleSheets[0].cssRules[1].style; if (s.display == 'none') s.display = null; else s.display = 'none';">UNEXPECTED FAIL</span>&nbsp;
michael@0 32 <span class="XFAIL always"><input type="checkbox" checked="true" onclick="var s = document.styleSheets[0].cssRules[2].style; if (s.display == 'none') s.display = null; else s.display = 'none';">KNOWN FAIL</span>&nbsp;
michael@0 33 <span class="WEIRDPASS always"><input type="checkbox" checked="true" onclick="var s = document.styleSheets[0].cssRules[3].style; if (s.display == 'none') s.display = null; else s.display = 'none';">UNEXPECTED PASS</span>&nbsp;
michael@0 34 <span class="PASSRANDOM always"><input type="checkbox" checked="true" onclick="var s = document.styleSheets[0].cssRules[4].style; if (s.display == 'none') s.display = null; else s.display = 'none';">PASS (Random)</span>&nbsp;
michael@0 35 <span class="FAILRANDOM always"><input type="checkbox" checked="true" onclick="var s = document.styleSheets[0].cssRules[5].style; if (s.display == 'none') s.display = null; else s.display = 'none';">FAIL (Random)</span>&nbsp;
michael@0 36 </p>
michael@0 37 <table>
michael@0 38 EOD
michael@0 39 ;
michael@0 40
michael@0 41 sub readcleanline {
michael@0 42 my $l = <>;
michael@0 43 chomp $l;
michael@0 44 chop $l if ($l =~ /\r$/);
michael@0 45 return $l;
michael@0 46 }
michael@0 47
michael@0 48 sub do_html {
michael@0 49 my ($l) = @_;
michael@0 50
michael@0 51 $l =~ s,(file:[^ ]*),<a href="\1">\1</a>,g;
michael@0 52 $l =~ s,(data:[^ ]*),<a href="\1">\1</a>,g;
michael@0 53
michael@0 54 return $l;
michael@0 55 }
michael@0 56
michael@0 57 $l = 0;
michael@0 58
michael@0 59 while (<>) {
michael@0 60 $l++;
michael@0 61 next unless /^REFTEST/;
michael@0 62
michael@0 63 chomp;
michael@0 64 chop if /\r$/;
michael@0 65
michael@0 66 s/^REFTEST *//;
michael@0 67
michael@0 68 my $randomresult = 0;
michael@0 69 if (/EXPECTED RANDOM/) {
michael@0 70 s/\(EXPECTED RANDOM\)//;
michael@0 71 $randomresult = 1;
michael@0 72 }
michael@0 73
michael@0 74 if (/^TEST-PASS \| (.*)$/) {
michael@0 75 my $class = $randomresult ? "PASSRANDOM" : "PASS";
michael@0 76 print '<tr><td class="' . $class . '">' . do_html($1) . "</td></tr>\n";
michael@0 77 } elsif (/^TEST-UNEXPECTED-(....) \| (.*)$/) {
michael@0 78 if ($randomresult) {
michael@0 79 die "Error on line $l: UNEXPECTED with test marked random?!";
michael@0 80 }
michael@0 81 my $class = ($1 eq "PASS") ? "WEIRDPASS" : "FAIL";
michael@0 82 print '<tr><td class="' . $class . '">' . do_html($2) . "</td></tr>\n";
michael@0 83
michael@0 84 # UNEXPECTED results can be followed by one or two images
michael@0 85 $testline = &readcleanline;
michael@0 86
michael@0 87 print '<tr><td class="FAILIMAGES">';
michael@0 88
michael@0 89 if ($testline =~ /REFTEST IMAGE: (data:.*)$/) {
michael@0 90 print '<a href="' . $1 . '"><img class="testresult" src="' . $1 . '"></a>';
michael@0 91 } elsif ($testline =~ /REFTEST IMAGE 1 \(TEST\): (data:.*)$/) {
michael@0 92 $refline = &readcleanline;
michael@0 93 print '<a href="' . $1 . '"><img class="testresult" src="' . $1 . '"></a>';
michael@0 94 {
michael@0 95 die "Error on line $l" unless $refline =~ /REFTEST IMAGE 2 \(REFERENCE\): (data:.*)$/;
michael@0 96 print '<a href="' . $1 . '"><img class="testref" src="' . $1 . '"></a>';
michael@0 97 }
michael@0 98
michael@0 99 } else {
michael@0 100 die "Error on line $l";
michael@0 101 }
michael@0 102
michael@0 103 print "</td></tr>\n";
michael@0 104 } elsif (/^TEST-KNOWN-FAIL \| (.*$)/) {
michael@0 105 my $class = $randomresult ? "XFAILRANDOM" : "XFAIL";
michael@0 106 print '<tr><td class="' . $class . '">' . do_html($1) . "</td></tr>\n";
michael@0 107 } else {
michael@0 108 print STDERR "Unknown Line: " . $_ . "\n";
michael@0 109 print "<tr><td><pre>" . $_ . "</pre></td></tr>\n";
michael@0 110 }
michael@0 111 }
michael@0 112
michael@0 113 print <<EOD
michael@0 114 </table>
michael@0 115 </body>
michael@0 116 </html>
michael@0 117 EOD
michael@0 118 ;

mercurial