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

Side by Side Diff: content/test/gpu/gpu_tests/test_expectations.py

Issue 1413883003: Add a presubmit script and pylintrc for content/test/gpu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address kbr's comments Created 5 years, 2 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 2013 The Chromium Authors. All rights reserved. 1 # Copyright 2013 The Chromium Authors. All rights reserved.
2 # Use of this source code is governed by a BSD-style license that can be 2 # Use of this source code is governed by a BSD-style license that can be
3 # found in the LICENSE file. 3 # found in the LICENSE file.
4 4
5 import fnmatch 5 import fnmatch
6 import urlparse 6 import urlparse
7 7
8 # Valid expectation conditions are: 8 # Valid expectation conditions are:
9 # 9 #
10 # Operating systems: 10 # Operating systems:
11 # win, xp, vista, win7, win8, win10, mac, leopard, snowleopard, 11 # win, xp, vista, win7, win8, win10, mac, leopard, snowleopard,
12 # lion, mountainlion, mavericks, yosemite, linux, chromeos, 12 # lion, mountainlion, mavericks, yosemite, linux, chromeos,
13 # android 13 # android
14 # 14 #
15 # Browser types: 15 # Browser types:
16 # android-webview-shell, android-content-shell, debug, release 16 # android-webview-shell, android-content-shell, debug, release
17 # 17 #
18 # Sample usage in SetExpectations in subclasses: 18 # Sample usage in SetExpectations in subclasses:
19 # self.Fail('gl-enable-vertex-attrib.html', 19 # self.Fail('gl-enable-vertex-attrib.html',
20 # ['mac', 'release'], bug=123) 20 # ['mac', 'release'], bug=123)
21 21
22 WIN_CONDITIONS = ['xp', 'vista', 'win7', 'win8', 'win10'] 22 WIN_CONDITIONS = ['xp', 'vista', 'win7', 'win8', 'win10']
23 MAC_CONDITIONS = ['leopard', 'snowleopard', 'lion', 'mountainlion', 23 MAC_CONDITIONS = ['leopard', 'snowleopard', 'lion', 'mountainlion',
24 'mavericks', 'yosemite'] 24 'mavericks', 'yosemite']
25 25
26 OS_CONDITIONS = ['win', 'mac', 'linux', 'chromeos', 'android'] + \ 26 OS_CONDITIONS = ['win', 'mac', 'linux', 'chromeos', 'android'] + \
27 WIN_CONDITIONS + MAC_CONDITIONS 27 WIN_CONDITIONS + MAC_CONDITIONS
28 28
29 BROWSER_TYPE_CONDITIONS = [ 29 BROWSER_TYPE_CONDITIONS = [
30 'android-webview-shell', 'android-content-shell', 'debug', 'release' ] 30 'android-webview-shell', 'android-content-shell', 'debug', 'release']
31 31
32 class Expectation(object): 32 class Expectation(object):
33 """Represents a single test expectation for a page. 33 """Represents a single test expectation for a page.
34 34
35 Supports conditions based on operating system (e.g., win, mac) and 35 Supports conditions based on operating system (e.g., win, mac) and
36 browser type (e.g. 'debug', 'release'). 36 browser type (e.g. 'debug', 'release').
37 37
38 Subclass this class and call super.__init__ last in your constructor 38 Subclass this class and call super.__init__ last in your constructor
39 in order to add new user-defined conditions. The conditions are 39 in order to add new user-defined conditions. The conditions are
40 parsed at the end of this class's constructor, so be careful not to 40 parsed at the end of this class's constructor, so be careful not to
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 135
136 def _HasWildcardCharacters(self, input_string): 136 def _HasWildcardCharacters(self, input_string):
137 # Could make this more precise. 137 # Could make this more precise.
138 return '*' in input_string or '+' in input_string 138 return '*' in input_string or '+' in input_string
139 139
140 def _BuildExpectationsCache(self, browser, page): 140 def _BuildExpectationsCache(self, browser, page):
141 # Turn off name matching while building the cache. 141 # Turn off name matching while building the cache.
142 self._skip_matching_names = True 142 self._skip_matching_names = True
143 for e in self._expectations: 143 for e in self._expectations:
144 if self.ExpectationAppliesToPage(e, browser, page): 144 if self.ExpectationAppliesToPage(e, browser, page):
145 if (self._HasWildcardCharacters(e.pattern)): 145 if self._HasWildcardCharacters(e.pattern):
146 self._expectations_with_wildcards.append(e) 146 self._expectations_with_wildcards.append(e)
147 else: 147 else:
148 if e.pattern in self._expectations_by_pattern: 148 if e.pattern in self._expectations_by_pattern:
149 print "WARNING: Non-wildcard pattern collision for", pattern 149 print "WARNING: Non-wildcard pattern collision for", e.pattern
150 self._expectations_by_pattern[e.pattern] = e 150 self._expectations_by_pattern[e.pattern] = e
151 self._built_expectation_cache = True 151 self._built_expectation_cache = True
152 self._skip_matching_names = False 152 self._skip_matching_names = False
153 153
154 def _GetNormalizedURL(self, url, browser): 154 def _GetNormalizedURL(self, url, browser):
155 # Telemetry uses backslashes in its file:// URLs on Windows, 155 # Telemetry uses backslashes in its file:// URLs on Windows,
156 # breaking matching of test expectations. 156 # breaking matching of test expectations.
157 if not browser.platform.GetOSName() == 'win': 157 if not browser.platform.GetOSName() == 'win':
158 return url 158 return url
159 return url.replace('\\', '/') 159 return url.replace('\\', '/')
160 160
161 def _GetURLPath(self, url): 161 def _GetURLPath(self, url):
162 components = urlparse.urlsplit(url) 162 components = urlparse.urlsplit(url)
163 # For compatibility, the file:// scheme must be treated specially. 163 # For compatibility, the file:// scheme must be treated specially.
164 # The top-level directory shows up in the netloc portion of the URL. 164 # The top-level directory shows up in the netloc portion of the URL.
165 if components[0] == 'file': 165 if components[0] == 'file':
166 url_path = components[1] + components[2] 166 url_path = components[1] + components[2]
167 else: 167 else:
168 url_path = components[2] 168 url_path = components[2]
169 # Chop any leading slash since the expectations used by this class 169 # Chop any leading slash since the expectations used by this class
170 # assume that. 170 # assume that.
171 if (url_path and url_path[0] == '/'): 171 if url_path and url_path[0] == '/':
172 url_path = url_path[1:] 172 url_path = url_path[1:]
173 # Python's urlsplit doesn't seem to handle query arguments for 173 # Python's urlsplit doesn't seem to handle query arguments for
174 # file:// URLs properly. Split them off manually. 174 # file:// URLs properly. Split them off manually.
175 query_index = url_path.find('?') 175 query_index = url_path.find('?')
176 if query_index > 0: 176 if query_index > 0:
177 url_path = url_path[0:query_index] 177 url_path = url_path[0:query_index]
178 return url_path 178 return url_path
179 179
180 def _GetExpectationObjectForPage(self, browser, page): 180 def _GetExpectationObjectForPage(self, browser, page):
181 if not self._built_expectation_cache: 181 if not self._built_expectation_cache:
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
253 platform = browser.platform 253 platform = browser.platform
254 os_matches = (not expectation.os_conditions or 254 os_matches = (not expectation.os_conditions or
255 platform.GetOSName() in expectation.os_conditions or 255 platform.GetOSName() in expectation.os_conditions or
256 platform.GetOSVersionName() in expectation.os_conditions) 256 platform.GetOSVersionName() in expectation.os_conditions)
257 257
258 browser_matches = ( 258 browser_matches = (
259 (not expectation.browser_conditions) or 259 (not expectation.browser_conditions) or
260 browser.browser_type in expectation.browser_conditions) 260 browser.browser_type in expectation.browser_conditions)
261 261
262 return os_matches and browser_matches 262 return os_matches and browser_matches
OLDNEW
« no previous file with comments | « content/test/gpu/gpu_tests/screenshot_sync_expectations.py ('k') | content/test/gpu/gpu_tests/test_expectations_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698