Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(466)

Side by Side Diff: Tools/GardeningServer/scripts/results.js

Issue 400423002: Remove base.* methods. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2011 Google Inc. All rights reserved. 2 * Copyright (C) 2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions 5 * modification, are permitted provided that the following conditions
6 * are met: 6 * are met:
7 * 1. Redistributions of source code must retain the above copyright 7 * 1. Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * 2. Redistributions in binary form must reproduce the above copyright 9 * 2. Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 break; 123 break;
124 default: 124 default:
125 // FIXME: Add support for the rest of the result types. 125 // FIXME: Add support for the rest of the result types.
126 // '-expected.html', 126 // '-expected.html',
127 // '-expected-mismatch.html', 127 // '-expected-mismatch.html',
128 // ... and possibly more. 128 // ... and possibly more.
129 break; 129 break;
130 } 130 }
131 }); 131 });
132 132
133 return base.uniquifyArray(suffixList); 133 return suffixList.unique();
134 } 134 }
135 135
136 function failureTypeList(failureBlob) 136 function failureTypeList(failureBlob)
137 { 137 {
138 return failureBlob.split(' '); 138 return failureBlob.split(' ');
139 }; 139 };
140 140
141 function resultsDirectoryURL(builderName) 141 function resultsDirectoryURL(builderName)
142 { 142 {
143 return config.layoutTestResultsURL + '/' + config.resultsDirectoryNameFromBu ilderName(builderName) + '/results/layout-test-results/'; 143 return config.layoutTestResultsURL + '/' + config.resultsDirectoryNameFromBu ilderName(builderName) + '/results/layout-test-results/';
144 } 144 }
145 145
146 function resultsDirectoryURLForBuildNumber(builderName, buildNumber) 146 function resultsDirectoryURLForBuildNumber(builderName, buildNumber)
147 { 147 {
148 return config.layoutTestResultsURL + '/' + config.resultsDirectoryNameFromBu ilderName(builderName) + '/' + buildNumber + '/' ; 148 return config.layoutTestResultsURL + '/' + config.resultsDirectoryNameFromBu ilderName(builderName) + '/' + buildNumber + '/' ;
149 } 149 }
150 150
151 function resultsSummaryURL(builderName) 151 function resultsSummaryURL(builderName)
152 { 152 {
153 return resultsDirectoryURL(builderName) + kResultsName; 153 return resultsDirectoryURL(builderName) + kResultsName;
154 } 154 }
155 155
156 var g_resultsCache = new base.AsynchronousCache(function(key) { 156 var g_resultsCache = new base.AsynchronousCache(function(key) {
157 return net.jsonp(key); 157 return net.jsonp(key);
158 }); 158 });
159 159
160 results.ResultAnalyzer = base.extends(Object, { 160 results.ResultAnalyzer = function(resultNode)
161 init: function(resultNode) 161 {
162 { 162 this._isUnexpected = resultNode.is_unexpected;
163 this._isUnexpected = resultNode.is_unexpected; 163 this._actual = resultNode ? failureTypeList(resultNode.actual) : [];
164 this._actual = resultNode ? failureTypeList(resultNode.actual) : []; 164 this._expected = resultNode ? this._addImpliedExpectations(failureTypeList(r esultNode.expected)) : [];
165 this._expected = resultNode ? this._addImpliedExpectations(failureTypeLi st(resultNode.expected)) : []; 165 };
166 }, 166
167 results.ResultAnalyzer.prototype = {
167 _addImpliedExpectations: function(resultsList) 168 _addImpliedExpectations: function(resultsList)
168 { 169 {
169 if (resultsList.indexOf('FAIL') == -1) 170 if (resultsList.indexOf('FAIL') == -1)
170 return resultsList; 171 return resultsList;
171 return resultsList.concat(kFailingResults); 172 return resultsList.concat(kFailingResults);
172 }, 173 },
173 _hasPass: function(results) 174 _hasPass: function(results)
174 { 175 {
175 return results.indexOf(PASS) != -1; 176 return results.indexOf(PASS) != -1;
176 }, 177 },
(...skipping 11 matching lines...) Expand all
188 { 189 {
189 return this._actual.length > 1; 190 return this._actual.length > 1;
190 }, 191 },
191 wontfix: function() 192 wontfix: function()
192 { 193 {
193 return this._expected.indexOf('WONTFIX') != -1; 194 return this._expected.indexOf('WONTFIX') != -1;
194 }, 195 },
195 hasUnexpectedFailures: function() 196 hasUnexpectedFailures: function()
196 { 197 {
197 return this._isUnexpected; 198 return this._isUnexpected;
198 } 199 },
199 }); 200 };
200 201
201 function isUnexpectedFailure(resultNode) 202 function isUnexpectedFailure(resultNode)
202 { 203 {
203 var analyzer = new results.ResultAnalyzer(resultNode); 204 var analyzer = new results.ResultAnalyzer(resultNode);
204 return analyzer.hasUnexpectedFailures() && !analyzer.succeeded() && !analyze r.flaky() && !analyzer.wontfix(); 205 return analyzer.hasUnexpectedFailures() && !analyzer.succeeded() && !analyze r.flaky() && !analyzer.wontfix();
205 } 206 }
206 207
207 function isResultNode(node) 208 function isResultNode(node)
208 { 209 {
209 return !!node.actual; 210 return !!node.actual;
210 } 211 }
211 212
213 results._joinPath = function(parent, child)
214 {
215 if (parent.length == 0)
216 return child;
217 return parent + '/' + child;
218 };
219
220 results._filterTree = function(tree, isLeaf, predicate)
221 {
222 var filteredTree = {};
223
224 function walkSubtree(subtree, directory)
225 {
226 for (var childName in subtree) {
227 var child = subtree[childName];
228 var childPath = results._joinPath(directory, childName);
229 if (isLeaf(child)) {
230 if (predicate(child))
231 filteredTree[childPath] = child;
232 continue;
233 }
234 walkSubtree(child, childPath);
235 }
236 }
237
238 walkSubtree(tree, '');
239 return filteredTree;
240 };
241
212 results.unexpectedFailures = function(resultsTree) 242 results.unexpectedFailures = function(resultsTree)
213 { 243 {
214 return base.filterTree(resultsTree.tests, isResultNode, isUnexpectedFailure) ; 244 return results._filterTree(resultsTree.tests, isResultNode, isUnexpectedFail ure);
215 }; 245 };
216 246
217 function resultsByTest(resultsByBuilder, filter) 247 function resultsByTest(resultsByBuilder, filter)
218 { 248 {
219 var resultsByTest = {}; 249 var resultsByTest = {};
220 250
221 Object.keys(resultsByBuilder, function(builderName, resultsTree) { 251 Object.keys(resultsByBuilder, function(builderName, resultsTree) {
222 Object.keys(filter(resultsTree), function(testName, resultNode) { 252 Object.keys(filter(resultsTree), function(testName, resultNode) {
223 resultsByTest[testName] = resultsByTest[testName] || {}; 253 resultsByTest[testName] = resultsByTest[testName] || {};
224 resultsByTest[testName][builderName] = resultNode; 254 resultsByTest[testName][builderName] = resultNode;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
404 if (/\.wav$/.test(url)) 434 if (/\.wav$/.test(url))
405 return results.kAudioType; 435 return results.kAudioType;
406 return results.kTextType; 436 return results.kTextType;
407 } 437 }
408 438
409 function sortResultURLsBySuffix(urls) 439 function sortResultURLsBySuffix(urls)
410 { 440 {
411 var sortedURLs = []; 441 var sortedURLs = [];
412 kPreferredSuffixOrder.forEach(function(suffix) { 442 kPreferredSuffixOrder.forEach(function(suffix) {
413 urls.forEach(function(url) { 443 urls.forEach(function(url) {
414 if (!base.endsWith(url, suffix)) 444 if (!url.endsWith(suffix))
415 return; 445 return;
416 sortedURLs.push(url); 446 sortedURLs.push(url);
417 }); 447 });
418 }); 448 });
419 if (sortedURLs.length != urls.length) 449 if (sortedURLs.length != urls.length)
420 throw "sortResultURLsBySuffix failed to return the same number of URLs." ; 450 throw "sortResultURLsBySuffix failed to return the same number of URLs." ;
421 return sortedURLs; 451 return sortedURLs;
422 } 452 }
423 453
454 results._trimExtension = function(url)
455 {
456 var index = url.lastIndexOf('.');
457 if (index == -1)
458 return url;
459 return url.substr(0, index);
460 }
461
424 results.fetchResultsURLs = function(failureInfo) 462 results.fetchResultsURLs = function(failureInfo)
425 { 463 {
426 var testNameStem = base.trimExtension(failureInfo.testName); 464 var testNameStem = results._trimExtension(failureInfo.testName);
427 var urlStem = resultsDirectoryURL(failureInfo.builderName); 465 var urlStem = resultsDirectoryURL(failureInfo.builderName);
428 466
429 var suffixList = possibleSuffixListFor(failureInfo.failureTypeList); 467 var suffixList = possibleSuffixListFor(failureInfo.failureTypeList);
430 var resultURLs = []; 468 var resultURLs = [];
431 var probePromises = []; 469 var probePromises = [];
432 suffixList.forEach(function(suffix) { 470 suffixList.forEach(function(suffix) {
433 var url = urlStem + testNameStem + suffix; 471 var url = urlStem + testNameStem + suffix;
434 probePromises.push(net.probe(url).then( 472 probePromises.push(net.probe(url).then(
435 function() { 473 function() {
436 resultURLs.push(url); 474 resultURLs.push(url);
(...skipping 14 matching lines...) Expand all
451 fetchPromises.push(net.jsonp(resultsURL).then(function(resultsTree) { 489 fetchPromises.push(net.jsonp(resultsURL).then(function(resultsTree) {
452 resultsByBuilder[builderName] = resultsTree; 490 resultsByBuilder[builderName] = resultsTree;
453 })); 491 }));
454 }); 492 });
455 return Promise.all(fetchPromises).then(function() { 493 return Promise.all(fetchPromises).then(function() {
456 return resultsByBuilder; 494 return resultsByBuilder;
457 }); 495 });
458 }; 496 };
459 497
460 })(); 498 })();
OLDNEW
« no previous file with comments | « Tools/GardeningServer/scripts/net_unittests.js ('k') | Tools/GardeningServer/scripts/results_unittests.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698