Title: [87148] trunk/Tools
Revision
87148
Author
[email protected]
Date
2011-05-24 08:09:39 -0700 (Tue, 24 May 2011)

Log Message

Make TestFailures show how many tests are failing on each tester, and omit testers with no failures

Fixes <http://webkit.org/b/61063> <rdar://problem/9460533> TestFailures page shows testers
that don't have any failing tests, which isn't useful

Reviewed by David Kilzer.

* BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Buildbot.js:
(Buildbot.prototype.getTesters): Renamed from getTesterNames. Now returns Builder objects
instead of name strings.
(Buildbot.prototype._buildersForNames): Added. Helper function to convert an array of
builder names into an array of builders.

* BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Builder.js:
(Builder.prototype.getMostRecentCompletedBuildNumber): Added. Returns the build number of
the most recently completed build, or -1 if there is no such build.
(Builder.prototype.getNumberOfFailingTests): Added. Returns the number of tests that failed
in the given build, or -1 if the number could not be determined. Some of this code came from
_getFailingTests.
(Builder.prototype._getBuildJSON): Added. Code came from _getFailingTests.
(Builder.prototype._getFailingTests): Changed to use new _getBuildJSON and
getNumberOfFailingTests functions.

* BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ViewController.js:
(ViewController.prototype._displayTesters): Get the current number of test failures for each
tester and show it in the list. Omit testers that have no failures at all. We keep the
testers and failure counts in an array and sort it before displaying the current data, as
the order in which data will be fetched is unpredictable.

Modified Paths

Diff

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Buildbot.js (87147 => 87148)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Buildbot.js	2011-05-24 14:48:24 UTC (rev 87147)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Buildbot.js	2011-05-24 15:09:39 UTC (rev 87148)
@@ -41,10 +41,10 @@
         return this._builders[name];
     },
 
-    getTesterNames: function(callback) {
-        var cacheKey = 'getTesterNames';
+    getTesters: function(callback) {
+        var cacheKey = 'getTesters';
         if (cacheKey in this._cache) {
-            callback(this._cache[cacheKey]);
+            callback(this._buildersForNames(this._cache[cacheKey]));
             return;
         }
 
@@ -57,7 +57,7 @@
             });
 
             self._cache[cacheKey] = names;
-            callback(names);
+            callback(self._buildersForNames(names));
         });
     },
 
@@ -71,4 +71,9 @@
     resultsDirectoryURL: function(builderName, buildName) {
         return this.baseURL + 'results/' + builderName + '/' + buildName + '/';
     },
+
+    _buildersForNames: function(names) {
+        var self = this;
+        return names.map(function(name) { return self.builderNamed(name) });
+    },
 };

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Builder.js (87147 => 87148)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Builder.js	2011-05-24 14:48:24 UTC (rev 87147)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Builder.js	2011-05-24 15:09:39 UTC (rev 87148)
@@ -57,6 +57,88 @@
         return diagnosticInfo[failureType];
     },
 
