OLD | NEW |
1 # Copyright (C) 2013 Google Inc. All rights reserved. | 1 # Copyright (C) 2013 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * 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 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 RESULT_TYPES_TO_IGNORE = ['N', 'X', 'Y'] | 136 RESULT_TYPES_TO_IGNORE = ['N', 'X', 'Y'] |
137 | 137 |
138 def __init__(self, results_json): | 138 def __init__(self, results_json): |
139 self.results_json = results_json | 139 self.results_json = results_json |
140 | 140 |
141 def _line_from_test_and_flaky_types_and_bug_urls(self, test_path, flaky_type
s, bug_urls): | 141 def _line_from_test_and_flaky_types_and_bug_urls(self, test_path, flaky_type
s, bug_urls): |
142 line = TestExpectationLine() | 142 line = TestExpectationLine() |
143 line.original_string = test_path | 143 line.original_string = test_path |
144 line.name = test_path | 144 line.name = test_path |
145 line.filename = test_path | 145 line.filename = test_path |
146 line.modifiers = bug_urls if bug_urls else "" | 146 line.specifiers = bug_urls if bug_urls else "" |
147 line.expectations = sorted(map(self.results_json.expectation_for_type, f
laky_types)) | 147 line.expectations = sorted(map(self.results_json.expectation_for_type, f
laky_types)) |
148 return line | 148 return line |
149 | 149 |
150 def flakes_by_path(self, only_ignore_very_flaky): | 150 def flakes_by_path(self, only_ignore_very_flaky): |
151 """Sets test expectations to bot results if there are at least two disti
nct results.""" | 151 """Sets test expectations to bot results if there are at least two disti
nct results.""" |
152 flakes_by_path = {} | 152 flakes_by_path = {} |
153 for test_path, entry in self.results_json.walk_results(): | 153 for test_path, entry in self.results_json.walk_results(): |
154 results_dict = entry[self.results_json.RESULTS_KEY] | 154 results_dict = entry[self.results_json.RESULTS_KEY] |
155 flaky_types = self._flaky_types_in_results(results_dict, only_ignore
_very_flaky) | 155 flaky_types = self._flaky_types_in_results(results_dict, only_ignore
_very_flaky) |
156 if len(flaky_types) <= 1: | 156 if len(flaky_types) <= 1: |
157 continue | 157 continue |
158 flakes_by_path[test_path] = sorted(map(self.results_json.expectation
_for_type, flaky_types)) | 158 flakes_by_path[test_path] = sorted(map(self.results_json.expectation
_for_type, flaky_types)) |
159 return flakes_by_path | 159 return flakes_by_path |
160 | 160 |
161 def unexpected_results_by_path(self): | 161 def unexpected_results_by_path(self): |
162 """For tests with unexpected results, returns original expectations + re
sults.""" | 162 """For tests with unexpected results, returns original expectations + re
sults.""" |
163 def exp_to_string(exp): | 163 def exp_to_string(exp): |
164 return (TestExpectations.EXPECTATIONS_TO_STRING.get(exp, None) or | 164 return TestExpectations.EXPECTATIONS_TO_STRING.get(exp, None).upper(
) |
165 TestExpectations.MODIFIERS_TO_STRING.get(exp, None)).upper() | |
166 | 165 |
167 def string_to_exp(string): | 166 def string_to_exp(string): |
168 # Needs a bit more logic than the method above, | 167 # Needs a bit more logic than the method above, |
169 # since a PASS is 0 and evaluates to False. | 168 # since a PASS is 0 and evaluates to False. |
170 result = TestExpectations.EXPECTATIONS.get(string.lower(), None) | 169 result = TestExpectations.EXPECTATIONS.get(string.lower(), None) |
171 if not result is None: | 170 if not result is None: |
172 return result | 171 return result |
173 result = TestExpectations.MODIFIERS.get(string.lower(), None) | |
174 if not result is None: | |
175 return result | |
176 raise ValueError(string) | 172 raise ValueError(string) |
177 | 173 |
178 unexpected_results_by_path = {} | 174 unexpected_results_by_path = {} |
179 for test_path, entry in self.results_json.walk_results(): | 175 for test_path, entry in self.results_json.walk_results(): |
180 # Expectations for this test. No expectation defaults to PASS. | 176 # Expectations for this test. No expectation defaults to PASS. |
181 exp_string = entry.get(self.results_json.EXPECTATIONS_KEY, u'PASS') | 177 exp_string = entry.get(self.results_json.EXPECTATIONS_KEY, u'PASS') |
182 | 178 |
183 # All run-length-encoded results for this test. | 179 # All run-length-encoded results for this test. |
184 results_dict = entry.get(self.results_json.RESULTS_KEY, {}) | 180 results_dict = entry.get(self.results_json.RESULTS_KEY, {}) |
185 | 181 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
232 # Otherwise, we include lots of false-positives due to tests tha
t fail | 228 # Otherwise, we include lots of false-positives due to tests tha
t fail |
233 # for a couple runs and then start passing. | 229 # for a couple runs and then start passing. |
234 # FIXME: Maybe we should make this more liberal and consider it
a flake | 230 # FIXME: Maybe we should make this more liberal and consider it
a flake |
235 # even if we only see that failure once. | 231 # even if we only see that failure once. |
236 seen_results[result_type] = True | 232 seen_results[result_type] = True |
237 continue | 233 continue |
238 | 234 |
239 results_map[result_type] = True | 235 results_map[result_type] = True |
240 | 236 |
241 return results_map.keys() | 237 return results_map.keys() |
OLD | NEW |