results.webkit.org: Add switch to filter results by expectation
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jul 2019 21:23:32 +0000 (21:23 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 26 Jul 2019 21:23:32 +0000 (21:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=200134

Rubber-stamped by Aakash Jain.

Users of the results database should be able to easily differentiate tests which are expected
to fail verse tests which are unexpectedly failing.

* resultsdbpy/resultsdbpy/view/static/js/timeline.js:
(Timeline.render): Respect the willFilterExpected variable.
(LegendLabel): Generates html for label in the legend.
(Legend): Add switch for filter results.
* resultsdbpy/resultsdbpy/view/templates/search.html: GIve Legend callback to re-render timelines.
* resultsdbpy/resultsdbpy/view/templates/suite_results.html:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@247877 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/resultsdbpy/resultsdbpy/view/static/js/timeline.js
Tools/resultsdbpy/resultsdbpy/view/templates/search.html
Tools/resultsdbpy/resultsdbpy/view/templates/suite_results.html

index 80363d3..3144fc2 100644 (file)
@@ -1,3 +1,20 @@
+2019-07-26  Jonathan Bedard  <jbedard@apple.com>
+
+        results.webkit.org: Add switch to filter results by expectation
+        https://bugs.webkit.org/show_bug.cgi?id=200134
+
+        Rubber-stamped by Aakash Jain.
+
+        Users of the results database should be able to easily differentiate tests which are expected
+        to fail verse tests which are unexpectedly failing.
+
+        * resultsdbpy/resultsdbpy/view/static/js/timeline.js:
+        (Timeline.render): Respect the willFilterExpected variable.
+        (LegendLabel): Generates html for label in the legend.
+        (Legend): Add switch for filter results.
+        * resultsdbpy/resultsdbpy/view/templates/search.html: GIve Legend callback to re-render timelines.
+        * resultsdbpy/resultsdbpy/view/templates/suite_results.html:
+
 2019-07-26  Aakash Jain  <aakash_jain@apple.com>
 
         [ews-build] Use update-webkit script in Style EWS
index 4c484e6..b37b857 100644 (file)
@@ -24,7 +24,7 @@
 import {CommitBank} from '/assets/js/commit.js';
 import {Configuration} from '/assets/js/configuration.js';
 import {deepCompare, ErrorDisplay, paramsToQuery, queryToParams} from '/assets/js/common.js';
-import {DOM, REF} from '/library/js/Ref.js';
+import {DOM, EventStream, REF} from '/library/js/Ref.js';
 
 
 const DEFAULT_LIMIT = 100;
@@ -69,6 +69,7 @@ class Expectations
         return result;
     }
 }
