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

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

Issue 402603007: Get sheriff-o-matic data from auto-sheriff.appspot.com. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: update and delete old code 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 13 matching lines...) Expand all
24 */ 24 */
25 25
26 var unittest = unittest || {}; 26 var unittest = unittest || {};
27 27
28 (function () { 28 (function () {
29 29
30 module("results"); 30 module("results");
31 31
32 var MockResultsBaseURL = 'https://storage.googleapis.com/chromium-layout-test-ar chives/Mock_Builder/results/layout-test-results'; 32 var MockResultsBaseURL = 'https://storage.googleapis.com/chromium-layout-test-ar chives/Mock_Builder/results/layout-test-results';
33 33
34 unittest.kExampleResultsJSON = {
35 "tests": {
36 "scrollbars": {
37 "custom-scrollbar-with-incomplete-style.html": {
38 "expected": "IMAGE",
39 "actual": "IMAGE",
40 },
41 "expected-wontfix": {
42 "expected": "WONTFIX",
43 "actual": "SKIP",
44 },
45 "flaky-scrollbar.html": {
46 "expected": "PASS",
47 "actual": "PASS TEXT",
48 "is_unexpected": true,
49 },
50 "unexpected-failing-flaky-scrollbar.html": {
51 "expected": "TEXT",
52 "actual": "TIMEOUT TEXT",
53 "is_unexpected": true,
54 },
55 "unexpected-pass.html": {
56 "expected": "FAIL",
57 "actual": "PASS",
58 "is_unexpected": true,
59 }
60 },
61 "userscripts": {
62 "user-script-video-document.html": {
63 "expected": "FAIL",
64 "actual": "TEXT",
65 },
66 "another-test.html": {
67 "expected": "PASS",
68 "actual": "TEXT",
69 "is_unexpected": true,
70 }
71 },
72 },
73 "skipped": 339,
74 "num_regressions": 14,
75 "interrupted": false,
76 "layout_tests_dir": "\/mnt\/data\/b\/build\/slave\/Webkit_Linux\/build\/src\ /third_party\/WebKit\/LayoutTests",
77 "version": 3,
78 "num_passes": 15566,
79 "has_pretty_patch": false,
80 "fixable": 1233,
81 "num_flaky":1,
82 "has_wdiff": true,
83 "blink_revision": "90430"
84 };
85
86 test("ResultAnalyzer", 44, function() {
87 var analyzer;
88
89 analyzer = new results.ResultAnalyzer({expected: 'PASS', actual: 'TEXT', is_ unexpected: true});
90 ok(analyzer.hasUnexpectedFailures());
91 deepEqual(analyzer.unexpectedResults(), ['TEXT']);
92 ok(!analyzer.succeeded());
93 ok(!analyzer.flaky());
94
95 analyzer = new results.ResultAnalyzer({expected: 'PASS TIMEOUT', actual: 'TE XT', is_unexpected: true});
96 ok(analyzer.hasUnexpectedFailures());
97 deepEqual(analyzer.unexpectedResults(), ['TEXT']);
98 ok(!analyzer.succeeded());
99 ok(!analyzer.flaky());
100
101 analyzer = new results.ResultAnalyzer({expected: 'TEXT', actual: 'TEXT TIMEO UT', is_unexpected: true});
102 ok(analyzer.hasUnexpectedFailures());
103 deepEqual(analyzer.unexpectedResults(), ['TIMEOUT']);
104 ok(!analyzer.succeeded());
105 ok(analyzer.flaky());
106
107 analyzer = new results.ResultAnalyzer({expected: 'PASS', actual: 'TEXT TIMEO UT', is_unexpected: true});
108 ok(analyzer.hasUnexpectedFailures());
109 deepEqual(analyzer.unexpectedResults(), ['TEXT', 'TIMEOUT']);
110 ok(!analyzer.succeeded());
111 ok(analyzer.flaky());
112
113 analyzer = new results.ResultAnalyzer({expected: 'PASS TIMEOUT', actual: 'PA SS TIMEOUT'});
114 ok(!analyzer.hasUnexpectedFailures());
115 deepEqual(analyzer.unexpectedResults(), []);
116 ok(analyzer.succeeded());
117 ok(analyzer.flaky());
118
119 analyzer = new results.ResultAnalyzer({expected: 'PASS TIMEOUT', actual: 'TI MEOUT PASS'});
120 ok(!analyzer.hasUnexpectedFailures());
121 deepEqual(analyzer.unexpectedResults(), []);
122 ok(analyzer.succeeded());
123 ok(analyzer.flaky());
124
125 analyzer = new results.ResultAnalyzer({expected: 'FAIL', actual: 'TIMEOUT', is_unexpected: true});
126 ok(analyzer.hasUnexpectedFailures());
127 deepEqual(analyzer.unexpectedResults(), ['TIMEOUT']);
128 ok(!analyzer.succeeded());
129 ok(!analyzer.flaky());
130
131 analyzer = new results.ResultAnalyzer({expected: 'FAIL', actual: 'IMAGE', is _unexpected: true});
132 ok(analyzer.hasUnexpectedFailures());
133 deepEqual(analyzer.unexpectedResults(), ['IMAGE']);
134 ok(!analyzer.succeeded());
135 ok(!analyzer.flaky());
136
137 analyzer = new results.ResultAnalyzer({expected: 'FAIL', actual: 'AUDIO'});
138 ok(!analyzer.hasUnexpectedFailures());
139 deepEqual(analyzer.unexpectedResults(), []);
140 ok(!analyzer.succeeded());
141 ok(!analyzer.flaky());
142
143 analyzer = new results.ResultAnalyzer({expected: 'FAIL', actual: 'TEXT'});
144 ok(!analyzer.hasUnexpectedFailures());
145 deepEqual(analyzer.unexpectedResults(), []);
146 ok(!analyzer.succeeded());
147 ok(!analyzer.flaky());
148
149 analyzer = new results.ResultAnalyzer({expected: 'FAIL', actual: 'IMAGE+TEXT '});
150 ok(!analyzer.hasUnexpectedFailures());
151 deepEqual(analyzer.unexpectedResults(), []);
152 ok(!analyzer.succeeded());
153 ok(!analyzer.flaky());
154 });
155
156 test("trimExtension", 6, function() { 34 test("trimExtension", 6, function() {
157 equals(results._trimExtension("xyz"), "xyz"); 35 equals(results._trimExtension("xyz"), "xyz");
158 equals(results._trimExtension("xy.z"), "xy"); 36 equals(results._trimExtension("xy.z"), "xy");
159 equals(results._trimExtension("x.yz"), "x"); 37 equals(results._trimExtension("x.yz"), "x");
160 equals(results._trimExtension("x.y.z"), "x.y"); 38 equals(results._trimExtension("x.y.z"), "x.y");
161 equals(results._trimExtension(".xyz"), ""); 39 equals(results._trimExtension(".xyz"), "");
162 equals(results._trimExtension(""), ""); 40 equals(results._trimExtension(""), "");
163 }); 41 });
164 42
165 test("joinPath", 1, function() {
166 var value = results._joinPath("path/to", "test.html");
167 equals(value, "path/to/test.html");
168 });
169
170 test("joinPath with empty parent", 1, function() {
171 var value = results._joinPath("", "test.html");
172 equals(value, "test.html");
173 });
174
175 test("filterTree", 2, function() {
176 var tree = {
177 'path': {
178 'to': {
179 'test.html': {
180 'actual': 'PASS',
181 'expected': 'FAIL'
182 }
183 },
184 'another.html': {
185 'actual': 'TEXT',
186 'expected': 'PASS'
187 }
188 }
189 }
190
191 function isLeaf(node)
192 {
193 return !!node.actual;
194 }
195
196 function actualIsText(node)
197 {
198 return node.actual == 'TEXT';
199 }
200
201 var all = results._filterTree(tree, isLeaf, function() { return true });
202 deepEqual(all, {
203 'path/to/test.html': {
204 'actual': 'PASS',
205 'expected': 'FAIL'
206 },
207 'path/another.html': {
208 'actual': 'TEXT',
209 'expected': 'PASS'
210 }
211 });
212
213 var text = results._filterTree(tree, isLeaf, actualIsText);
214 deepEqual(text, {
215 'path/another.html': {
216 'actual': 'TEXT',
217 'expected': 'PASS'
218 }
219 });
220 });
221
222 test("unexpectedFailures", 1, function() {
223 var unexpectedFailures = results.unexpectedFailures(unittest.kExampleResults JSON);
224 deepEqual(unexpectedFailures, {
225 "userscripts/another-test.html": {
226 "expected": "PASS",
227 "actual": "TEXT",
228 "is_unexpected": true,
229 }
230 });
231 });
232
233 test("unexpectedFailuresByTest", 1, function() {
234 var unexpectedFailuresByTest = results.unexpectedFailuresByTest({
235 "Mock Builder": unittest.kExampleResultsJSON
236 });
237 deepEqual(unexpectedFailuresByTest, {
238 "userscripts/another-test.html": {
239 "Mock Builder": {
240 "expected": "PASS",
241 "actual": "TEXT",
242 "is_unexpected": true,
243 }
244 }
245 });
246 });
247
248 test("failureInfo", 1, function() { 43 test("failureInfo", 1, function() {
249 var failureInfo = results.failureInfo("userscripts/another-test.html", "Mock Builder", "FAIL PASS"); 44 var failureInfo = results.failureInfo("userscripts/another-test.html", "Mock Builder", "FAIL PASS");
250 deepEqual(failureInfo, { 45 deepEqual(failureInfo, {
251 "testName": "userscripts/another-test.html", 46 "testName": "userscripts/another-test.html",
252 "builderName": "Mock Builder", 47 "builderName": "Mock Builder",
253 "failureTypeList": ["FAIL", "PASS"], 48 "failureTypeList": ["FAIL", "PASS"],
254 }); 49 });
255 }); 50 });
256 51
257 test("resultKind", 12, function() { 52 test("resultKind", 12, function() {
(...skipping 19 matching lines...) Expand all
277 equals(results.resultType("http://example.com/foo.bar-expected.txt"), "text" ); 72 equals(results.resultType("http://example.com/foo.bar-expected.txt"), "text" );
278 equals(results.resultType("http://example.com/foo.bar-diff.txt"), "text"); 73 equals(results.resultType("http://example.com/foo.bar-diff.txt"), "text");
279 equals(results.resultType("http://example.com/foo-actual.png"), "image"); 74 equals(results.resultType("http://example.com/foo-actual.png"), "image");
280 equals(results.resultType("http://example.com/foo-expected.png"), "image"); 75 equals(results.resultType("http://example.com/foo-expected.png"), "image");
281 equals(results.resultType("http://example.com/foo-diff.png"), "image"); 76 equals(results.resultType("http://example.com/foo-diff.png"), "image");
282 equals(results.resultType("http://example.com/foo-pretty-diff.html"), "text" ); 77 equals(results.resultType("http://example.com/foo-pretty-diff.html"), "text" );
283 equals(results.resultType("http://example.com/foo-wdiff.html"), "text"); 78 equals(results.resultType("http://example.com/foo-wdiff.html"), "text");
284 equals(results.resultType("http://example.com/foo.xyz"), "text"); 79 equals(results.resultType("http://example.com/foo.xyz"), "text");
285 }); 80 });
286 81
287 test("resultNodeForTest", 4, function() {
288 deepEqual(results.resultNodeForTest(unittest.kExampleResultsJSON, "userscrip ts/another-test.html"), {
289 "expected": "PASS",
290 "actual": "TEXT",
291 "is_unexpected": true,
292 });
293 equals(results.resultNodeForTest(unittest.kExampleResultsJSON, "foo.html"), null);
294 equals(results.resultNodeForTest(unittest.kExampleResultsJSON, "userscripts/ foo.html"), null);
295 equals(results.resultNodeForTest(unittest.kExampleResultsJSON, "userscripts/ foo/bar.html"), null);
296 });
297
298 asyncTest("walkHistory", 1, function() {
299 var simulator = new NetworkSimulator();
300
301 var keyMap = {
302 "Mock_Builder": {
303 "11108": {
304 "tests": {
305 "userscripts": {
306 "another-test.html": {
307 "expected": "PASS",
308 "actual": "TEXT",
309 "is_unexpected": true,
310 }
311 },
312 },
313 "blink_revision": "90430"
314 },
315 "11107":{
316 "tests": {
317 "userscripts": {
318 "user-script-video-document.html": {
319 "expected": "FAIL",
320 "actual": "TEXT",
321 "is_unexpected": false,
322 },
323 "another-test.html": {
324 "expected": "PASS",
325 "actual": "TEXT",
326 "is_unexpected": true,
327 }
328 },
329 },
330 "blink_revision": "90429"
331 },
332 "11106":{
333 "tests": {
334 "userscripts": {
335 "another-test.html": {
336 "expected": "PASS",
337 "actual": "TEXT",
338 "is_unexpected": true,
339 }
340 },
341 },
342 "blink_revision": "90426"
343 },
344 "11105":{
345 "tests": {
346 "userscripts": {
347 "user-script-video-document.html": {
348 "expected": "FAIL",
349 "actual": "TEXT",
350 "is_unexpected": false,
351 },
352 },
353 },
354 "blink_revision": "90424"
355 },
356 },
357 "Another_Builder": {
358 "22202":{
359 "tests": {
360 "userscripts": {
361 "another-test.html": {
362 "expected": "PASS",
363 "actual": "TEXT",
364 "is_unexpected": true,
365 }
366 },
367 },
368 "blink_revision": "90426"
369 },
370 "22201":{
371 "tests": {
372 },
373 "blink_revision": "90425"
374 },
375 },
376 };
377
378 simulator.jsonp = function(url) {
379 var result = keyMap[/[^/]+_Builder/.exec(url)][/\d+/.exec(url)];
380 return Promise.resolve(result ? result : {});
381 };
382
383 simulator.json = function(url) {
384 if (/Mock Builder/.test(url))
385 return Promise.resolve({cachedBuilds: [11101, 11102, 11103, 11104, 1 1105, 11106, 11107, 11108]});
386 else if (/Another Builder/.test(url))
387 return Promise.resolve({cachedBuilds: [22201, 22202]});
388 else
389 return Promise.reject(false, 'Unexpected URL: ' + url);
390 };
391
392 simulator.runTest(function() {
393 results.regressionRangeForFailure("Mock Builder", "userscripts/anoth er-test.html")
394 .then(function(result) {
395 var oldestFailingRevision = result[0];
396 var newestPassingRevision = result[1];
397 equals(oldestFailingRevision, 90426);
398 equals(newestPassingRevision, 90424);
399 });
400 results.unifyRegressionRanges(["Mock Builder", "Another Builder"], " userscripts/another-test.html")
401 .then(function(result) {
402 var oldestFailingRevision = result[0];
403 var newestPassingRevision = result[1];
404 equals(oldestFailingRevision, 90426);
405 equals(newestPassingRevision, 90425);
406 });
407 }).then(start);
408 });
409
410 asyncTest("walkHistory (no revision)", 3, function() {
411 var simulator = new NetworkSimulator();
412
413 var keyMap = {
414 "Mock_Builder": {
415 "11103": {
416 "tests": {
417 "userscripts": {
418 "another-test.html": {
419 "expected": "PASS",
420 "actual": "TEXT"
421 }
422 },
423 },
424 "blink_revision": ""
425 },
426 "11102":{
427 "tests": {
428 },
429 "blink_revision": ""
430 },
431 },
432 };
433
434 simulator.jsonp = function(url) {
435 var result = keyMap[/[^/]+_Builder/.exec(url)][/\d+/.exec(url)];
436 return Promise.resolve(result ? result : {});
437 };
438
439 simulator.json = function(url) {
440 return Promise.resolve({});
441 };
442
443 simulator.runTest(function() {
444 results.regressionRangeForFailure("Mock Builder", "userscripts/another-t est.html").then(function(result) {
445 var oldestFailingRevision = result[0];
446 var newestPassingRevision = result[1];
447 equals(oldestFailingRevision, 0);
448 equals(newestPassingRevision, 0);
449 }).then(start);
450 });
451 });
452
453 asyncTest("fetchResultsURLs", 5, function() { 82 asyncTest("fetchResultsURLs", 5, function() {
454 var simulator = new NetworkSimulator(); 83 var simulator = new NetworkSimulator();
455 84
456 var probedURLs = []; 85 var probedURLs = [];
457 simulator.probe = function(url) 86 simulator.probe = function(url)
458 { 87 {
459 probedURLs.push(url); 88 probedURLs.push(url);
460 if (url.endsWith('.txt')) 89 if (url.endsWith('.txt'))
461 return Promise.resolve(); 90 return Promise.resolve();
462 else if (/taco.+png$/.test(url)) 91 else if (/taco.+png$/.test(url))
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
506 MockResultsBaseURL + "/userscripts/taco-actual.png", 135 MockResultsBaseURL + "/userscripts/taco-actual.png",
507 MockResultsBaseURL + "/userscripts/taco-diff.png", 136 MockResultsBaseURL + "/userscripts/taco-diff.png",
508 MockResultsBaseURL + "/userscripts/taco-actual.txt", 137 MockResultsBaseURL + "/userscripts/taco-actual.txt",
509 MockResultsBaseURL + "/userscripts/taco-expected.txt", 138 MockResultsBaseURL + "/userscripts/taco-expected.txt",
510 MockResultsBaseURL + "/userscripts/taco-diff.txt", 139 MockResultsBaseURL + "/userscripts/taco-diff.txt",
511 ]); 140 ]);
512 start(); 141 start();
513 }); 142 });
514 }); 143 });
515 144
516 asyncTest("fetchResultsByBuilder", 3, function() {
517 var simulator = new NetworkSimulator();
518
519 var probedURLs = [];
520 simulator.jsonp = function(url)
521 {
522 probedURLs.push(url);
523 return Promise.resolve(url.endsWith('results/layout-test-results/failing _results.json'));
524 };
525
526 simulator.runTest(function() {
527 results.fetchResultsByBuilder(['MockBuilder1', 'MockBuilder2']).then(fun ction(resultsByBuilder) {
528 deepEqual(resultsByBuilder, {
529 "MockBuilder1": true,
530 "MockBuilder2": true,
531 });
532 });
533 }).then(start);
534
535 deepEqual(probedURLs, [
536 MockResultsBaseURL.replace('Mock_Builder', 'MockBuilder1') + "/failing_r esults.json",
537 MockResultsBaseURL.replace('Mock_Builder', 'MockBuilder2') + "/failing_r esults.json"
538 ]);
539
540 });
541
542 })(); 145 })();
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698