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

Side by Side Diff: Tools/AutoSheriff/analysis_unittest.py

Issue 398823008: WIP: Add auto-sheriff.appspot.com code to Blink 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
(Empty)
1 # Copyright 2014 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file.
4
5 import unittest
6 import analysis
7 import json
8
9
10 class FailureAnalysisTest(unittest.TestCase):
11 # v8 stays the same, chromium differs, nacl is reduced.
12 MERGE_REGRESSION_RANGES_JSON = """
13 [
14 {
15 "failing_revisions": {
16 "v8": "22263",
17 "chromium": "282006",
18 "nacl": "13441"
19 },
20 "passing_revisions": {
21 "v8": "22263",
22 "chromium": "281980",
23 "nacl": "13441"
24 }
25 },
26 {
27 "failing_revisions": {
28 "v8": "22263",
29 "chromium": "282022",
30 "nacl": "13452"
31 },
32 "passing_revisions": {
33 "v8": "22263",
34 "chromium": "281989",
35 "nacl": "13441"
36 }
37 }
38 ]
39 """
40
41 MERGE_REGRESSION_RANGES_JSON_NULL = """
42 [
43 {
44 "failing_revisions": {
45 "v8": "22263",
46 "nacl": "13441"
47 },
48 "passing_revisions": null
49 },
50 {
51 "failing_revisions": {
52 "v8": "22263",
53 "nacl": null
54 },
55 "passing_revisions": {
56 "v8": "22263",
57 "nacl": "13441"
58 }
59 }
60 ]
61 """
62
63 def test_merge_regression_ranges(self):
64 alerts = json.loads(self.MERGE_REGRESSION_RANGES_JSON)
65 passing, failing = analysis.merge_regression_ranges(alerts)
66 expected_pass = { 'v8': '22263', 'chromium': '281989', 'nacl': '13441' }
67 expected_fail = { 'v8': '22263', 'chromium': '282006', 'nacl': '13441' }
68 self.assertEquals(expected_fail, failing)
69 self.assertEquals(expected_pass, passing)
70
71 alerts = json.loads(self.MERGE_REGRESSION_RANGES_JSON_NULL)
72 passing, failing = analysis.merge_regression_ranges(alerts)
73 expected_pass = None
74 expected_fail = { 'v8': '22263', 'nacl': '13441' }
75 self.assertEquals(expected_fail, failing)
76 self.assertEquals(expected_pass, passing)
77
78
79 def test_flatten_to_commit_list(self):
80 passing = { 'v8': '1', 'chromium': '4'}
ojan 2014/07/22 02:01:23 Inconsistent spacing here and in a few places belo
81 failing = { 'v8': '2', 'chromium': '4'}
82 commit_list = analysis.flatten_to_commit_list(passing, failing)
83 self.assertEquals(commit_list, ['v8:2'])
84
85
86 def test_range_key_for_group(self):
87 failing = { 'v8': '2', 'chromium': '4'}
88 group = {
89 'merged_last_passing': None,
90 'merged_first_failing': failing,
91 'sort_key': 'foobar',
92 }
93 range_key = analysis.range_key_for_group(group)
94 self.assertEquals(range_key, 'foo<=v8:2 <=chromium:4')
95
96 MERGE_BY_RANGE_JSON = """
97 [
98 {
99 "merged_last_passing": { "v8": "1" },
100 "merged_first_failing": { "v8": "2" },
101 "sort_key": "dromaeo.domcoreattr",
102 "failure_keys": [
103 ]
104 },
105 {
106 "merged_last_passing": { "v8": "1" },
107 "merged_first_failing": { "v8": "2" },
108 "sort_key": "dromaeo.jslibmodifyprototype",
109 "failure_keys": [
110 ]
111 }
112 ]
113 """
114
115 def test_merge_by_range(self):
116 groups = json.loads(self.MERGE_BY_RANGE_JSON)
117 merged = analysis.merge_by_range(groups)
118 self.assertEquals(len(merged), 1)
119 self.assertEquals(merged[0]['sort_key'], 'dromaeo.')
120 self.assertEquals(analysis.merge_by_range([]), [])
121
122
123 if __name__ == '__main__':
124 unittest.main()
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698