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

Side by Side Diff: Tools/Scripts/webkitpy/layout_tests/port/driver.py

Issue 1154373005: Introduce WPTServe for running W3C Blink Layout tests (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fix nits, refactor, license header update. Created 5 years, 6 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) 2011 Google Inc. All rights reserved. 1 # Copyright (C) 2011 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 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
215 215
216 # FIXME: Seems this could just be inlined into callers. 216 # FIXME: Seems this could just be inlined into callers.
217 @classmethod 217 @classmethod
218 def _command_wrapper(cls, wrapper_option): 218 def _command_wrapper(cls, wrapper_option):
219 # Hook for injecting valgrind or other runtime instrumentation, 219 # Hook for injecting valgrind or other runtime instrumentation,
220 # used by e.g. tools/valgrind/valgrind_tests.py. 220 # used by e.g. tools/valgrind/valgrind_tests.py.
221 return shlex.split(wrapper_option) if wrapper_option else [] 221 return shlex.split(wrapper_option) if wrapper_option else []
222 222
223 HTTP_DIR = "http/tests/" 223 HTTP_DIR = "http/tests/"
224 HTTP_LOCAL_DIR = "http/tests/local/" 224 HTTP_LOCAL_DIR = "http/tests/local/"
225 WPT_DIR = "imported/web-platform-tests/"
225 226
226 def is_http_test(self, test_name): 227 def is_http_test(self, test_name):
227 return test_name.startswith(self.HTTP_DIR) and not test_name.startswith( self.HTTP_LOCAL_DIR) 228 return test_name.startswith(self.HTTP_DIR) and not test_name.startswith( self.HTTP_LOCAL_DIR)
228 229
230 def _should_treat_as_wpt_test(self, test_name):
231 return self._port.is_wpt_enabled() and self._port.is_wpt_test(test_name)
232
233 def _get_http_host_and_ports_for_test(self, test_name):
234 if self._should_treat_as_wpt_test(test_name):
235 # TODO(burnik): Read from config or args.
236 return ("web-platform.test", 8001, 8444)
237 else:
238 return ("127.0.0.1", 8000, 8443)
239
229 def test_to_uri(self, test_name): 240 def test_to_uri(self, test_name):
230 """Convert a test name to a URI. 241 """Convert a test name to a URI.
231 242
232 Tests which have an 'https' directory in their paths (e.g. 243 Tests which have an 'https' directory in their paths (e.g.
233 '/http/tests/security/mixedContent/https/test1.html') or '.https.' in 244 '/http/tests/security/mixedContent/https/test1.html') or '.https.' in
234 their name (e.g. 'http/tests/security/mixedContent/test1.https.html') wi ll 245 their name (e.g. 'http/tests/security/mixedContent/test1.https.html') wi ll
235 be loaded over HTTPS; all other tests over HTTP. 246 be loaded over HTTPS; all other tests over HTTP.
236 """ 247 """
237 if not self.is_http_test(test_name): 248 is_wpt_test = self._should_treat_as_wpt_test(test_name)
249
250 if not self.is_http_test(test_name) and not is_wpt_test:
238 return path.abspath_to_uri(self._port.host.platform, self._port.absp ath_for_test(test_name)) 251 return path.abspath_to_uri(self._port.host.platform, self._port.absp ath_for_test(test_name))
239 252
240 relative_path = test_name[len(self.HTTP_DIR):] 253 if is_wpt_test:
254 test_dir_prefix = self.WPT_DIR
255 else:
256 test_dir_prefix = self.HTTP_DIR
257
258 relative_path = test_name[len(test_dir_prefix):]
259 hostname, insecure_port, secure_port = self._get_http_host_and_ports_for _test(test_name)
241 260
242 if "/https/" in test_name or ".https." in test_name: 261 if "/https/" in test_name or ".https." in test_name:
243 return "https://127.0.0.1:8443/" + relative_path 262 return "https://%s:%d/%s" % (hostname, secure_port, relative_path)
244 return "http://127.0.0.1:8000/" + relative_path 263 return "http://%s:%d/%s" % (hostname, insecure_port, relative_path)
245 264
246 def uri_to_test(self, uri): 265 def uri_to_test(self, uri):
247 """Return the base layout test name for a given URI. 266 """Return the base layout test name for a given URI.
248 267
249 This returns the test name for a given URI, e.g., if you passed in 268 This returns the test name for a given URI, e.g., if you passed in
250 "file:///src/LayoutTests/fast/html/keygen.html" it would return 269 "file:///src/LayoutTests/fast/html/keygen.html" it would return
251 "fast/html/keygen.html". 270 "fast/html/keygen.html".
252 271
253 """ 272 """
273
274 # This looks like a bit of a hack, since the uri is used instead of test name.
275 hostname, insecure_port, secure_port = self._get_http_host_and_ports_for _test(uri)
276
254 if uri.startswith("file:///"): 277 if uri.startswith("file:///"):
255 prefix = path.abspath_to_uri(self._port.host.platform, self._port.la yout_tests_dir()) 278 prefix = path.abspath_to_uri(self._port.host.platform, self._port.la yout_tests_dir())
256 if not prefix.endswith('/'): 279 if not prefix.endswith('/'):
257 prefix += '/' 280 prefix += '/'
258 return uri[len(prefix):] 281 return uri[len(prefix):]
259 if uri.startswith("http://"): 282 if uri.startswith("http://"):
260 return uri.replace('http://127.0.0.1:8000/', self.HTTP_DIR) 283 return uri.replace('http://%s:%d/' % (hostname, insecure_port), self .HTTP_DIR)
261 if uri.startswith("https://"): 284 if uri.startswith("https://"):
262 return uri.replace('https://127.0.0.1:8443/', self.HTTP_DIR) 285 return uri.replace('https://%s:%d/' % (hostname, secure_port), self. HTTP_DIR)
263 raise NotImplementedError('unknown url type: %s' % uri) 286 raise NotImplementedError('unknown url type: %s' % uri)
264 287
265 def has_crashed(self): 288 def has_crashed(self):
266 if self._server_process is None: 289 if self._server_process is None:
267 return False 290 return False
268 if self._crashed_process_name: 291 if self._crashed_process_name:
269 return True 292 return True
270 if self._server_process.has_crashed(): 293 if self._server_process.has_crashed():
271 self._crashed_process_name = self._server_process.name() 294 self._crashed_process_name = self._server_process.name()
272 self._crashed_pid = self._server_process.pid() 295 self._crashed_pid = self._server_process.pid()
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 if error_line.startswith("#LEAK - "): 403 if error_line.startswith("#LEAK - "):
381 self._leaked = True 404 self._leaked = True
382 match = re.match('#LEAK - (\S+) pid (\d+) (.+)\n', error_line) 405 match = re.match('#LEAK - (\S+) pid (\d+) (.+)\n', error_line)
383 self._leak_log = match.group(3) 406 self._leak_log = match.group(3)
384 return self._leaked 407 return self._leaked
385 408
386 def _command_from_driver_input(self, driver_input): 409 def _command_from_driver_input(self, driver_input):
387 # FIXME: performance tests pass in full URLs instead of test names. 410 # FIXME: performance tests pass in full URLs instead of test names.
388 if driver_input.test_name.startswith('http://') or driver_input.test_nam e.startswith('https://') or driver_input.test_name == ('about:blank'): 411 if driver_input.test_name.startswith('http://') or driver_input.test_nam e.startswith('https://') or driver_input.test_name == ('about:blank'):
389 command = driver_input.test_name 412 command = driver_input.test_name
390 elif self.is_http_test(driver_input.test_name): 413 elif self.is_http_test(driver_input.test_name) or self._should_treat_as_ wpt_test(driver_input.test_name):
391 command = self.test_to_uri(driver_input.test_name) 414 command = self.test_to_uri(driver_input.test_name)
392 else: 415 else:
393 command = self._port.abspath_for_test(driver_input.test_name) 416 command = self._port.abspath_for_test(driver_input.test_name)
394 if sys.platform == 'cygwin': 417 if sys.platform == 'cygwin':
395 command = path.cygpath(command) 418 command = path.cygpath(command)
396 419
397 assert not driver_input.image_hash or driver_input.should_run_pixel_test 420 assert not driver_input.image_hash or driver_input.should_run_pixel_test
398 421
399 # ' is the separator between arguments. 422 # ' is the separator between arguments.
400 if self._port.supports_per_test_timeout(): 423 if self._port.supports_per_test_timeout():
(...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after
516 self.decoded_content = None 539 self.decoded_content = None
517 self.malloc = None 540 self.malloc = None
518 self.js_heap = None 541 self.js_heap = None
519 self.stdin_path = None 542 self.stdin_path = None
520 543
521 def decode_content(self): 544 def decode_content(self):
522 if self.encoding == 'base64' and self.content is not None: 545 if self.encoding == 'base64' and self.content is not None:
523 self.decoded_content = base64.b64decode(self.content) 546 self.decoded_content = base64.b64decode(self.content)
524 else: 547 else:
525 self.decoded_content = self.content 548 self.decoded_content = self.content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698