diff options
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py')
-rw-r--r-- | WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py | 92 |
1 files changed, 56 insertions, 36 deletions
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py index 3149290..8fe685a 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py @@ -32,6 +32,7 @@ from __future__ import with_statement import codecs +import errno import logging import os import re @@ -43,7 +44,6 @@ import tempfile import time import webbrowser -from webkitpy.common.system.executive import Executive from webkitpy.common.system.path import cygpath from webkitpy.layout_tests.layout_package import test_expectations from webkitpy.layout_tests.layout_package import test_output @@ -175,6 +175,8 @@ class ChromiumPort(base.Port): return result def driver_name(self): + if self._options.use_drt: + return "DumpRenderTree" return "test_shell" def path_from_chromium_base(self, *comps): @@ -212,13 +214,11 @@ class ChromiumPort(base.Port): if os.path.exists(cachedir): shutil.rmtree(cachedir) - def create_driver(self, image_path, options): + def create_driver(self, worker_number): """Starts a new Driver and returns a handle to it.""" - if options.use_drt and sys.platform == 'darwin': - return webkit.WebKitDriver(self, image_path, options, - executive=self._executive) - return ChromiumDriver(self, image_path, options, - executive=self._executive) + if self.get_option('use_drt') and sys.platform == 'darwin': + return webkit.WebKitDriver(self, worker_number) + return ChromiumDriver(self, worker_number) def start_helper(self): helper_path = self._path_to_helper() @@ -359,48 +359,50 @@ class ChromiumPort(base.Port): class ChromiumDriver(base.Driver): """Abstract interface for test_shell.""" - def __init__(self, port, image_path, options, executive=Executive()): + def __init__(self, port, worker_number): self._port = port - self._options = options - self._image_path = image_path - self._executive = executive - - def _driver_args(self): - driver_args = [] - if self._image_path: + self._worker_number = worker_number + self._image_path = None + if self._port.get_option('pixel_tests'): + self._image_path = os.path.join( + self._port.get_option('results_directory'), + 'png_result%s.png' % self._worker_number) + + def cmd_line(self): + cmd = self._command_wrapper(self._port.get_option('wrapper')) + cmd.append(self._port._path_to_driver()) + if self._port.get_option('pixel_tests'): # See note above in diff_image() for why we need _convert_path(). - driver_args.append("--pixel-tests=" + - self._port._convert_path(self._image_path)) + cmd.append("--pixel-tests=" + + self._port._convert_path(self._image_path)) if self._port.get_option('use_drt'): - driver_args.append('--test-shell') + cmd.append('--test-shell') else: - driver_args.append('--layout-tests') + cmd.append('--layout-tests') if self._port.get_option('startup_dialog'): - driver_args.append('--testshell-startup-dialog') + cmd.append('--testshell-startup-dialog') if self._port.get_option('gp_fault_error_box'): - driver_args.append('--gp-fault-error-box') + cmd.append('--gp-fault-error-box') - if self._options.js_flags is not None: - driver_args.append('--js-flags="' + self._options.js_flags + '"') + if self._port.get_option('js_flags') is not None: + cmd.append('--js-flags="' + self._port.get_option('js_flags') + '"') - if self._options.multiple_loads is not None and self._options.multiple_loads > 0: - driver_args.append('--multiple-loads=' + str(self._options.multiple_loads)) + if self._port.get_option('multiple_loads') > 0: + cmd.append('--multiple-loads=' + str(self._port.get_option('multiple_loads'))) if self._port.get_option('accelerated_compositing'): - driver_args.append('--enable-accelerated-compositing') + cmd.append('--enable-accelerated-compositing') if self._port.get_option('accelerated_2d_canvas'): - driver_args.append('--enable-accelerated-2d-canvas') - return driver_args + cmd.append('--enable-accelerated-2d-canvas') + return cmd def start(self): # FIXME: Should be an error to call this method twice. - cmd = self._command_wrapper(self._port.get_option('wrapper')) - cmd.append(self._port._path_to_driver()) - cmd += self._driver_args() + cmd = self.cmd_line() # We need to pass close_fds=True to work around Python bug #2320 # (otherwise we can hang when we kill DumpRenderTree when we are running @@ -454,7 +456,22 @@ class ChromiumDriver(base.Driver): else: return None - def run_test(self, uri, timeoutms, checksum): + def _output_image_with_retry(self): + # Retry a few more times because open() sometimes fails on Windows, + # raising "IOError: [Errno 13] Permission denied:" + retry_num = 50 + timeout_seconds = 5.0 + for i in range(retry_num): + try: + return self._output_image() + except IOError, e: + if e.errno == errno.EACCES: + time.sleep(timeout_seconds / retry_num) + else: + raise e + return self._output_image() + + def run_test(self, test_input): output = [] error = [] crash = False @@ -464,7 +481,9 @@ class ChromiumDriver(base.Driver): start_time = time.time() - cmd = self._test_shell_command(uri, timeoutms, checksum) + uri = self._port.filename_to_uri(test_input.filename) + cmd = self._test_shell_command(uri, test_input.timeout, + test_input.image_hash) (line, crash) = self._write_command_and_read_line(input=cmd) while not crash and line.rstrip() != "#EOF": @@ -505,9 +524,10 @@ class ChromiumDriver(base.Driver): (line, crash) = self._write_command_and_read_line(input=None) + run_time = time.time() - start_time return test_output.TestOutput( - ''.join(output), self._output_image(), actual_checksum, - crash, time.time() - start_time, timeout, ''.join(error)) + ''.join(output), self._output_image_with_retry(), actual_checksum, + crash, run_time, timeout, ''.join(error)) def stop(self): if self._proc: @@ -532,4 +552,4 @@ class ChromiumDriver(base.Driver): if self._proc.poll() is None: _log.warning('stopping test driver timed out, ' 'killing it') - self._executive.kill_process(self._proc.pid) + self._port._executive.kill_process(self._proc.pid) |