Francois Gouget : winetest/build-patterns: Allow expanding a test's pattern.

Alexandre Julliard julliard at winehq.org
Tue Aug 10 15:54:02 CDT 2021


Module: tools
Branch: master
Commit: 3c6c348d04784b07e3022db1b22f099f8d839bdf
URL:    https://source.winehq.org/git/tools.git/?a=commit;h=3c6c348d04784b07e3022db1b22f099f8d839bdf

Author: Francois Gouget <fgouget at codeweavers.com>
Date:   Tue Aug 10 04:42:15 2021 +0200

winetest/build-patterns: Allow expanding a test's pattern.

When some lines are omitted from a test pattern (either because they
are reruns or the specific report was explicitly deselected), add a
button to toggle showing / hiding them.

Signed-off-by: Francois Gouget <fgouget at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 winetest/build-patterns |  2 +-
 winetest/patterns.js    | 80 ++++++++++++++++++++++++++++++++++++++++++++-----
 winetest/report.css     |  4 +++
 3 files changed, 78 insertions(+), 8 deletions(-)

diff --git a/winetest/build-patterns b/winetest/build-patterns
index 474fa1f..a11c3de 100755
--- a/winetest/build-patterns
+++ b/winetest/build-patterns
@@ -1243,7 +1243,7 @@ sub write_patterns_list($$$$)
             my $tooltip = $list->{title} ? " title='$list->{title}'" : "";
             $title = "<a href='tests/$testname.html'$tooltip>$testname</a>";
         }
-        print $html "<div class='updownbar'>$title";
+        print $html "<div class='updownbar'>$title <a class='expandtest'></a>";
         print $html "<div class='ralign'>";
         if ($mainpage)
         {
diff --git a/winetest/patterns.js b/winetest/patterns.js
index 4876113..be583a5 100644
--- a/winetest/patterns.js
+++ b/winetest/patterns.js
@@ -21,6 +21,47 @@
 var hide_reruns;
 var groups;
 var cbs;
+var tests;
+
+function enableExpandButton(test)
+{
+    test.domexpand.innerHTML = '[+]';
+    test.domexpand.title = "Remove filters";
+    test.domexpand.style.display = "inline-block";
+}
+
+function expandTest(test)
+{
+    test.patlines.forEach(patline => {
+        patline.dom.style.display = patline.display;
+    });
+    test.domexpand.innerHTML = '[-]';
+    test.domexpand.title = "Apply filters";
+    test.domexpand.style.display = "inline-block";
+    test.expanded = true;
+}
+
+function reduceTest(test)
+{
+    test.patlines.forEach(patline => {
+        if (!patline.cb.checked)
+            patline.dom.style.display = 'none';
+    });
+    enableExpandButton(test);
+}
+
+function toggleTest(e)
+{
+    const domtest = e.target.closest("div.testfile");
+    const test = tests[domtest.id];
+    if (test)
+    {
+        if (e.target.innerHTML == '[+]')
+            expandTest(test);
+        else
+            reduceTest(test);
+    }
+}
 
 function refreshPage(changes, rerun_checked)
 {
@@ -49,6 +90,12 @@ function refreshPage(changes, rerun_checked)
         hide_reruns = rerun_checked;
     }
 
+    for (let key in tests)
+    {
+        if (tests[key].expanded)
+            reduceTest(tests[key]);
+    }
+
     for (let key in changes)
     {
         const cb = cbs[key];
@@ -60,8 +107,11 @@ function refreshPage(changes, rerun_checked)
             cb.patlines.forEach(patline => {
                 patline.dom.style.display = patline.display;
                 const test = patline.test;
-                if (++test.linecount == 1 && test.id != "summary")
+                test.linecount++;
+                if (test.linecount == 1 && test.id != "summary")
                     test.dom.style.display = test.display;
+                if (test.linecount == test.patlines.length)
+                    test.domexpand.style.display = "none";
             });
         }
         else
@@ -69,8 +119,11 @@ function refreshPage(changes, rerun_checked)
             cb.patlines.forEach(patline => {
                 patline.dom.style.display = "none";
                 const test = patline.test;
-                if (--test.linecount == 0 && test.id != "summary")
+                test.linecount--;
+                if (test.linecount == 0 && test.id != "summary")
                     test.dom.style.display = "none";
+                if (test.linecount == test.patlines.length - 1)
+                    enableExpandButton(test);
             });
         }
 
@@ -138,24 +191,37 @@ function init()
         domcb.addEventListener('click', toggledReportCB);
     });
 
+    tests = {};
     document.querySelectorAll("div.testfile").forEach(domtest => {
+        const domexpand = domtest.querySelector("a.expandtest");
+        domexpand.addEventListener('click', toggleTest);
+
         const test = { id: domtest.id,
                        dom: domtest,
                        display: domtest.style.display,
-                       linecount: 0
+                       domexpand: domexpand,
+                       patlines: [],
+                       linecount: 0,
+                       expanded: false
                      };
+        tests[domtest.id] = test;
 
         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
-                                 });
+                const patline = { dom: domline,
+                                  display: domline.style.display,
+                                  cb: cb,
+                                  test: test
+                                };
+                cb.patlines.push(patline);
+                test.patlines.push(patline);
                 if (cb.checked) test.linecount++;
             }
         });
+        if (test.linecount < test.patlines.length)
+            enableExpandButton(test);
     });
 
     /* When reloading a page the browser may preserve the checkbox state
diff --git a/winetest/report.css b/winetest/report.css
index d42e05d..be49a05 100644
--- a/winetest/report.css
+++ b/winetest/report.css
@@ -78,6 +78,10 @@ table.output td {
 .disabled {
     color: grey;
 }
+.expandtest {
+    display: none;
+    font-family: monospace;
+}
 
 .pattern {
     display: inline-block;




More information about the wine-cvs mailing list