| OLD | NEW |
| 1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 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 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 243 self.comment = None | 243 self.comment = None |
| 244 self.matching_tests = [] | 244 self.matching_tests = [] |
| 245 self.warnings = [] | 245 self.warnings = [] |
| 246 self.is_extra_skipped_test = False | 246 self.is_extra_skipped_test = False |
| 247 | 247 |
| 248 def __str__(self): | 248 def __str__(self): |
| 249 return 'TestExpectationLine{name=%s, matching_configurations=%s, origina
l_string=%s}' % ( | 249 return 'TestExpectationLine{name=%s, matching_configurations=%s, origina
l_string=%s}' % ( |
| 250 self.name, self.matching_configurations, self.original_string) | 250 self.name, self.matching_configurations, self.original_string) |
| 251 | 251 |
| 252 def __eq__(self, other): | 252 def __eq__(self, other): |
| 253 return (self.original_string == other.original_string | 253 return (isinstance(other, self.__class__) |
| 254 and self.original_string == other.original_string |
| 254 and self.filename == other.filename | 255 and self.filename == other.filename |
| 255 and self.line_numbers == other.line_numbers | 256 and self.line_numbers == other.line_numbers |
| 256 and self.name == other.name | 257 and self.name == other.name |
| 257 and self.path == other.path | 258 and self.path == other.path |
| 258 and self.bugs == other.bugs | 259 and self.bugs == other.bugs |
| 259 and self.specifiers == other.specifiers | 260 and self.specifiers == other.specifiers |
| 260 and self.parsed_specifiers == other.parsed_specifiers | 261 and self.parsed_specifiers == other.parsed_specifiers |
| 261 and self.matching_configurations == other.matching_configuration
s | 262 and self.matching_configurations == other.matching_configuration
s |
| 262 and self.expectations == other.expectations | 263 and self.expectations == other.expectations |
| 263 and self.parsed_expectations == other.parsed_expectations | 264 and self.parsed_expectations == other.parsed_expectations |
| (...skipping 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 688 return ' '.join(retval) | 689 return ' '.join(retval) |
| 689 | 690 |
| 690 def expectation_to_string(self, expectation): | 691 def expectation_to_string(self, expectation): |
| 691 """Return the uppercased string equivalent of a given expectation.""" | 692 """Return the uppercased string equivalent of a given expectation.""" |
| 692 for item in TestExpectations.EXPECTATIONS.items(): | 693 for item in TestExpectations.EXPECTATIONS.items(): |
| 693 if item[1] == expectation: | 694 if item[1] == expectation: |
| 694 return item[0].upper() | 695 return item[0].upper() |
| 695 raise ValueError(expectation) | 696 raise ValueError(expectation) |
| 696 | 697 |
| 697 def remove_expectation_line(self, test): | 698 def remove_expectation_line(self, test): |
| 698 if not self.has_test(test): | 699 if not self.has_test(test.name): |
| 699 return | 700 return |
| 700 self._clear_expectations_for_test(test) | 701 self._clear_expectations_for_test(test) |
| 701 del self._test_to_expectation_line[test] | 702 del self._test_to_expectation_line[test] |
| 702 | 703 |
| 703 def add_expectation_line(self, expectation_line, | 704 def add_expectation_line(self, expectation_line, |
| 704 model_all_expectations=False): | 705 model_all_expectations=False): |
| 705 """Returns a list of warnings encountered while matching specifiers.""" | 706 """Returns a list of warnings encountered while matching specifiers.""" |
| 706 | 707 |
| 707 if expectation_line.is_invalid(): | 708 if expectation_line.is_invalid(): |
| 708 return | 709 return |
| (...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1173 for test in self._expectations: | 1174 for test in self._expectations: |
| 1174 if test.name and test.name in tests_to_skip: | 1175 if test.name and test.name in tests_to_skip: |
| 1175 test.warnings.append('%s:%s %s is also in a Skipped file.' % (te
st.filename, test.line_numbers, test.name)) | 1176 test.warnings.append('%s:%s %s is also in a Skipped file.' % (te
st.filename, test.line_numbers, test.name)) |
| 1176 | 1177 |
| 1177 model = TestExpectationsModel(self._shorten_filename) | 1178 model = TestExpectationsModel(self._shorten_filename) |
| 1178 for test_name in tests_to_skip: | 1179 for test_name in tests_to_skip: |
| 1179 expectation_line = self._parser.expectation_for_skipped_test(test_na
me) | 1180 expectation_line = self._parser.expectation_for_skipped_test(test_na
me) |
| 1180 model.add_expectation_line(expectation_line) | 1181 model.add_expectation_line(expectation_line) |
| 1181 self._model.merge_model(model) | 1182 self._model.merge_model(model) |
| 1182 | 1183 |
| 1183 def remove_tests(self, tests_to_remove): | 1184 def remove_tests_from_expectations(self, tests_to_remove): |
| 1184 for test in self._expectations: | 1185 for test in self._expectations: |
| 1185 if test.name and test.name in tests_to_remove: | 1186 if not test.name: |
| 1186 self.remove_expectation_line(test) | 1187 continue |
| 1188 if test.name not in tests_to_remove: |
| 1189 continue |
| 1190 self._expectations.remove(test) |
| 1191 if not self._model.has_test(test.name): |
| 1192 continue |
| 1193 line = self._model.get_expectation_line(test.name) |
| 1194 self._model.remove_expectation_line(line) |
| 1187 | 1195 |
| 1188 def add_expectations_from_bot(self): | 1196 def add_expectations_from_bot(self): |
| 1189 # FIXME: With mode 'very-flaky' and 'maybe-flaky', this will show the ex
pectations entry in the flakiness | 1197 # FIXME: With mode 'very-flaky' and 'maybe-flaky', this will show the ex
pectations entry in the flakiness |
| 1190 # dashboard rows for each test to be whatever the bot thinks they should
be. Is this a good thing? | 1198 # dashboard rows for each test to be whatever the bot thinks they should
be. Is this a good thing? |
| 1191 bot_expectations = self._port.bot_expectations() | 1199 bot_expectations = self._port.bot_expectations() |
| 1192 model = TestExpectationsModel(self._shorten_filename) | 1200 model = TestExpectationsModel(self._shorten_filename) |
| 1193 for test_name in bot_expectations: | 1201 for test_name in bot_expectations: |
| 1194 expectation_line = self._parser.expectation_line_for_test(test_name,
bot_expectations[test_name]) | 1202 expectation_line = self._parser.expectation_line_for_test(test_name,
bot_expectations[test_name]) |
| 1195 | 1203 |
| 1196 # Unexpected results are merged into existing expectations. | 1204 # Unexpected results are merged into existing expectations. |
| 1197 model.add_expectation_line(expectation_line) | 1205 model.add_expectation_line(expectation_line) |
| 1198 self._model.merge_model(model) | 1206 self._model.merge_model(model) |
| 1199 | 1207 |
| 1200 def add_expectation_line(self, expectation_line): | 1208 def add_expectation_line(self, expectation_line): |
| 1201 self._model.add_expectation_line(expectation_line) | 1209 self._model.add_expectation_line(expectation_line) |
| 1202 self._expectations += [expectation_line] | 1210 self._expectations += [expectation_line] |
| 1203 | 1211 |
| 1204 def remove_expectation_line(self, test): | |
| 1205 if not self._model.has_test(test): | |
| 1206 return | |
| 1207 self._expectations.remove(self._model.get_expectation_line(test)) | |
| 1208 self._model.remove_expectation_line(test) | |
| 1209 | |
| 1210 @staticmethod | 1212 @staticmethod |
| 1211 def list_to_string(expectation_lines, test_configuration_converter=None, rec
onstitute_only_these=None): | 1213 def list_to_string(expectation_lines, test_configuration_converter=None, rec
onstitute_only_these=None): |
| 1212 def serialize(expectation_line): | 1214 def serialize(expectation_line): |
| 1213 # If reconstitute_only_these is an empty list, we want to return ori
ginal_string. | 1215 # If reconstitute_only_these is an empty list, we want to return ori
ginal_string. |
| 1214 # So we need to compare reconstitute_only_these to None, not just ch
eck if it's falsey. | 1216 # So we need to compare reconstitute_only_these to None, not just ch
eck if it's falsey. |
| 1215 if reconstitute_only_these is None or expectation_line in reconstitu
te_only_these: | 1217 if reconstitute_only_these is None or expectation_line in reconstitu
te_only_these: |
| 1216 return expectation_line.to_string(test_configuration_converter) | 1218 return expectation_line.to_string(test_configuration_converter) |
| 1217 return expectation_line.original_string | 1219 return expectation_line.original_string |
| 1218 | 1220 |
| 1219 def nones_out(expectation_line): | 1221 def nones_out(expectation_line): |
| 1220 return expectation_line is not None | 1222 return expectation_line is not None |
| 1221 | 1223 |
| 1222 return '\n'.join(filter(nones_out, map(serialize, expectation_lines))) | 1224 return '\n'.join(filter(nones_out, map(serialize, expectation_lines))) |
| OLD | NEW |