Changeset 91538 in webkit


Ignore:
Timestamp:
Jul 21, 2011 5:29:31 PM (13 years ago)
Author:
abarth@webkit.org
Message:

Refactor Trac.js for use in garden-o-matic
https://bugs.webkit.org/show_bug.cgi?id=64998

Reviewed by Adam Roben.

This patch refactors Trac.js to match the architecture and style of
garden-o-matic. I've also factored AsynchronousCache out of Trac (and
moved it to base) because it was redundant with some other code we
already had.

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

(FailingTestsBugForm):

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

(ViewController.prototype._displayBuilder.start):
(ViewController.prototype._displayBuilder):
(ViewController.prototype._domForRegressionRange.trac.getCommitDataForRevisionRange):
(ViewController.prototype._domForRegressionRange):

  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/base.js:
  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/config.js:
  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html:
  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/results.js:
  • BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/run-unittests.html:
Location:
trunk/Tools
Files:
10 edited

Legend:

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

    r91272 r91538  
    2424 */
    2525
    26 function FailingTestsBugForm(bugzilla, trac, tester, failingBuildName, passingBuildName, failingTests) {
     26function FailingTestsBugForm(bugzilla, tester, failingBuildName, passingBuildName, failingTests) {
    2727    TestRelatedBugForm.call(this, bugzilla, tester);
    2828
    29     this._trac = trac;
    3029    this._failingBuildName = failingBuildName;
    3130    this._passingBuildName = passingBuildName;
     
    4948            endOfFirstSentence = 'started failing on ' + this._tester.name;
    5049            if (firstSuspectRevision === lastSuspectRevision)
    51                 endOfFirstSentence += ' in r' + firstSuspectRevision + ' <' + this._trac.changesetURL(firstSuspectRevision) + '>';
     50                endOfFirstSentence += ' in r' + firstSuspectRevision + ' <' + trac.changesetURL(firstSuspectRevision) + '>';
    5251            else
    5352                endOfFirstSentence += ' between r' + firstSuspectRevision + ' and r' + lastSuspectRevision + ' (inclusive)';
    5453        } else
    55             endOfFirstSentence = (this._failingTests.length === 1 ? 'has' : 'have') + ' been failing on ' + this._tester.name + ' since at least r' + firstSuspectRevision + ' <' + this._trac.changesetURL(firstSuspectRevision) + '>';
     54            endOfFirstSentence = (this._failingTests.length === 1 ? 'has' : 'have') + ' been failing on ' + this._tester.name + ' since at least r' + firstSuspectRevision + ' <' + trac.changesetURL(firstSuspectRevision) + '>';
    5655        var description;
    5756        if (this._failingTests.length === 1)
     
    6564        }
    6665        if (firstSuspectRevision !== lastSuspectRevision)
    67             description += this._trac.logURL('trunk', firstSuspectRevision, lastSuspectRevision) + '\n\n';
     66            description += trac.logURL('trunk', firstSuspectRevision, lastSuspectRevision) + '\n\n';
    6867        if (this._passingBuildName)
    6968            description += this._tester.resultsPageURL(this._passingBuildName) + ' passed\n';
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/FailingTestsBugForm_unittests.js

    r91272 r91538  
    3232    mockBugzilla.baseURL = '[BUGZILLA BASE URL]';
    3333
    34     var mockTrac = {};
    35     mockTrac.changesetURL = function(revisionNumber) {
    36         return '[CHANGESET URL r' + revisionNumber + ']';
    37     }
    38     mockTrac.logURL = function(path, startRevision, endRevision) {
    39         return '[LOG URL ' + path + ', r' + startRevision + ', r' + endRevision + ']';
    40     }
    41 
    4234    var mockBuildbot = {};
    4335    mockBuildbot.parseBuildName = function(buildName) {
     
    5648    }
    5749
    58     return new FailingTestsBugForm(mockBugzilla, mockTrac, mockBuilder, failingBuildName, passingBuildName, failingTests);
     50    return new FailingTestsBugForm(mockBugzilla, mockBuilder, failingBuildName, passingBuildName, failingTests);
    5951}
    6052
     
    7163            'css1/basic/class_as_selector.html',
    7264        ],
    73         expectedDescription: 'css1/basic/class_as_selector.html has been failing on Windows 7 Release (Tests) since at least r10 <[CHANGESET URL r10]>.\n\n[RESULTS PAGE URL Windows 7 Release (Tests), r10 (5)] failed\n',
     65        expectedDescription: 'css1/basic/class_as_selector.html has been failing on Windows 7 Release (Tests) since at least r10 <http://trac.webkit.org/changeset/10>.\n\n[RESULTS PAGE URL Windows 7 Release (Tests), r10 (5)] failed\n',
    7466        expectedTitle: 'REGRESSION (r10): css1/basic/class_as_selector.html failing on Windows 7 Release (Tests)',
    7567    },
     
    8072            'css1/basic/class_as_selector.html',
    8173        ],
    82         expectedDescription: 'css1/basic/class_as_selector.html started failing on Windows 7 Release (Tests) in r10 <[CHANGESET URL r10]>.\n\n[RESULTS PAGE URL Windows 7 Release (Tests), r9 (3)] passed\n[RESULTS PAGE URL Windows 7 Release (Tests), r10 (5)] failed\n',
     74        expectedDescription: 'css1/basic/class_as_selector.html started failing on Windows 7 Release (Tests) in r10 <http://trac.webkit.org/changeset/10>.\n\n[RESULTS PAGE URL Windows 7 Release (Tests), r9 (3)] passed\n[RESULTS PAGE URL Windows 7 Release (Tests), r10 (5)] failed\n',
    8375        expectedTitle: 'REGRESSION (r10): css1/basic/class_as_selector.html failing on Windows 7 Release (Tests)',
    8476    },
     
    8981            'css1/basic/class_as_selector.html',
    9082        ],
    91         expectedDescription: 'css1/basic/class_as_selector.html started failing on Windows 7 Release (Tests) between r9 and r10 (inclusive).\n\n[LOG URL trunk, r9, r10]\n\n[RESULTS PAGE URL Windows 7 Release (Tests), r8 (2)] passed\n[RESULTS PAGE URL Windows 7 Release (Tests), r10 (5)] failed\n',
     83        expectedDescription: 'css1/basic/class_as_selector.html started failing on Windows 7 Release (Tests) between r9 and r10 (inclusive).\n\nhttp://trac.webkit.org/log/trunk?rev=10&stop_rev=9\n\n[RESULTS PAGE URL Windows 7 Release (Tests), r8 (2)] passed\n[RESULTS PAGE URL Windows 7 Release (Tests), r10 (5)] failed\n',
    9284        expectedTitle: 'REGRESSION (r8-r10): css1/basic/class_as_selector.html failing on Windows 7 Release (Tests)',
    9385    },
     
    9991            'fast/css/ex-after-font-variant.html',
    10092        ],
    101         expectedDescription: 'css1/basic/class_as_selector.html and fast/css/ex-after-font-variant.html started failing on Windows 7 Release (Tests) between r9 and r10 (inclusive).\n\n[LOG URL trunk, r9, r10]\n\n[RESULTS PAGE URL Windows 7 Release (Tests), r8 (2)] passed\n[RESULTS PAGE URL Windows 7 Release (Tests), r10 (5)] failed\n',
     93        expectedDescription: 'css1/basic/class_as_selector.html and fast/css/ex-after-font-variant.html started failing on Windows 7 Release (Tests) between r9 and r10 (inclusive).\n\nhttp://trac.webkit.org/log/trunk?rev=10&stop_rev=9\n\n[RESULTS PAGE URL Windows 7 Release (Tests), r8 (2)] passed\n[RESULTS PAGE URL Windows 7 Release (Tests), r10 (5)] failed\n',
    10294        expectedTitle: 'REGRESSION (r8-r10): css1/basic/class_as_selector.html, fast/css/ex-after-font-variant.html failing on Windows 7 Release (Tests)',
    10395    },
     
    115107            'css1/basic/class_as_selector8.html',
    116108        ],
    117         expectedDescription: 'The following tests started failing on Windows 7 Release (Tests) between r9 and r10 (inclusive):\n\n    css1/basic/class_as_selector1.html\n    css1/basic/class_as_selector2.html\n    css1/basic/class_as_selector3.html\n    css1/basic/class_as_selector4.html\n    css1/basic/class_as_selector5.html\n    css1/basic/class_as_selector6.html\n    css1/basic/class_as_selector7.html\n    css1/basic/class_as_selector8.html\n\n[LOG URL trunk, r9, r10]\n\n[RESULTS PAGE URL Windows 7 Release (Tests), r8 (2)] passed\n[RESULTS PAGE URL Windows 7 Release (Tests), r10 (5)] failed\n',
     109        expectedDescription: 'The following tests started failing on Windows 7 Release (Tests) between r9 and r10 (inclusive):\n\n    css1/basic/class_as_selector1.html\n    css1/basic/class_as_selector2.html\n    css1/basic/class_as_selector3.html\n    css1/basic/class_as_selector4.html\n    css1/basic/class_as_selector5.html\n    css1/basic/class_as_selector6.html\n    css1/basic/class_as_selector7.html\n    css1/basic/class_as_selector8.html\n\nhttp://trac.webkit.org/log/trunk?rev=10&stop_rev=9\n\n[RESULTS PAGE URL Windows 7 Release (Tests), r8 (2)] passed\n[RESULTS PAGE URL Windows 7 Release (Tests), r10 (5)] failed\n',
    118110        expectedTitle: 'REGRESSION (r8-r10): 8 css1/basic tests failing on Windows 7 Release (Tests)',
    119111    },
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Trac.js

    r90639 r91538  
    2424 */
    2525
    26 function Trac(baseURL) {
    27     this.baseURL = baseURL;
    28     this._cache = {};
     26var trac = trac || {};
     27
     28(function() {
     29
     30function parseCommitData(responseXML)
     31{
     32    var commits = Array.prototype.map.call(responseXML.getElementsByTagName('item'), function(item) {
     33        var title = item.getElementsByTagName('title')[0].textContent;
     34        var revision = parseInt(/^Revision (\d+):/.exec(title)[1], 10);
     35
     36        var container = document.createElement('div');
     37        container.innerHTML = item.getElementsByTagName('description')[0].textContent;
     38
     39        return {
     40            revision: revision,
     41            title: title,
     42            // FIXME: This isn't a very high-fidelity reproduction of the commit message,
     43            // but it's good enough for our purposes.
     44            message: container.innerText,
     45        };
     46    });
     47
     48    return commits;
    2949}
    3050
    31 Trac.prototype = {
    32     changesetURL: function(revision) {
    33         return this.baseURL + 'changeset/' + revision;
    34     },
     51var g_cache = new base.AsynchronousCache(function(key, callback) {
     52    var explodedKey = key.split('\n');
    3553
    36     getCommitDataForRevisionRange: function(path, startRevision, endRevision, callback) {
    37         // FIXME: We could try to be smarter and cache individual commits, but in practice we just
    38         // get called with the same parameters over and over.
    39         var cacheKey = 'getCommitDataForRevisionRange.' + [path, startRevision, endRevision].join('.');
    40         if (cacheKey in this._cache) {
    41             callback(this._cache[cacheKey]);
    42             return;
    43         }
     54    var path = explodedKey[0];
     55    var startRevision = explodedKey[1];
     56    var endRevision = explodedKey[2];
    4457
    45         var callbacksCacheKey = 'callbacks.' + cacheKey;
    46         if (callbacksCacheKey in this._cache) {
    47             this._cache[callbacksCacheKey].push(callback);
    48             return;
    49         }
     58    var url = trac.logURL(path, startRevision, endRevision, true, true);
    5059
    51         this._cache[callbacksCacheKey] = [callback];
     60    $.get(url, function(commitData) {
     61        callback(parseCommitData(commitData));
     62    });
     63});
    5264
    53         var self = this;
     65trac.changesetURL = function(revision)
     66{
     67    return config.kTracURL + '/changeset/' + revision;
     68};
    5469
    55         function cacheResultsAndCallCallbacks(commits) {
    56             self._cache[cacheKey] = commits;
     70trac.logURL = function(path, startRevision, endRevision, showFullCommitLogs, formatAsRSS)
     71{
     72    var queryParameters = {
     73        rev: endRevision,
     74        stop_rev: startRevision,
     75    };
    5776
    58             var callbacks = self._cache[callbacksCacheKey];
    59             delete self._cache[callbacksCacheKey];
     77    if (showFullCommitLogs)
     78        queryParameters.verbose = 'on';
     79    if (formatAsRSS)
     80        queryParameters.format = 'rss';
    6081
    61             callbacks.forEach(function(callback) {
    62                 callback(commits);
    63             });
    64         }
     82    return config.kTracURL + '/log/' + path + '?' + $.param(queryParameters);
     83};
    6584
    66         getResource(self.logURL('trunk', startRevision, endRevision, true, true), function(xhr) {
    67             var commits = Array.prototype.map.call(xhr.responseXML.getElementsByTagName('item'), function(item) {
    68                 var title = item.getElementsByTagName('title')[0].textContent;
    69                 var revision = parseInt(/^Revision (\d+):/.exec(title)[1], 10);
     85trac.commitDataForRevisionRange = function(path, startRevision, endRevision, callback)
     86{
     87    var key = [path, startRevision, endRevision].join('\n');
     88    g_cache.get(key, callback);
     89};
    7090
    71                 var container = document.createElement('div');
    72                 container.innerHTML = item.getElementsByTagName('description')[0].textContent;
    73 
    74                 return {
    75                     revision: revision,
    76                     title: title,
    77                     // FIXME: This isn't a very high-fidelity reproduction of the commit message,
    78                     // but it's good enough for our purposes.
    79                     message: container.innerText,
    80                 };
    81             });
    82 
    83             cacheResultsAndCallCallbacks(commits);
    84         },
    85         function(xhr) {
    86             cacheResultsAndCallCallbacks([]);
    87         });
    88     },
    89 
    90     logURL: function(path, startRevision, endRevision, showFullCommitLogs, formatAsRSS) {
    91         var queryParameters = {
    92             rev: endRevision,
    93             stop_rev: startRevision,
    94         };
    95         if (showFullCommitLogs)
    96             queryParameters.verbose = 'on';
    97         if (formatAsRSS)
    98             queryParameters.format = 'rss';
    99         return addQueryParametersToURL(this.baseURL + 'log/' + path, queryParameters);
    100     },
    101 };
     91})();
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ViewController.js

    r91278 r91538  
    2424 */
    2525
    26 function ViewController(buildbot, bugzilla, trac) {
     26function ViewController(buildbot, bugzilla) {
    2727    this._buildbot = buildbot;
    2828    this._bugzilla = bugzilla;
    29     this._trac = trac;
    3029    this._navigationID = 0;
    3130
     
    105104
    106105                if (passingBuildName || !stillFetchingData) {
    107                     var bugForm = new FailingTestsBugForm(self._bugzilla, self._trac, builder, buildName, passingBuildName, failingTestNames);
     106                    var bugForm = new FailingTestsBugForm(self._bugzilla, builder, buildName, passingBuildName, failingTestNames);
    108107                    item.appendChild(self._domForNewAndExistingBugs(builder, failingTestNames, bugForm))
    109108                }
     
    199198        result.appendChild(link);
    200199
    201         link.href = this._trac.logURL('trunk', firstSuspectRevision, lastSuspectRevision, true);
     200        link.href = trac.logURL('trunk', firstSuspectRevision, lastSuspectRevision, true);
    202201        link.appendChild(document.createTextNode('View regression range in Trac'));
    203202
     
    206205        // FIXME: Maybe some of this code should go in LayoutTestHistoryAnalyzer, or some other class?
    207206        var self = this;
    208         self._trac.getCommitDataForRevisionRange('trunk', firstSuspectRevision, lastSuspectRevision, function(commits) {
     207        trac.getCommitDataForRevisionRange('trunk', firstSuspectRevision, lastSuspectRevision, function(commits) {
    209208            var failingTestNamesWithoutExtensions = failingTestNames.map(removePathExtension);
    210209            var suspectCommits = commits.filter(function(commit) {
     
    235234                item.appendChild(link);
    236235
    237                 link.href = self._trac.changesetURL(commit.revision);
     236                link.href = trac.changesetURL(commit.revision);
    238237                link.appendChild(document.createTextNode(commit.title))
    239238
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/base.js

    r91519 r91538  
    147147};
    148148
     149base.AsynchronousCache = function(fetch)
     150{
     151    this._fetch = fetch;
     152    this._dataCache = {};
     153    this._callbackCache = {};
     154};
     155
     156base.AsynchronousCache.prototype.get = function(key, callback)
     157{
     158    var self = this;
     159
     160    if (self._dataCache[key]) {
     161        // FIXME: Consider always calling callback asynchronously.
     162        callback(self._dataCache[key]);
     163        return;
     164    }
     165
     166    if (key in self._callbackCache) {
     167        self._callbackCache[key].push(callback);
     168        return;
     169    }
     170
     171    self._callbackCache[key] = [callback];
     172
     173    self._fetch.call(null, key, function(data) {
     174        self._dataCache[key] = data;
     175
     176        var callbackList = self._callbackCache[key];
     177        delete self._callbackCache[key];
     178
     179        callbackList.forEach(function(cachedCallback) {
     180            cachedCallback(data);
     181        });
     182    });
     183};
     184
    149185})();
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/config.js

    r91519 r91538  
    3030];
    3131
     32config.kTracURL = 'http://trac.webkit.org';
     33
    3234config.kTestNameAttr = 'data-test-name';
    3335config.kBuilderNameAttr = 'data-builder-name';
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html

    r91278 r91538  
    2828<head>
    2929    <link rel="stylesheet" href="TestFailures.css"></link>
     30    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
     31
     32    <script src="config.js"></script>
     33    <script src="base.js"></script>
     34    <script src="Trac.js"></script>
     35
    3036    <script src="Utilities.js"></script>
    3137    <script src="NewBugForm.js"></script>
     
    4349    <script src="ORWTResultsParser.js"></script>
    4450    <script src="PersistentCache.js"></script>
    45     <script src="Trac.js"></script>
    4651    <script src="ViewController.js"></script>
    4752    <script src="WebKitBugzilla.js"></script>
    4853    <script src="WebKitBuildbot.js"></script>
    4954    <script>
    50         var viewController = new ViewController(new WebKitBuildbot(), new Bugzilla('https://bugs.webkit.org/'), new Trac('http://trac.webkit.org/'));
     55        var viewController = new ViewController(new WebKitBuildbot(), new Bugzilla('https://bugs.webkit.org/'));
    5156    </script>
    5257</head>
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/results.js

    r91519 r91538  
    158158}
    159159
    160 function ResultsCache()
    161 {
    162     this._cache = {};
    163 }
    164 
    165 ResultsCache.prototype._fetch = function(key, callback)
    166 {
    167     var self = this;
    168 
    169     var url = kTestResultsServer + 'testfile?key=' + key;
    170     base.jsonp(url, function (resultsTree) {
    171         self._cache[key] = resultsTree;
    172         callback(resultsTree);
    173     });
    174 };
    175 
    176 // Warning! This function can call callback either synchronously or asynchronously.
    177 // FIXME: Consider using setTimeout to make this method always asynchronous.
    178 ResultsCache.prototype.get = function(key, callback)
    179 {
    180     if (this._cache[key]) {
    181         callback(this._cache[key]);
    182         return;
    183     }
    184     this._fetch(key, callback);
    185 };
    186 
    187 var g_resultsCache = new ResultsCache();
     160var g_resultsCache = new base.AsynchronousCache(function(key, callback) {
     161    base.jsonp(kTestResultsServer + 'testfile?key=' + key, callback);
     162});
    188163
    189164function anyIsFailure(resultsList)
  • trunk/Tools/BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/run-unittests.html

    r91524 r91538  
    1212<h2 id="qunit-userAgent"></h2>
    1313<ol id="qunit-tests"></ol>
     14
     15<script src="config.js"></script>
     16<script src="base.js"></script>
     17<script src="base_unittests.js"></script>
     18<script src="Trac.js"></script>
     19<script src="trac_unittests.js"></script>
     20<script src="checkout.js"></script>
     21<script src="checkout_unittests.js"></script>
     22<script src="results.js"></script>
     23<script src="results_unittests.js"></script>
     24<script src="ui.js"></script>
     25<script src="ui_unittests.js"></script>
     26
    1427<!-- FIXME: We should have tests for these files! -->
    1528<script src="Bugzilla.js"></script>
     
    4053<script src="Builder_unittests.js"></script>
    4154
    42 <script src="config.js"></script>
    43 <script src="base.js"></script>
    44 <script src="base_unittests.js"></script>
    45 <script src="checkout.js"></script>
    46 <script src="checkout_unittests.js"></script>
    47 <script src="results.js"></script>
    48 <script src="results_unittests.js"></script>
    49 <script src="ui.js"></script>
    50 <script src="ui_unittests.js"></script>
    5155</body>
    5256</html>
  • trunk/Tools/ChangeLog

    r91529 r91538  
     12011-07-21  Adam Barth  <abarth@webkit.org>
     2
     3        Refactor Trac.js for use in garden-o-matic
     4        https://bugs.webkit.org/show_bug.cgi?id=64998
     5
     6        Reviewed by Adam Roben.
     7
     8        This patch refactors Trac.js to match the architecture and style of
     9        garden-o-matic.  I've also factored AsynchronousCache out of Trac (and
     10        moved it to base) because it was redundant with some other code we
     11        already had.
     12
     13        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/FailingTestsBugForm.js:
     14        (FailingTestsBugForm):
     15        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/FailingTestsBugForm_unittests.js:
     16        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/Trac.js:
     17        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/ViewController.js:
     18        (ViewController.prototype._displayBuilder.start):
     19        (ViewController.prototype._displayBuilder):
     20        (ViewController.prototype._domForRegressionRange.trac.getCommitDataForRevisionRange):
     21        (ViewController.prototype._domForRegressionRange):
     22        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/base.js:
     23        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/config.js:
     24        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/index.html:
     25        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/results.js:
     26        * BuildSlaveSupport/build.webkit.org-config/public_html/TestFailures/run-unittests.html:
     27
    1282011-07-21  Ojan Vafai  <ojan@chromium.org>
    229
Note: See TracChangeset for help on using the changeset viewer.