| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2014 The Chromium Authors. All rights reserved. | 2 Copyright 2014 The Chromium Authors. All rights reserved. |
| 3 Use of this source code is governed by a BSD-style license that can be | 3 Use of this source code is governed by a BSD-style license that can be |
| 4 found in the LICENSE file. | 4 found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 | 6 |
| 7 <link rel="import" href="../ct-failure-analyzer.html"> | 7 <link rel="import" href="../ct-failure-analyzer.html"> |
| 8 | 8 |
| 9 <script> | 9 <script> |
| 10 (function () { | 10 (function () { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 23 | 23 |
| 24 var failures = [failure4, failure3, failure2, failure1]; | 24 var failures = [failure4, failure3, failure2, failure1]; |
| 25 var expectedFailures = [failure1, failure2, failure3, failure4]; | 25 var expectedFailures = [failure1, failure2, failure3, failure4]; |
| 26 assert.deepEqual(failures.sort(analyzer._failureComparator), expectedFailu
res); | 26 assert.deepEqual(failures.sort(analyzer._failureComparator), expectedFailu
res); |
| 27 }); | 27 }); |
| 28 }); | 28 }); |
| 29 | 29 |
| 30 describe('_failureListComparator', function() { | 30 describe('_failureListComparator', function() { |
| 31 it('should compare failures correctly', function() { | 31 it('should compare failures correctly', function() { |
| 32 var analyzer = document.createElement('ct-failure-analyzer'); | 32 var analyzer = document.createElement('ct-failure-analyzer'); |
| 33 var revision1 = { | 33 |
| 34 'chromium': 1, | 34 var group1 = new CTFailureGroup("0", [], ['chromium:1', 'blink:2'], null); |
| 35 'blink': 2 | 35 var group2 = new CTFailureGroup("1", [], ['chromium:2', 'blink:1'], null); |
| 36 }; | 36 var group3 = new CTFailureGroup("2", [], ['chromium:2', 'blink:2'], null); |
| 37 var revision2 = { | 37 var group4 = new CTFailureGroup("3", [], [], null); |
| 38 'chromium': 2, | |
| 39 'blink': 1 | |
| 40 }; | |
| 41 var revision3 = { | |
| 42 'chromium': 2, | |
| 43 'blink': 2 | |
| 44 }; | |
| 45 var resultsByBuilder = {}; | |
| 46 var failure1 = new CTFailure("step", "reason", resultsByBuilder, revision1
, revision1); | |
| 47 var failure2 = new CTFailure("step", "reason", resultsByBuilder, revision2
, revision2); | |
| 48 var failure3 = new CTFailure("step", "reason", resultsByBuilder, revision3
, revision3); | |
| 49 var failure4 = new CTFailure("step", "reason", resultsByBuilder, null, nul
l); | |
| 50 var group1 = new CTFailureGroup("0", [failure1], null); | |
| 51 var group2 = new CTFailureGroup("1", [failure2], null); | |
| 52 var group3 = new CTFailureGroup("2", [failure3], null); | |
| 53 var group4 = new CTFailureGroup("3", [failure4], null); | |
| 54 | 38 |
| 55 // Sort by last revision first. | 39 // Sort by last revision first. |
| 56 assert(analyzer._failureListComparator('chromium', group1, group2) > 0); | 40 assert(analyzer._failureByTreeListComparator('chromium', group1, group2) >
0); |
| 57 assert(analyzer._failureListComparator('chromium', group2, group1) < 0); | 41 assert(analyzer._failureByTreeListComparator('chromium', group2, group1) <
0); |
| 58 assert(analyzer._failureListComparator('chromium', group1, group1) == 0); | 42 assert(analyzer._failureByTreeListComparator('chromium', group1, group1) =
= 0); |
| 59 | 43 |
| 60 // If the tree revisions are equal, take others. | 44 // If the tree revisions are equal, take others. |
| 61 assert(analyzer._failureListComparator('chromium', group2, group3) > 0); | 45 assert(analyzer._failureByTreeListComparator('chromium', group2, group3) >
0); |
| 62 | 46 |
| 63 // Prioritize the given tree. | 47 // Prioritize the given tree. |
| 64 assert(analyzer._failureListComparator('chromium', group1, group2) > 0); | 48 assert(analyzer._failureByTreeListComparator('chromium', group1, group2) >
0); |
| 65 assert(analyzer._failureListComparator('blink', group1, group2) < 0); | 49 assert(analyzer._failureByTreeListComparator('blink', group1, group2) < 0)
; |
| 66 | 50 |
| 67 // Default to 'chromium'. | 51 // Default to 'chromium'. |
| 68 assert(analyzer._failureListComparator(undefined, group1, group2) > 0); | 52 assert(analyzer._failureByTreeListComparator(undefined, group1, group2) >
0); |
| 69 | 53 |
| 70 // Failures without a revision go to the end. | 54 // Failures without a revision go to the end. |
| 71 assert(analyzer._failureListComparator('chromium', group4, group1) < 0); | 55 assert(analyzer._failureByTreeListComparator('chromium', group4, group1) <
0); |
| 56 |
| 57 // Support for git hashes. |
| 58 var group1hash = new CTFailureGroup("0", [], ['chromium:123abc', 'blink:2'
], null); |
| 59 var group2hash = new CTFailureGroup("1", [], ['chromium:abc123', 'blink:1'
], null); |
| 60 assert(analyzer._failureByTreeListComparator('chromium', group1hash, group
2hash) > 0); |
| 61 assert(analyzer._failureByTreeListComparator('chromium', group2hash, group
1hash) < 0); |
| 62 assert(analyzer._failureByTreeListComparator('chromium', group1hash, group
1hash) == 0); |
| 72 }); | 63 }); |
| 73 }); | 64 }); |
| 74 }); | 65 }); |
| 75 | 66 |
| 76 })() | 67 })() |
| 77 </script> | 68 </script> |
| OLD | NEW |