+let willFilterExpected = false;
 
 function tickForCommit(commit, scale) {
     let params = {
@@ -533,17 +534,19 @@ class Timeline {
                                     if (pairForIndex.results[resultIndex].stats)
                                         dots[configurationKey].push(new Dot(
                                             pairForIndex.results[resultIndex].stats.tests_run,
-                                            pairForIndex.results[resultIndex].stats.tests_unexpected_failed,
-                                            pairForIndex.results[resultIndex].stats.tests_unexpected_timedout,
-                                            pairForIndex.results[resultIndex].stats.tests_unexpected_crashed,
+                                            pairForIndex.results[resultIndex].stats[`tests${willFilterExpected ? '_unexpected_' : '_'}failed`],
+                                            pairForIndex.results[resultIndex].stats[`tests${willFilterExpected ? '_unexpected_' : '_'}timedout`],
+                                            pairForIndex.results[resultIndex].stats[`tests${willFilterExpected ? '_unexpected_' : '_'}crashed`],
                                             false,
                                             buildLink,
                                         ));
                                     else {
-                                        const resultId = Expectations.stringToStateId(Expectations.unexpectedResults(
-                                            pairForIndex.results[resultIndex].actual,
-                                            pairForIndex.results[resultIndex].expected,
-                                        ));
+                                        let resultId = Expectations.stringToStateId(pairForIndex.results[resultIndex].actual);
+                                        if (willFilterExpected)
+                                            resultId = Expectations.stringToStateId(Expectations.unexpectedResults(
+                                                pairForIndex.results[resultIndex].actual,
+                                                pairForIndex.results[resultIndex].expected,
+                                            ));
 
                                         dots[configurationKey].push(new Dot(
                                             1,
@@ -600,29 +603,81 @@ class Timeline {
     }
 }
 
-function Legend() {
-    return `<div class="content">
-            <br>
-            <div class="lengend timeline">
-                <div class="item">
-                    <div class="dot success"></div>
-                    <div class="label">All Tests Passed</div>
-                </div>
-                <div class="item">
-                    <div class="dot failed"></div>
-                    <div class="label">Some Tests Failed</div>
-                </div>
-                <div class="item">
-                    <div class="dot timeout"></div>
-                    <div class="label">Some Tests Timed-Out</div>
-                </div>
-                <div class="item">
-                    <div class="dot crash"></div>
-                    <div class="label">Some Tests Crashed</div>
-                </div>
+function LegendLabel(eventStream, filterExpectedText, filterUnexpectedText) {
+    let ref = REF.createRef({
+        state: willFilterExpected,
+        onStateUpdate: (element, state) => {
+            if (state) element.innerText = filterExpectedText;
+            else element.innerText = filterUnexpectedText;
+        }
+    });
+    eventStream.action((willFilterExpected) => ref.setState(willFilterExpected));
+    return `<div class="label" ref="${ref}"></div>`;
+} 
+
+function Legend(callback=null, plural=false) {
+    let updateLabelEvents = new EventStream();
+    let result = `<br>
+         <div class="lengend timeline">
+            <div class="item">
+                <div class="dot success"></div>
+                ${LegendLabel(
+                    updateLabelEvents,
+                    plural ? 'No unexpected results' : 'Result expected',
+                    plural ? 'All tests passed' : 'Test passed',
+                )}
+            </div>
+            <div class="item">
+                <div class="dot failed"></div>
+                ${LegendLabel(
+                    updateLabelEvents,
+                    plural ? 'Some tests unexpectedly failed' : 'Unexpectedly failed',
+                    plural ? 'Some tests failed' : 'Test failed',
+                )}
+            </div>
+            <div class="item">
+                <div class="dot timeout"></div>
+                ${LegendLabel(
+                    updateLabelEvents,
+                    plural ? 'Some tests unexpectedly timed out' : 'Unexpectedly timed out',
+                    plural ? 'Some tests timed out' : 'Test timed out',
+                )}
+            </div>
+            <div class="item">
+                <div class="dot crash"></div>
+                ${LegendLabel(
+                    updateLabelEvents,
+                    plural ? 'Some tests unexpectedly crashed' : 'Unexpectedly crashed',
+                    plural ? 'Some tests crashed' : 'Test crashed',
+                )}
             </div>
             <br>
         </div>`;
+
+    if (callback) {
+        const swtch = REF.createRef({
+            onElementMount: (element) => {
+                element.onchange = () => {
+                    if (element.checked)
+                        willFilterExpected = true;
+                    else
+                        willFilterExpected = false;
+                    updateLabelEvents.add(willFilterExpected);
+                    callback();
+                };
+            },
+        });
+
+        result += `<div class="input" style="width:400px">
+            <label>Filter expected results</label>
+            <label class="switch">
+                <input type="checkbox"${willFilterExpected ? ' checked': ''} ref="${swtch}">
+                <span class="slider"></span>
+            </label>
+        </div>`;
+    }
+
+    return `<div class="content">${result}</div><br>`;
 }
 
 export {Legend, Timeline, Expectations};
index aea0280..c356feb 100644 (file)
@@ -127,7 +127,11 @@ class SearchView {
                 }
 
                 if (diff.children)
-                    DOM.inject(element, Legend() + diff.children.map(renderChild).join(''));
+                    DOM.inject(element, Legend(() => {
+                        self.ref.state.children.forEach((child) => {
+                            child.timeline.rerender();
+                        });
+                    }, false) + diff.children.map(renderChild).join(''));
                 if (diff.prepending) {
                     diff.prepending.forEach(child => {
                         DOM.after(element.firstElementChild, renderChild(child));
index 58db87a..873fcf1 100644 (file)
@@ -141,7 +141,11 @@ class MainView {
     }
     render(suites) {
         let children = this.children;
-        return Legend() + suites.map(suite => {
+        return Legend(() => {
+            for (let suite in children) {
+                children[suite].rerender();
+            }
+        }, true) + suites.map(suite => {
             return `<div class="section">
                     <div class="header">
                         <div class="title">${suite}</div>