Changeset 89838 in webkit


Ignore:
Timestamp:
Jun 27, 2011 11:27:33 AM (13 years ago)
Author:
Adam Roben
Message:

Move some inappropriate code out of Builder

Fixes <http://webkit.org/b/63406> TestFailure page's Builder class has a bunch of code that
isn't really about a builder

Reviewed by Anders Carlsson.

  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Builder.js:

(Builder.prototype.getBuildNames): Renamed from _getBuildNames, since it now needs to be
called by other objects.

  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/LayoutTestHistoryAnalyzer.js:

Added. Code came from Builder.
(LayoutTestHistoryAnalyzer):
(LayoutTestHistoryAnalyzer.prototype.start):
(LayoutTestHistoryAnalyzer.prototype._incorporateBuildHistory):

  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/LayoutTestResultsLoader.js:

Added. Code came from Builder.
(LayoutTestResultsLoader):
(LayoutTestResultsLoader.prototype.start):

  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ViewController.js:

(ViewController.prototype._displayBuilder): Changed to use LayoutTestHistoryAnalyzer.

  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html: Pull in new

scripts.

Location:
trunk/Tools
Files:
2 added
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Builder.js

    r89698 r89838  
    147147    },
    148148
    149     /*
    150      * Preiodically calls callback until all current failures have been explained. Callback is
    151      * passed an object like the following:
    152      * {
    153      *     'r12347 (681)': {
    154      *         'tooManyFailures': false,
    155      *         'tests': {
    156      *             'css1/basic/class_as_selector2.html': 'fail',
    157      *         },
    158      *     },
    159      *     'r12346 (680)': {
    160      *         'tooManyFailures': false,
    161      *         'tests': {},
    162      *     },
    163      *     'r12345 (679)': {
    164      *         'tooManyFailures': false,
    165      *         'tests': {
    166      *             'css1/basic/class_as_selector.html': 'crash',
    167      *         },
    168      *     },
    169      * },
    170      * Each build contains just the failures that a) are still occuring on the bots, and b) were new
    171      * in that build.
    172      */
    173     startFetchingBuildHistory: function(callback) {
    174         var cacheKey = '_startFetchingBuildHistory';
    175         if (!(cacheKey in this._cache))
    176             this._cache[cacheKey] = {};
    177 
    178         var history = this._cache[cacheKey];
    179 
    180         var self = this;
    181         self._getBuildNames(function(buildNames) {
    182             function inner(buildIndex) {
    183                 self._incorporateBuildHistory(buildNames, buildIndex, history, function(callAgain) {
    184                     var nextIndex = buildIndex + 1;
    185                     if (nextIndex >= buildNames.length)
    186                         callAgain = false;
    187                     callback(history, callAgain);
    188                     if (!callAgain)
    189                         return;
    190                     setTimeout(function() { inner(nextIndex) }, 0);
    191                 });
    192             }
    193             inner(0);
    194         });
    195     },
    196 
    197149    resultsDirectoryURL: function(buildName) {
    198150        return this.buildbot.resultsDirectoryURL(this.name, buildName);
     
    218170    },
    219171
    220     _getBuildNames: function(callback) {
     172    getBuildNames: function(callback) {
    221173        var cacheKey = '_getBuildNames';
    222174        if (cacheKey in this._cache) {
     
    241193        });
    242194    },
    243 
    244     _getFailingTests: function(buildName, callback, errorCallback) {
    245         var cacheKey = this.name + '__getFailingTests_' + buildName;
    246         if (PersistentCache.contains(cacheKey)) {
    247             callback(PersistentCache.get(cacheKey));
    248             return;
    249         }
    250 
    251         var tests = {};
    252 
    253         var parsedBuildName = this.buildbot.parseBuildName(buildName);
    254 
    255         // http://webkit.org/b/62380 was fixed in r89610.
    256         var resultsHTMLSupportsTooManyFailuresInfo = parsedBuildName.revision >= 89610;
    257 
    258         var self = this;
    259 
    260         function fetchAndParseResultsHTMLAndCallCallback(callback, tooManyFailures) {
    261             getResource(self.resultsPageURL(buildName), function(xhr) {
    262                 var root = document.createElement('html');
    263                 root.innerHTML = xhr.responseText;
    264 
    265                 if (resultsHTMLSupportsTooManyFailuresInfo)
    266                     tooManyFailures = root.getElementsByClassName('stopped-running-early-message').length > 0;
    267 
    268                 function testsForResultTable(regex) {
    269                     var paragraph = Array.prototype.findFirst.call(root.querySelectorAll('p'), function(paragraph) {
    270                         return regex.test(paragraph.innerText);
    271                     });
    272                     if (!paragraph)
    273                         return [];
    274                     var table = paragraph.nextElementSibling;
    275                     console.assert(table.nodeName === 'TABLE');
    276                     return Array.prototype.map.call(table.querySelectorAll('td:first-child > a'), function(elem) {
    277                         return elem.innerText;
    278                     });
    279                 }
    280 
    281                 testsForResultTable(/did not match expected results/).forEach(function(name) {
    282                     tests[name] = 'fail';
    283                 });
    284                 testsForResultTable(/timed out/).forEach(function(name) {
    285                     tests[name] = 'timeout';
    286                 });
    287                 testsForResultTable(/tool to crash/).forEach(function(name) {
    288                     tests[name] = 'crash';
    289                 });
    290                 testsForResultTable(/Web process to crash/).forEach(function(name) {
    291                     tests[name] = 'webprocess crash';
    292                 });
    293 
    294                 PersistentCache.set(cacheKey, tests);
    295                 callback(tests, tooManyFailures);
    296             },
    297             function(xhr) {
    298                 // We failed to fetch results.html. run-webkit-tests must have aborted early.
    299                 PersistentCache.set(cacheKey, tests);
    300                 errorCallback(tests, tooManyFailures);
    301             });
    302         }
    303 
    304         if (resultsHTMLSupportsTooManyFailuresInfo) {
    305             fetchAndParseResultsHTMLAndCallCallback(callback, false);
    306             return;
    307         }
    308 
    309         self.getNumberOfFailingTests(parsedBuildName.buildNumber, function(failingTestCount, tooManyFailures) {
    310             if (failingTestCount < 0) {
    311                 // The number of failing tests couldn't be determined.
    312                 PersistentCache.set(cacheKey, tests);
    313                 errorCallback(tests, tooManyFailures);
    314                 return;
    315             }
    316 
    317             if (!failingTestCount) {
    318                 // All tests passed.
    319                 PersistentCache.set(cacheKey, tests);
    320                 callback(tests, tooManyFailures);
    321                 return;
    322             }
    323 
    324             // Find out which tests failed.
    325             fetchAndParseResultsHTMLAndCallCallback(callback, tooManyFailures);
    326         });
    327     },
    328 
    329     _incorporateBuildHistory: function(buildNames, buildIndex, history, callback) {
    330         var previousBuildName = Object.keys(history).last();
    331         var nextBuildName = buildNames[buildIndex];
    332 
    333         this._getFailingTests(nextBuildName, function(tests, tooManyFailures) {
    334             history[nextBuildName] = {
    335                 tooManyFailures: tooManyFailures,
    336                 tests: {},
    337             };
    338 
    339             for (var testName in tests) {
    340                 if (previousBuildName) {
    341                     if (!(testName in history[previousBuildName].tests))
    342                         continue;
    343                     delete history[previousBuildName].tests[testName];
    344                 }
    345                 history[nextBuildName].tests[testName] = tests[testName];
    346             }
    347 
    348             callback(Object.keys(history[nextBuildName].tests).length);
    349         },
    350         function(tests) {
    351             // Some tests failed, but we couldn't fetch results.html (perhaps because the test
    352             // run aborted early for some reason). Just skip this build entirely.
    353             callback(true);
    354         });
    355     },
    356195};
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ViewController.js

    r89702 r89838  
    4949    _displayBuilder: function(builder) {
    5050        var self = this;
    51         builder.startFetchingBuildHistory(function(history, stillFetchingData) {
     51        (new LayoutTestHistoryAnalyzer(builder)).start(function(history, stillFetchingData) {
    5252            var list = document.createElement('ol');
    5353            list.id = 'failure-history';
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html

    r89695 r89838  
    3131    <script src="Buildbot.js"></script>
    3232    <script src="Builder.js"></script>
     33    <script src="LayoutTestHistoryAnalyzer.js"></script>
     34    <script src="LayoutTestResultsLoader.js"></script>
    3335    <script src="PersistentCache.js"></script>
    3436    <script src="Trac.js"></script>
  • trunk/Tools/ChangeLog

    r89837 r89838  
     12011-06-26  Adam Roben  <aroben@apple.com>
     2
     3        Move some inappropriate code out of Builder
     4
     5        Fixes <http://webkit.org/b/63406> TestFailure page's Builder class has a bunch of code that
     6        isn't really about a builder
     7
     8        Reviewed by Anders Carlsson.
     9
     10        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Builder.js:
     11        (Builder.prototype.getBuildNames): Renamed from _getBuildNames, since it now needs to be
     12        called by other objects.
     13
     14        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/LayoutTestHistoryAnalyzer.js:
     15        Added. Code came from Builder.
     16        (LayoutTestHistoryAnalyzer):
     17        (LayoutTestHistoryAnalyzer.prototype.start):
     18        (LayoutTestHistoryAnalyzer.prototype._incorporateBuildHistory):
     19
     20        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/LayoutTestResultsLoader.js:
     21        Added. Code came from Builder.
     22        (LayoutTestResultsLoader):
     23        (LayoutTestResultsLoader.prototype.start):
     24
     25        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ViewController.js:
     26        (ViewController.prototype._displayBuilder): Changed to use LayoutTestHistoryAnalyzer.
     27
     28        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html: Pull in new
     29        scripts.
     30
    1312011-05-17  Nat Duca  <nduca@chromium.org>
    232
Note: See TracChangeset for help on using the changeset viewer.