This allows zooming on the results of a specific machine or test configuration.
Signed-off-by: Francois Gouget fgouget@codeweavers.com --- winetest/build-patterns | 31 ++++++++++++- winetest/patterns.js | 100 ++++++++++++++++++++++++++++++++++++++++ winetest/report.css | 6 +++ 3 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 winetest/patterns.js
diff --git a/winetest/build-patterns b/winetest/build-patterns index d530ad2f8..fc6f7edbe 100755 --- a/winetest/build-patterns +++ b/winetest/build-patterns @@ -20,6 +20,7 @@ use strict; use warnings; use open ':utf8'; use CGI qw(:standard); +use POSIX; # ceil()
use Text::CSV::Encoded; use Time::Piece; @@ -980,7 +981,7 @@ sub write_pattern_line($$$) my ($html, $test, $reportdir) = @_; my $testreport = $test->{testreports}->{$reportdir};
- print $html "<div class='pattern'>"; + print $html "<div class='patline' data-id='$reportdir'><div class='pattern'>";
my $has_newmode; my ($range_symbol, $range_count) = ("", 0); @@ -1086,7 +1087,7 @@ sub write_pattern_line($$$) } my $label = $reportdir; $label = "<b>$label</b>" if ($has_newmode); - print $html "</div> $label\n"; + print $html "</div> $label\n</div>"; }
sub index2symbol($) @@ -1288,6 +1289,7 @@ sub write_patterns_page($$$) <head> <title>$title</title> <link rel="stylesheet" href="/report.css" type="text/css"> + <script type="text/javascript" defer="true" src="/patterns.js"></script> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> </head> <body> @@ -1462,6 +1464,31 @@ EOF $tests{0}->{desc} .= "</ul>"; if (!$nolist) { + my @table = ("<details><summary>Page cutomization</summary> +<div class='detailsbox'><p>Uncheck the reports you do not want to see on this page.</p> +<table width='100%'>"); + my @reportmap; + for (my $i = 0; $i < @sortedreports; $i++) + { + my $reportdir = $sortedreports[$i]; + push @reportmap, $i if ($pagereports->{$reportdir}); + } + my $count = @reportmap; + for (my $i = 0; $i < ceil($count/4); $i++) + { + push @table, "<tr>"; + for (my $c = 0; $c < $count; $c += ceil($count/4)) + { + my $reportindex = $reportmap[$i + $c]; + last if (!defined $reportindex); + my $reportdir = $sortedreports[$reportindex] || ""; + push @table, "<td><label><input class='reportcb' type='checkbox' id='$reportdir' checked> $reportdir</label></td>"; + } + push @table, "</tr>"; + } + push @table, "</div></table></details>"; + $tests{0}->{desc} .= join("", @table); + $tests{0}->{desc} .= "<p>Unlike the other patterns on this page, the one below shows the number of failed test units for each configuration.</p>"; }
diff --git a/winetest/patterns.js b/winetest/patterns.js new file mode 100644 index 000000000..a70df079e --- /dev/null +++ b/winetest/patterns.js @@ -0,0 +1,100 @@ +/* Hide / show reports on the patterns page + * + * Copyright 2021 Francois Gouget + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + *Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +"use strict"; + +var cbs; + +function refreshPage(changes) +{ + for (let key in changes) + { + const cb = cbs[key]; + if (cb.checked == changes[key]) continue; + + if (changes[key]) + { + cb.patlines.forEach(patline => { + patline.dom.style.display = patline.display; + const test = patline.test; + if (++test.linecount == 1 && test.id != "summary") + test.dom.style.display = test.display; + }); + } + else + { + cb.patlines.forEach(patline => { + patline.dom.style.display = "none"; + const test = patline.test; + if (--test.linecount == 0 && test.id != "summary") + test.dom.style.display = "none"; + }); + } + + cb.checked = changes[key]; + } +} + +function toggledReportCB(e) +{ + const cb = e.target; + const changes = {}; + changes[cb.id] = cb.checked; + refreshPage(changes); +} + +function init() +{ + const changes = {}; + cbs = {}; + document.querySelectorAll("input.reportcb").forEach(domcb => { + cbs[domcb.id] = { checked: true, /* all reports are shown by default */ + display: domcb.style.display, + patlines: [] + }; + changes[domcb.id] = domcb.checked; + domcb.addEventListener('click', toggledReportCB); + }); + + document.querySelectorAll("div.testfile").forEach(domtest => { + const test = { id: domtest.id, + dom: domtest, + display: domtest.style.display, + linecount: 0 + }; + + domtest.querySelectorAll("div.patline").forEach(domline => { + const cb = cbs[domline.getAttribute("data-id")]; + if (cb) + { + cb.patlines.push({ dom: domline, + display: domline.style.display, + test: test + }); + if (cb.checked) test.linecount++; + } + }); + }); + + /* When reloading a page the browser may preserve the checkbox state + * so reapply them to the rest of the page. + */ + refreshPage(changes); +} + +window.addEventListener('load', init); diff --git a/winetest/report.css b/winetest/report.css index 4594c5d49..f193bc3be 100644 --- a/winetest/report.css +++ b/winetest/report.css @@ -70,6 +70,12 @@ table.output td { float: right; }
+.detailsbox { + margin: 5px 1em 0 1em; + padding: 0 5px 5px; + border: 1px solid #601919; +} + .pattern { display: inline-block; font-family: monospace;