[tools] winetest/build-patterns: Use JavaScript to hide the WineTest reruns.

Francois Gouget fgouget at codeweavers.com
Sun Aug 8 19:19:33 CDT 2021


They are now included on all pages since they will not mess up the 
patterns.
Also reruns are now right next to the first run which makes it easier
to compare them.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
---
 winetest/build-patterns | 16 +++++---------
 winetest/patterns.js    | 49 ++++++++++++++++++++++++++++++++++++++---
 winetest/report.css     |  3 +++
 3 files changed, 54 insertions(+), 14 deletions(-)

diff --git a/winetest/build-patterns b/winetest/build-patterns
index a1691db3d..474fa1ffc 100755
--- a/winetest/build-patterns
+++ b/winetest/build-patterns
@@ -436,8 +436,7 @@ sub cmpreports
 {
     my $ra = $reports{$a};
     my $rb = $reports{$b};
-    return $ra->{is_rerun} <=> $rb->{is_rerun} ||
-           ($platform_order{$ra->{platform}} || 0) <=> ($platform_order{$rb->{platform}} || 0) ||
+    return ($platform_order{$ra->{platform}} || 0) <=> ($platform_order{$rb->{platform}} || 0) ||
            $ra->{tag} cmp $rb->{tag} ||
            ($ra->{num} || 0) <=> ($rb->{num} || 0);
 }
@@ -1465,7 +1464,8 @@ EOF
     if (!$nolist)
     {
         my @table = ("<details><summary>Page cutomization</summary>
-<div class='detailsbox'><p>This section lets you select the reports to show on this page.</p><p>");
+<div class='detailsbox'><p>This section lets you select the reports to show on this page.</p><p>
+<label><input id='reruns' type='checkbox' checked> Hide WineTest reruns</label><br>");
         if (!$subpage or $subpage eq "-tb-win")
         {
             push @table, "<label><input id='tbwin' class='groupcb' type='checkbox' checked> Show the TestBot Windows reports</label><br>";
@@ -1498,7 +1498,8 @@ EOF
                 my $reportdir = $sortedreports[$reportindex] || "";
                 my $report = $reports{$reportdir};
                 my $group = " data-group='". ($report->{tag} =~ /^newtb-/ ? "tb" : "") . ($report->{is_wine} ? "wine" : "win") ."'";
-                push @table, "<td><label><input class='reportcb'$group type='checkbox' id='$reportdir' checked> $reportdir</label></td>";
+                my $rerun = $report->{is_rerun} ? " data-rerun='1'" : "";
+                push @table, "<td><label><input class='reportcb'$group$rerun type='checkbox' id='$reportdir' checked> $reportdir</label></td>";
             }
             push @table, "</tr>";
         }
@@ -1546,13 +1547,6 @@ my %tbreports;
 foreach my $report (values %reports)
 {
     next if ($report->{tag} !~ /^newtb-/); # ignore non-TestBot reports
-    if ($report->{is_rerun})
-    {
-        # Skip reruns because they are infrequent and thus usually do not
-        # meaningfully contribute to the patterns.
-        # They can still be checked on the 'all reports' page.
-        next;
-    }
     # Windows and Wine have different failure modes so put them on separate
     # pages.
     my $page = $report->{is_wine} ? "wine" : "win";
diff --git a/winetest/patterns.js b/winetest/patterns.js
index 80ac4b868..4876113fa 100644
--- a/winetest/patterns.js
+++ b/winetest/patterns.js
@@ -18,14 +18,42 @@
  */
 "use strict";
 
+var hide_reruns;
+var groups;
 var cbs;
 
-function refreshPage(changes)
+function refreshPage(changes, rerun_checked)
 {
+    if (rerun_checked != undefined && rerun_checked != hide_reruns)
+    {
+        for (let key in cbs)
+        {
+            const cb = cbs[key];
+            if (!cb.rerun) continue;
+
+            cb.dom.disabled = rerun_checked;
+            if (rerun_checked)
+            {
+                cb.dom.parentNode.classList.add("disabled");
+                cb.dom.parentNode.title = "Reruns are hidden";
+                changes[key] = false;
+            }
+            else
+            {
+                cb.dom.parentNode.classList.remove("disabled");
+                cb.dom.parentNode.title = undefined;
+                changes[key] = groups[cb.group].checked;
+            }
+            cb.dom.checked = changes[key];
+        }
+        hide_reruns = rerun_checked;
+    }
+
     for (let key in changes)
     {
         const cb = cbs[key];
         if (cb.checked == changes[key]) continue;
+        if (cb.dom.parentNode.disabled) continue;
 
         if (changes[key])
         {
@@ -50,16 +78,22 @@ function refreshPage(changes)
     }
 }
 
+function toggledRerunCB(e)
+{
+    refreshPage({}, e.target.checked);
+}
+
 function toggledGroupCB(e)
 {
     const group = e.target.id;
     const checked = e.target.checked;
+    groups[group].checked = checked;
 
     const changes = {};
     for (let key in cbs)
     {
         const cb = cbs[key];
-        if (cb.group == group)
+        if (cb.group == group && !cb.dom.disabled)
         {
             cb.dom.checked = checked;
             changes[key] = checked;
@@ -78,7 +112,15 @@ function toggledReportCB(e)
 
 function init()
 {
+    hide_reruns = false; /* reruns are shown by default */
+    const domreruns = document.getElementById("reruns");
+    domreruns.addEventListener('click', toggledRerunCB);
+
+    groups = {};
     document.querySelectorAll("input.groupcb").forEach(domcb => {
+        groups[domcb.id] = { dom: domcb,
+                             checked: domcb.checked
+                           };
         domcb.addEventListener('click', toggledGroupCB);
     });
 
@@ -89,6 +131,7 @@ function init()
                           checked: true, /* all reports are shown by default */
                           display: domcb.style.display,
                           group: domcb.getAttribute("data-group"),
+                          rerun: domcb.getAttribute("data-rerun"),
                           patlines: []
                         };
         changes[domcb.id] = domcb.checked;
@@ -118,7 +161,7 @@ function init()
     /* When reloading a page the browser may preserve the checkbox state
      * so reapply them to the rest of the page.
      */
-    refreshPage(changes);
+    refreshPage(changes, domreruns.checked);
 }
 
 window.addEventListener('load', init);
diff --git a/winetest/report.css b/winetest/report.css
index f193bc3be..d42e05d8d 100644
--- a/winetest/report.css
+++ b/winetest/report.css
@@ -75,6 +75,9 @@ table.output td {
     padding: 0 5px 5px;
     border: 1px solid #601919;
 }
+.disabled {
+    color: grey;
+}
 
 .pattern {
     display: inline-block;
-- 
2.20.1



More information about the wine-devel mailing list