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

Side by Side Diff: third_party/WebKit/Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py

Issue 2831883002: webkitpy: Reduce usage of path_from_webkit_base(). (Closed)
Patch Set: . Created 3 years, 8 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
OLDNEW
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 15 matching lines...) Expand all
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 28
29 """A helper class for reading in and dealing with tests expectations for layout tests.""" 29 """A helper class for reading in and dealing with tests expectations for layout tests."""
30 30
31 from collections import defaultdict 31 from collections import defaultdict
32 32
33 import logging 33 import logging
34 import re 34 import re
35 35
36 from webkitpy.common.webkit_finder import WebKitFinder
36 from webkitpy.layout_tests.models.test_configuration import TestConfigurationCon verter 37 from webkitpy.layout_tests.models.test_configuration import TestConfigurationCon verter
37 38
38 _log = logging.getLogger(__name__) 39 _log = logging.getLogger(__name__)
39 40
40 41
41 # Test expectation and specifier constants. 42 # Test expectation and specifier constants.
42 # 43 #
43 # FIXME: range() starts with 0 which makes if expectation checks harder 44 # FIXME: range() starts with 0 which makes if expectation checks harder
44 # as PASS is 0. 45 # as PASS is 0.
45 (PASS, FAIL, TEXT, IMAGE, IMAGE_PLUS_TEXT, AUDIO, TIMEOUT, CRASH, LEAK, SKIP, WO NTFIX, 46 (PASS, FAIL, TEXT, IMAGE, IMAGE_PLUS_TEXT, AUDIO, TIMEOUT, CRASH, LEAK, SKIP, WO NTFIX,
(...skipping 1042 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 if sanitizer_is_enabled: 1089 if sanitizer_is_enabled:
1089 expected_results = self.remove_non_sanitizer_failures(expected_resul ts) 1090 expected_results = self.remove_non_sanitizer_failures(expected_resul ts)
1090 elif not pixel_tests_are_enabled: 1091 elif not pixel_tests_are_enabled:
1091 expected_results = self.remove_pixel_failures(expected_results) 1092 expected_results = self.remove_pixel_failures(expected_results)
1092 return self.result_was_expected(result, expected_results, self.is_rebase lining(test)) 1093 return self.result_was_expected(result, expected_results, self.is_rebase lining(test))
1093 1094
1094 def is_rebaselining(self, test): 1095 def is_rebaselining(self, test):
1095 return REBASELINE in self._model.get_expectations(test) 1096 return REBASELINE in self._model.get_expectations(test)
1096 1097
1097 def _shorten_filename(self, filename): 1098 def _shorten_filename(self, filename):
1098 if filename.startswith(self._port.path_from_webkit_base()): 1099 finder = WebKitFinder(self._port.host.filesystem)
1099 return self._port.host.filesystem.relpath(filename, self._port.path_ from_webkit_base()) 1100 # TODO(tkent): Can we use path_from_layout_tests() instead?
1101 if filename.startswith(finder.path_from_webkit_base()):
1102 return self._port.host.filesystem.relpath(filename, finder.path_from _webkit_base())
1100 return filename 1103 return filename
1101 1104
1102 def _report_warnings(self): 1105 def _report_warnings(self):
1103 warnings = [] 1106 warnings = []
1104 for expectation in self._expectations: 1107 for expectation in self._expectations:
1105 for warning in expectation.warnings: 1108 for warning in expectation.warnings:
1106 warnings.append('%s:%s %s %s' % ( 1109 warnings.append('%s:%s %s %s' % (
1107 self._shorten_filename(expectation.filename), expectation.li ne_numbers, 1110 self._shorten_filename(expectation.filename), expectation.li ne_numbers,
1108 warning, expectation.name if expectation.expectations else e xpectation.original_string)) 1111 warning, expectation.name if expectation.expectations else e xpectation.original_string))
1109 1112
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1211 # If reconstitute_only_these is an empty list, we want to return ori ginal_string. 1214 # If reconstitute_only_these is an empty list, we want to return ori ginal_string.
1212 # So we need to compare reconstitute_only_these to None, not just ch eck if it's falsey. 1215 # So we need to compare reconstitute_only_these to None, not just ch eck if it's falsey.
1213 if reconstitute_only_these is None or expectation_line in reconstitu te_only_these: 1216 if reconstitute_only_these is None or expectation_line in reconstitu te_only_these:
1214 return expectation_line.to_string(test_configuration_converter) 1217 return expectation_line.to_string(test_configuration_converter)
1215 return expectation_line.original_string 1218 return expectation_line.original_string
1216 1219
1217 def nones_out(expectation_line): 1220 def nones_out(expectation_line):
1218 return expectation_line is not None 1221 return expectation_line is not None
1219 1222
1220 return '\n'.join(filter(nones_out, map(serialize, expectation_lines))) 1223 return '\n'.join(filter(nones_out, map(serialize, expectation_lines)))
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698