+    getMostRecentCompletedBuildNumber: function(callback) {
+        var cacheKey = 'getMostRecentCompletedBuildNumber';
+        if (cacheKey in this._cache) {
+            callback(this._cache[cacheKey]);
+            return;
+        }
+
+        var self = this;
+        getResource(self.buildbot.baseURL + 'json/builders/' + self.name, function(xhr) {
+            var data = ""
+
+            var oldestUnfinishedBuild = Infinity;
+            if ('currentBuilds' in data)
+                oldestUnfinishedBuild = data.currentBuilds[0];
+
+            for (var i = data.cachedBuilds.length - 1; i >= 0; --i) {
+                if (data.cachedBuilds[i] >= oldestUnfinishedBuild)
+                    continue;
+
+                self._cache[cacheKey] = data.cachedBuilds[i];
+                callback(data.cachedBuilds[i]);
+                return;
+            }
+
+            self._cache[cacheKey] = -1;
+            callback(self._cache[cacheKey]);
+        },
+        function(xhr) {
+            self._cache[cacheKey] = -1;
+            callback(self._cache[cacheKey]);
+        });
+    },
+
+    getNumberOfFailingTests: function(buildNumber, callback) {
+        var cacheKey = 'getNumberOfFailingTests_' + buildNumber;
+        if (cacheKey in this._cache) {
+            callback(this._cache[cacheKey]);
+            return;
+        }
+
+        var self = this;
+        self._getBuildJSON(buildNumber, function(data) {
+            var layoutTestStep = data.steps.findFirst(function(step) { return step.name === 'layout-test'; });
+            if (!layoutTestStep) {
+                self._cache[cacheKey] = -1;
+                callback(self._cache[cacheKey]);
+                return;
+            }
+
+            if (!('isStarted' in layoutTestStep)) {
+                // run-webkit-tests never even ran.
+                self._cache[cacheKey] = -1;
+                callback(self._cache[cacheKey]);
+                return;
+            }
+
+            if (!('results' in layoutTestStep) || layoutTestStep.results[0] === 0) {
+                // All tests passed.
+                self._cache[cacheKey] = 0;
+                callback(self._cache[cacheKey]);
+                return;
+            }
+
+            if (/^Exiting early/.test(layoutTestStep.results[1][0])) {
+                // Too many tests crashed or timed out. We can't know for sure how many failed.
+                self._cache[cacheKey] = -1;
+                callback(self._cache[cacheKey]);
+                return;
+            }
+
+            var failureCount = layoutTestStep.results[1].reduce(function(sum, outputLine) {
+                var match = /^(\d+) test cases/.exec(outputLine);
+                if (!match)
+                    return sum;
+                return sum + parseInt(match[1], 10);
+            }, 0);
+
+            self._cache[cacheKey] = failureCount;
+            callback(failureCount);
+        });
+    },
+
     /*
      * Preiodically calls callback until all current failures have been explained. Callback is
      * passed an object like the following:
@@ -99,6 +181,21 @@
         return this.buildbot.resultsDirectoryURL(this.name, buildName);
     },
 
+    _getBuildJSON: function(buildNumber, callback) {
+        var cacheKey = 'getBuildJSON_' + buildNumber;
+        if (cacheKey in this._cache) {
+            callback(this._cache[cacheKey]);
+            return;
+        }
+
+        var self = this;
+        getResource(self.buildbot.baseURL + 'json/builders/' + self.name + '/builds/' + buildNumber, function(xhr) {
+            var data = ""
+            self._cache[cacheKey] = data;
+            callback(data);
+        });
+    },
+
     _getBuildNames: function(callback) {
         var cacheKey = '_getBuildNames';
         if (cacheKey in this._cache) {
@@ -133,28 +230,22 @@
         var tests = {};
         this._cache[cacheKey] = tests;
 
+        var buildNumber = this.buildbot.parseBuildName(buildName).buildNumber;
+
         var self = this;
-        getResource(self.buildbot.baseURL + 'json/builders/' + self.name + '/builds/' + self.buildbot.parseBuildName(buildName).buildNumber, function(xhr) {
-            var data = ""
-            var layoutTestStep = data.steps.findFirst(function(step) { return step.name === 'layout-test'; });
-            if (!('isStarted' in layoutTestStep)) {
-                // run-webkit-tests never even ran.
+        self.getNumberOfFailingTests(buildNumber, function(failingTestCount) {
+            if (failingTestCount < 0) {
+                // The number of failing tests couldn't be determined.
                 errorCallback(tests);
                 return;
             }
 
-            if (!('results' in layoutTestStep) || layoutTestStep.results[0] === 0) {
+            if (!failingTestCount) {
                 // All tests passed.
                 callback(tests);
                 return;
             }
 
-            if (/^Exiting early/.test(layoutTestStep.results[1][0])) {
-                // Too many tests crashed or timed out. We can't use this test run.
-                errorCallback(tests);
-                return;
-            }
-
             // Find out which tests failed.
             getResource(self.resultsDirectoryURL(buildName) + 'results.html', function(xhr) {
                 var root = document.createElement('html');

Modified: trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ViewController.js (87147 => 87148)


--- trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ViewController.js	2011-05-24 14:48:24 UTC (rev 87147)
+++ trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ViewController.js	2011-05-24 15:09:39 UTC (rev 87148)
@@ -80,17 +80,42 @@
     },
 
     _displayTesters: function() {
-        this._buildbot.getTesterNames(function(names) {
-            var list = document.createElement('ul');
-            names.forEach(function(name) {
+        var list = document.createElement('ul');
+        var testersAndFailureCounts = [];
+
+        function updateList() {
+            testersAndFailureCounts.sort(function(a, b) { return a.tester.name.localeCompare(b.tester.name) });
+            while (list.firstChild)
+                list.removeChild(list.firstChild);
+            testersAndFailureCounts.forEach(function(testerAndFailureCount) {
+                var tester = testerAndFailureCount.tester;
+                var failureCount = testerAndFailureCount.failureCount;
+
                 var link = document.createElement('a');
-                link.href = '' + name;
-                link.appendChild(document.createTextNode(name));
+                link.href = '' + tester.name;
+                link.appendChild(document.createTextNode(tester.name));
+
                 var item = document.createElement('li');
                 item.appendChild(link);
+                item.appendChild(document.createTextNode(' (' + failureCount + ' failing tests)'));
                 list.appendChild(item);
             });
+        }
 
+        this._buildbot.getTesters(function(testers) {
+            testers.forEach(function(tester) {
+                tester.getMostRecentCompletedBuildNumber(function(buildNumber) {
+                    if (buildNumber < 0)
+                        return;
+                    tester.getNumberOfFailingTests(buildNumber, function(failureCount) {
+                        if (failureCount <= 0)
+                            return;
+                        testersAndFailureCounts.push({ tester: tester, failureCount: failureCount });
+                        updateList();
+                    });
+                });
+            });
+
             document.body.innerHTML = '';
             document.title = 'Testers';
             document.body.appendChild(list);

Modified: trunk/Tools/ChangeLog (87147 => 87148)


--- trunk/Tools/ChangeLog	2011-05-24 14:48:24 UTC (rev 87147)
+++ trunk/Tools/ChangeLog	2011-05-24 15:09:39 UTC (rev 87148)
@@ -1,3 +1,34 @@
+2011-05-24  Adam Roben  <[email protected]>
+
+        Make TestFailures show how many tests are failing on each tester, and omit testers with no failures
+
+        Fixes <http://webkit.org/b/61063> <rdar://problem/9460533> TestFailures page shows testers
+        that don't have any failing tests, which isn't useful
+
+        Reviewed by David Kilzer.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Buildbot.js:
+        (Buildbot.prototype.getTesters): Renamed from getTesterNames. Now returns Builder objects
+        instead of name strings.
+        (Buildbot.prototype._buildersForNames): Added. Helper function to convert an array of
+        builder names into an array of builders.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Builder.js:
+        (Builder.prototype.getMostRecentCompletedBuildNumber): Added. Returns the build number of
+        the most recently completed build, or -1 if there is no such build.
+        (Builder.prototype.getNumberOfFailingTests): Added. Returns the number of tests that failed
+        in the given build, or -1 if the number could not be determined. Some of this code came from
+        _getFailingTests.
+        (Builder.prototype._getBuildJSON): Added. Code came from _getFailingTests.
+        (Builder.prototype._getFailingTests): Changed to use new _getBuildJSON and
+        getNumberOfFailingTests functions.
+
+        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ViewController.js:
+        (ViewController.prototype._displayTesters): Get the current number of test failures for each
+        tester and show it in the list. Omit testers that have no failures at all. We keep the
+        testers and failure counts in an array and sort it before displaying the current data, as
+        the order in which data will be fetched is unpredictable.
+
 2011-05-23  Tony Chang  <[email protected]>
 
         Reviewed by Ojan Vafai.
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to