diff options
Diffstat (limited to 'WebKitTools/Scripts/webkitpy/layout_tests/port')
9 files changed, 145 insertions, 29 deletions
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py index a4cbe42..782c87c 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/base.py @@ -423,7 +423,7 @@ class Port(object): Returns: Operating-system's environment. """ - return os.environ + return os.environ.copy() def show_html_results_file(self, results_filename): """This routine should display the HTML file pointed at by diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py index bcbd498..b715f7b 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium.py @@ -158,9 +158,8 @@ class ChromiumPort(base.Port): return self.path_from_chromium_base('webkit', self._options.configuration, self._options.results_directory) except AssertionError: - return self.path_from_webkit_base('WebKit', 'chromium', - 'xcodebuild', self._options.configuration, - self._options.results_directory) + return self._build_path(self._options.configuration, + self._options.results_directory) def setup_test_run(self): # Delete the disk cache if any to ensure a clean test run. @@ -273,6 +272,12 @@ class ChromiumPort(base.Port): platform = self.name() return self.path_from_webkit_base('LayoutTests', 'platform', platform) + def _path_to_image_diff(self): + binary_name = 'image_diff' + if self._options.use_drt: + binary_name = 'ImageDiff' + return self._build_path(self._options.configuration, binary_name) + class ChromiumDriver(base.Driver): """Abstract interface for test_shell.""" diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py index 979e225..0818d51 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py @@ -81,11 +81,15 @@ class ChromiumLinuxPort(chromium.ChromiumPort): # def _build_path(self, *comps): - base = self.path_from_chromium_base() + if self._options.use_drt: + base = os.path.join(self.path_from_webkit_base(), 'WebKit', + 'chromium') + else: + base = self.path_from_chromium_base() if os.path.exists(os.path.join(base, 'sconsbuild')): - return self.path_from_chromium_base('sconsbuild', *comps) + return os.path.join(base, 'sconsbuild', *comps) else: - return self.path_from_chromium_base('out', *comps) + return os.path.join(base, 'out', *comps) def _check_apache_install(self): result = chromium.check_file_exists(self._path_to_apache(), @@ -147,14 +151,14 @@ class ChromiumLinuxPort(chromium.ChromiumPort): def _path_to_driver(self, configuration=None): if not configuration: configuration = self._options.configuration - return self._build_path(configuration, 'test_shell') + binary_name = 'test_shell' + if self._options.use_drt: + binary_name = 'DumpRenderTree' + return self._build_path(configuration, binary_name) def _path_to_helper(self): return None - def _path_to_image_diff(self): - return self._build_path(self._options.configuration, 'image_diff') - def _path_to_wdiff(self): if self._is_redhat_based(): return '/usr/bin/dwdiff' diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py index ba67a3e..aa3ac8d 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py @@ -150,12 +150,6 @@ class ChromiumMacPort(chromium.ChromiumPort): binary_name = 'LayoutTestHelper' return self._build_path(self._options.configuration, binary_name) - def _path_to_image_diff(self): - binary_name = 'image_diff' - if self._options.use_drt: - binary_name = 'ImageDiff' - return self._build_path(self._options.configuration, binary_name) - def _path_to_wdiff(self): return 'wdiff' diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py index 95d6378..a32eafd 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py @@ -27,6 +27,9 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. import chromium +import chromium_linux +import chromium_mac +import chromium_win import unittest import StringIO @@ -78,3 +81,17 @@ class ChromiumDriverTest(unittest.TestCase): raise IOError self.driver._proc.stdout.readline = mock_readline self._assert_write_command_and_read_line(expected_crash=True) + + def test_path_to_image_diff(self): + class MockOptions: + def __init__(self): + self.use_drt = True + + port = chromium_linux.ChromiumLinuxPort('test-port', options=MockOptions()) + self.assertTrue(port._path_to_image_diff().endswith( + '/out/Release/ImageDiff')) + port = chromium_mac.ChromiumMacPort('test-port', options=MockOptions()) + self.assertTrue(port._path_to_image_diff().endswith( + '/xcodebuild/Release/ImageDiff')) + # FIXME: Figure out how this is going to work on Windows. + #port = chromium_win.ChromiumWinPort('test-port', options=MockOptions()) diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py index ad78e61..3b11429 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py @@ -64,7 +64,7 @@ class ChromiumWinPort(chromium.ChromiumPort): setup_mount = self.path_from_chromium_base("third_party", "cygwin", "setup_mount.bat") - self._executive.run_command(setup_mount) + self._executive.run_command([setup_mount]) return env def baseline_search_path(self): @@ -117,6 +117,9 @@ class ChromiumWinPort(chromium.ChromiumPort): # def _build_path(self, *comps): + if self._options.use_drt: + return os.path.join(self.path_from_webkit_base(), 'WebKit', + 'chromium', *comps) p = self.path_from_chromium_base('webkit', *comps) if os.path.exists(p): return p diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py new file mode 100644 index 0000000..81db32c --- /dev/null +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py @@ -0,0 +1,74 @@ +# Copyright (C) 2010 Google Inc. All rights reserved. +# +# Redistribution and use in source and binary forms, with or without +# modification, are permitted provided that the following conditions are +# met: +# +# * Redistributions of source code must retain the above copyright +# notice, this list of conditions and the following disclaimer. +# * Redistributions in binary form must reproduce the above +# copyright notice, this list of conditions and the following disclaimer +# in the documentation and/or other materials provided with the +# distribution. +# * Neither the name of Google Inc. nor the names of its +# contributors may be used to endorse or promote products derived from +# this software without specific prior written permission. +# +# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS +# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT +# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR +# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT +# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, +# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT +# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, +# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY +# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +import os +import sys +import unittest +import chromium_win +from webkitpy.common.system import outputcapture +from webkitpy.tool import mocktool + + +class ChromiumWinTest(unittest.TestCase): + + class RegisterCygwinOption(object): + def __init__(self): + self.register_cygwin = True + + def setUp(self): + self.orig_platform = sys.platform + + def tearDown(self): + sys.platform = self.orig_platform + + def _mock_path_from_chromium_base(self, *comps): + return os.path.join("/chromium/src", *comps) + + def test_setup_environ_for_server(self): + port = chromium_win.ChromiumWinPort() + port._executive = mocktool.MockExecute(True) + port.path_from_chromium_base = self._mock_path_from_chromium_base + output = outputcapture.OutputCapture() + orig_environ = os.environ.copy() + env = output.assert_outputs(self, port.setup_environ_for_server) + self.assertEqual(orig_environ["PATH"], os.environ["PATH"]) + self.assertNotEqual(env["PATH"], os.environ["PATH"]) + + def test_setup_environ_for_server_register_cygwin(self): + sys.platform = "win32" + port = chromium_win.ChromiumWinPort( + options=ChromiumWinTest.RegisterCygwinOption()) + port._executive = mocktool.MockExecute(True) + port.path_from_chromium_base = self._mock_path_from_chromium_base + setup_mount = self._mock_path_from_chromium_base("third_party", + "cygwin", + "setup_mount.bat") + expected_stderr = "MOCK run_command: %s\n" % [setup_mount] + output = outputcapture.OutputCapture() + output.assert_outputs(self, port.setup_environ_for_server, + expected_stderr=expected_stderr) diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/dryrun.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/dryrun.py index 2c92865..e01bd2f 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/port/dryrun.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/dryrun.py @@ -143,7 +143,7 @@ class DryrunDriver(base.Driver): text_filename = self._port.expected_filename(test_name, '.txt') text_output = _read_file(text_filename) - if image_hash: + if image_hash is not None: image_filename = self._port.expected_filename(test_name, '.png') image = _read_file(image_filename, 'rb') if self._image_path: diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/port/test.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/test.py index 5d563cd..e6d4c99 100644 --- a/WebKitTools/Scripts/webkitpy/layout_tests/port/test.py +++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/test.py @@ -28,7 +28,9 @@ # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. """Dummy Port implementation used for testing.""" +from __future__ import with_statement +import codecs import os import time @@ -45,9 +47,8 @@ class TestPort(base.Port): return ('test',) def baseline_path(self): - curdir = os.path.abspath(__file__) - self.topdir = curdir[0:curdir.index("WebKitTools")] - return os.path.join(self.topdir, 'LayoutTests', 'platform', 'test') + return os.path.join(self.layout_tests_dir(), 'platform', + self.name()) def baseline_search_path(self): return [self.baseline_path()] @@ -66,12 +67,9 @@ class TestPort(base.Port): expected_filename, actual_filename): return '' - def relative_test_filename(self, filename): - return filename - - def expected_filename(self, filename, suffix): - (basename, ext) = os.path.splitext(filename) - return basename + '.' + suffix + def layout_tests_dir(self): + return self.path_from_webkit_base('WebKitTools', 'Scripts', + 'webkitpy', 'layout_tests', 'data') def name(self): return self._name @@ -79,6 +77,11 @@ class TestPort(base.Port): def options(self): return self._options + def path_to_test_expectations_file(self): + return self.path_from_webkit_base('WebKitTools', 'Scripts', + 'webkitpy', 'layout_tests', 'data', 'platform', 'test', + 'test_expectations.txt') + def results_directory(self): return '/tmp/' + self._options.results_directory @@ -104,7 +107,13 @@ class TestPort(base.Port): pass def test_expectations(self): - return '' + """Returns the test expectations for this port. + + Basically this string should contain the equivalent of a + test_expectations file. See test_expectations.py for more details.""" + expectations_path = self.path_to_test_expectations_file() + with codecs.open(expectations_path, "r", "utf-8") as file: + return file.read() def test_base_platform_names(self): return ('test',) @@ -129,6 +138,7 @@ class TestDriver(base.Driver): self._driver_options = test_driver_options self._image_path = image_path self._port = port + self._image_written = False def poll(self): return True @@ -137,6 +147,15 @@ class TestDriver(base.Driver): return 0 def run_test(self, uri, timeoutms, image_hash): + if not self._image_written and self._port._options.pixel_tests: + with open(self._image_path, "w") as f: + f.write("bad png file from TestDriver") + self._image_written = True + + # We special-case this because we can't fake an image hash for a + # missing expectation. + if uri.find('misc/missing-expectation') != -1: + return (False, False, 'deadbeefdeadbeefdeadbeefdeadbeef', '', None) return (False, False, image_hash, '', None) def start(self): |