Diff
Modified: trunk/Tools/ChangeLog (104339 => 104340)
--- trunk/Tools/ChangeLog 2012-01-06 22:22:45 UTC (rev 104339)
+++ trunk/Tools/ChangeLog 2012-01-06 22:27:18 UTC (rev 104340)
@@ -1,3 +1,33 @@
+2012-01-05 Dirk Pranke <dpra...@chromium.org>
+
+ webkitpy: clean up test/uri conversion routines
+ https://bugs.webkit.org/show_bug.cgi?id=75648
+
+ Reviewed by Eric Seidel.
+
+ This change moves test_to_uri and uri_to_test from the Port
+ class to the Driver class (the routines were only being
+ called by the drivers), and removes a bunch of stale and/or
+ busted logic.
+
+ * Scripts/webkitpy/layout_tests/port/base.py:
+ * Scripts/webkitpy/layout_tests/port/base_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/chromium.py:
+ * Scripts/webkitpy/layout_tests/port/chromium_unittest.py:
+ * Scripts/webkitpy/layout_tests/port/driver.py:
+ (is_http_test):
+ (test_to_uri):
+ (uri_to_test):
+ * Scripts/webkitpy/layout_tests/port/mock_drt.py:
+ (run_one_test):
+ * Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py:
+ (MockDRTTest.input_line):
+ (input_line):
+ (expected_output):
+ * Scripts/webkitpy/layout_tests/port/test.py:
+ * Scripts/webkitpy/layout_tests/port/webkit.py:
+ (_command_from_driver_input):
+
2012-01-06 Simon Fraser <simon.fra...@apple.com>
Mitigate scrollbar differences when running pixel tests
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py (104339 => 104340)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py 2012-01-06 22:22:45 UTC (rev 104339)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py 2012-01-06 22:27:18 UTC (rev 104340)
@@ -39,6 +39,7 @@
import re
from webkitpy.common.memoized import memoized
+from webkitpy.common.system import path
# Handle Python < 2.6 where multiprocessing isn't available.
@@ -49,7 +50,6 @@
from webkitpy.common import find_files
from webkitpy.common.system import logutils
-from webkitpy.common.system import path
from webkitpy.common.system.executive import ScriptError
from webkitpy.common.system.systemhost import SystemHost
from webkitpy.layout_tests import read_checksum_from_png
@@ -461,33 +461,6 @@
filename = self._filesystem.join(self.layout_tests_dir(), test_name)
return filename in reftest_list
- def test_to_uri(self, test_name):
- """Convert a test name to a URI."""
- LAYOUTTEST_HTTP_DIR = "http/tests/"
- LAYOUTTEST_WEBSOCKET_DIR = "http/tests/websocket/tests/"
-
- port = None
-
- relative_path = test_name
- if (relative_path.startswith(LAYOUTTEST_WEBSOCKET_DIR)
- or relative_path.startswith(LAYOUTTEST_HTTP_DIR)):
- relative_path = relative_path[len(LAYOUTTEST_HTTP_DIR):]
- port = 8000
-
- # Make http/tests/local run as local files. This is to mimic the
- # logic in run-webkit-tests.
- #
- # TODO(dpranke): remove the SSL reference?
- if (port and not relative_path.startswith("local/")):
- if relative_path.startswith("ssl/"):
- port += 443
- protocol = "https"
- else:
- protocol = "http"
- return "%s://127.0.0.1:%u/%s" % (protocol, port, relative_path)
-
- return path.abspath_to_uri(self.abspath_for_test(test_name))
-
def tests(self, paths):
"""Return the list of tests found."""
# When collecting test cases, skip these directories
@@ -567,32 +540,6 @@
"""
self._filesystem.write_binary_file(baseline_path, data)
- def uri_to_test_name(self, uri):
- """Return the base layout test name for a given URI.
-
- This returns the test name for a given URI, e.g., if you passed in
- "file:///src/LayoutTests/fast/html/keygen.html" it would return
- "fast/html/keygen.html".
-
- """
- test = uri
- if uri.startswith("file:///"):
- prefix = path.abspath_to_uri(self.layout_tests_dir()) + "/"
- return test[len(prefix):]
-
- if uri.startswith("http://127.0.0.1:8880/"):
- # websocket tests
- return test.replace('http://127.0.0.1:8880/', '')
-
- if uri.startswith("http://"):
- # regular HTTP test
- return test.replace('http://127.0.0.1:8000/', 'http/tests/')
-
- if uri.startswith("https://"):
- return test.replace('https://127.0.0.1:8443/', 'http/tests/')
-
- raise NotImplementedError('unknown url type: %s' % uri)
-
def layout_tests_dir(self):
"""Return the absolute path to the top of the LayoutTests directory."""
return self.path_from_webkit_base('LayoutTests')
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py (104339 => 104340)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py 2012-01-06 22:22:45 UTC (rev 104339)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py 2012-01-06 22:27:18 UTC (rev 104340)
@@ -226,16 +226,6 @@
self.assertTrue('canvas' in dirs)
self.assertTrue('css2.1' in dirs)
- def test_test_to_uri(self):
- port = self.make_port()
- layout_test_dir = port.layout_tests_dir()
- test = 'foo/bar.html'
- path = port._filesystem.join(layout_test_dir, test)
- if sys.platform == 'win32':
- path = path.replace("\\", "/")
-
- self.assertEqual(port.test_to_uri(test), abspath_to_uri(path))
-
def test_get_option__set(self):
options, args = optparse.OptionParser().parse_args([])
options.foo = 'bar'
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py (104339 => 104340)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py 2012-01-06 22:22:45 UTC (rev 104339)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium.py 2012-01-06 22:27:18 UTC (rev 104340)
@@ -524,7 +524,7 @@
has_audio = False
has_base64 = False
- uri = self._port.test_to_uri(driver_input.test_name)
+ uri = self.test_to_uri(driver_input.test_name)
cmd = self._test_shell_command(uri, driver_input.timeout, driver_input.image_hash)
line, crash = self._write_command_and_read_line(input=cmd)
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py (104339 => 104340)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py 2012-01-06 22:22:45 UTC (rev 104339)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_unittest.py 2012-01-06 22:27:18 UTC (rev 104340)
@@ -98,7 +98,7 @@
raise IOError
self.driver._proc.stdout.readline = mock_readline
- self.driver._port.test_to_uri = lambda test: 'mocktesturi'
+ self.driver.test_to_uri = lambda test: 'mocktesturi'
driver_output = self.driver.run_test(DriverInput(test_name='some/test.html', timeout=1, image_hash=None, is_reftest=False))
self.assertEqual(self.driver._port.driver_name(), driver_output.crashed_process_name)
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py (104339 => 104340)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py 2012-01-06 22:22:45 UTC (rev 104339)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/driver.py 2012-01-06 22:27:18 UTC (rev 104340)
@@ -28,7 +28,9 @@
import shlex
+from webkitpy.common.system import path
+
class DriverInput(object):
def __init__(self, test_name, timeout, image_hash, is_reftest):
self.test_name = test_name
@@ -91,6 +93,40 @@
# used by e.g. tools/valgrind/valgrind_tests.py.
return shlex.split(wrapper_option) if wrapper_option else []
+ HTTP_DIR = "http/tests/"
+ HTTP_LOCAL_DIR = "http/tests/local/"
+
+ def is_http_test(self, test_name):
+ return test_name.startswith(self.HTTP_DIR) and not test_name.startswith(self.HTTP_LOCAL_DIR)
+
+ def test_to_uri(self, test_name):
+ """Convert a test name to a URI."""
+ if not self.is_http_test(test_name):
+ return path.abspath_to_uri(self._port.abspath_for_test(test_name))
+
+ relative_path = test_name[len(self.HTTP_DIR):]
+
+ # TODO(dpranke): remove the SSL reference?
+ if relative_path.startswith("ssl/"):
+ return "https://127.0.0.1:8443/" + relative_path
+ return "http://127.0.0.1:8000/" + relative_path
+
+ def uri_to_test(self, uri):
+ """Return the base layout test name for a given URI.
+
+ This returns the test name for a given URI, e.g., if you passed in
+ "file:///src/LayoutTests/fast/html/keygen.html" it would return
+ "fast/html/keygen.html".
+
+ """
+ if uri.startswith("file:///"):
+ return uri[len(path.abspath_to_uri(self._port.layout_tests_dir()) + "/"):]
+ if uri.startswith("http://"):
+ return uri.replace('http://127.0.0.1:8000/', self.HTTP_DIR)
+ if uri.startswith("https://"):
+ return uri.replace('https://127.0.0.1:8443/', self.HTTP_DIR)
+ raise NotImplementedError('unknown url type: %s' % uri)
+
def has_crashed(self):
return False
@@ -113,6 +149,15 @@
else:
self._reftest_driver = driver_instance_constructor(port, worker_number, pixel_tests=True)
+ def is_http_test(self, test_name):
+ return self._driver.is_http_test(test_name)
+
+ def test_to_uri(self, test_name):
+ return self._driver.test_to_uri(test_name)
+
+ def uri_to_test(self, uri):
+ return self._driver.uri_to_test(uri)
+
def run_test(self, driver_input):
if driver_input.is_reftest:
return self._reftest_driver.run_test(driver_input)
Added: trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py (0 => 104340)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py 2012-01-06 22:27:18 UTC (rev 104340)
@@ -0,0 +1,77 @@
+# 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 sys
+import unittest
+
+from webkitpy.common.system.path import abspath_to_uri
+from webkitpy.common.host_mock import MockHost
+
+from webkitpy.layout_tests.port import Port, Driver, DriverOutput
+
+
+class DriverTest(unittest.TestCase):
+ def make_port(self):
+ return Port(MockHost())
+
+ def _assert_wrapper(self, wrapper_string, expected_wrapper):
+ wrapper = Driver(Port(MockHost()), None, pixel_tests=False)._command_wrapper(wrapper_string)
+ self.assertEqual(wrapper, expected_wrapper)
+
+ def test_command_wrapper(self):
+ self._assert_wrapper(None, [])
+ self._assert_wrapper("valgrind", ["valgrind"])
+
+ # Validate that shlex works as expected.
+ command_with_spaces = "valgrind --smc-check=\"check with spaces!\" --foo"
+ expected_parse = ["valgrind", "--smc-check=check with spaces!", "--foo"]
+ self._assert_wrapper(command_with_spaces, expected_parse)
+
+ def test_test_to_uri(self):
+ port = self.make_port()
+ driver = Driver(port, None, pixel_tests=False)
+ if sys.platform in ('cygwin', 'win32'):
+ self.assertEqual(driver.test_to_uri('foo/bar.html'), 'file:///%s/foo/bar.html' % port.layout_tests_dir())
+ else:
+ self.assertEqual(driver.test_to_uri('foo/bar.html'), 'file://%s/foo/bar.html' % port.layout_tests_dir())
+ self.assertEqual(driver.test_to_uri('http/tests/foo.html'), 'http://127.0.0.1:8000/foo.html')
+ self.assertEqual(driver.test_to_uri('http/tests/ssl/bar.html'), 'https://127.0.0.1:8443/ssl/bar.html')
+
+ def test_uri_to_test(self):
+ port = self.make_port()
+ driver = Driver(port, None, pixel_tests=False)
+ if sys.platform in ('cygwin', 'win32'):
+ self.assertEqual(driver.uri_to_test('file:///%s/foo/bar.html' % port.layout_tests_dir()), 'foo/bar.html')
+ else:
+ self.assertEqual(driver.uri_to_test('file://%s/foo/bar.html' % port.layout_tests_dir()), 'foo/bar.html')
+ self.assertEqual(driver.uri_to_test('http://127.0.0.1:8000/foo.html'), 'http/tests/foo.html')
+ self.assertEqual(driver.uri_to_test('https://127.0.0.1:8443/ssl/bar.html'), 'http/tests/ssl/bar.html')
+
+
+if __name__ == '__main__':
+ unittest.main()
Property changes on: trunk/Tools/Scripts/webkitpy/layout_tests/port/driver_unittest.py
___________________________________________________________________
Added: svn:eol-style
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py (104339 => 104340)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py 2012-01-06 22:22:45 UTC (rev 104339)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt.py 2012-01-06 22:27:18 UTC (rev 104340)
@@ -186,6 +186,7 @@
if options.platform:
port_name = options.platform
self._port = PortFactory(host).get(port_name=port_name, options=options)
+ self._driver = self._port.create_driver(0)
def run(self):
while True:
@@ -200,8 +201,8 @@
def run_one_test(self, test_input):
port = self._port
- if test_input.uri.startswith('http'):
- test_name = port.uri_to_test_name(test_input.uri)
+ if test_input.uri.startswith('http://') or test_input.uri.startswith('https://'):
+ test_name = self._driver.uri_to_test(test_input.uri)
else:
test_name = port.relative_test_filename(test_input.uri)
@@ -256,7 +257,7 @@
def run_one_test(self, test_input):
port = self._port
- test_name = self._port.uri_to_test_name(test_input.uri)
+ test_name = self._driver.uri_to_test(test_input.uri)
actual_text = port.expected_text(test_name)
actual_image = ''
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py (104339 => 104340)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py 2012-01-06 22:22:45 UTC (rev 104339)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/mock_drt_unittest.py 2012-01-06 22:27:18 UTC (rev 104340)
@@ -89,7 +89,7 @@
class MockDRTTest(unittest.TestCase):
def input_line(self, port, test_name, checksum=None):
- url = ""
+ url = ""
# FIXME: we shouldn't have to work around platform-specific issues
# here.
if url.startswith('file:////'):
@@ -215,13 +215,13 @@
return mock_drt.MockChromiumDRT(options, args, host, stdin, stdout, stderr)
def input_line(self, port, test_name, checksum=None):
- url = ""
+ url = ""
if checksum:
return url + ' 6000 ' + checksum + '\n'
return url + ' 6000\n'
def expected_output(self, port, test_name, pixel_tests, text_output, expected_checksum):
- url = ""
+ url = ""
if pixel_tests and expected_checksum:
return ['#URL:%s\n' % url,
'#MD5:%s\n' % expected_checksum,
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py (104339 => 104340)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py 2012-01-06 22:22:45 UTC (rev 104339)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py 2012-01-06 22:27:18 UTC (rev 104340)
@@ -450,68 +450,7 @@
def all_baseline_variants(self):
return self.ALL_BASELINE_VARIANTS
- # FIXME: These next two routines are copied from base.py with
- # the calls to path.abspath_to_uri() removed. We shouldn't have
- # to do this.
- def test_to_uri(self, test_name):
- """Convert a test file (which is an absolute path) to a URI."""
- LAYOUTTEST_HTTP_DIR = "http/tests/"
- LAYOUTTEST_WEBSOCKET_DIR = "http/tests/websocket/tests/"
- port = None
- use_ssl = False
-
- relative_path = test_name
- if (relative_path.startswith(LAYOUTTEST_WEBSOCKET_DIR)
- or relative_path.startswith(LAYOUTTEST_HTTP_DIR)):
- relative_path = relative_path[len(LAYOUTTEST_HTTP_DIR):]
- port = 8000
-
- # Make http/tests/local run as local files. This is to mimic the
- # logic in run-webkit-tests.
- #
- # TODO(dpranke): remove the media reference and the SSL reference?
- if (port and not relative_path.startswith("local/") and
- not relative_path.startswith("media/")):
- if relative_path.startswith("ssl/"):
- port += 443
- protocol = "https"
- else:
- protocol = "http"
- return "%s://127.0.0.1:%u/%s" % (protocol, port, relative_path)
-
- return "file://" + self.abspath_for_test(test_name)
-
- def abspath_for_test(self, test_name):
- return self.layout_tests_dir() + self.TEST_PATH_SEPARATOR + test_name
-
- def uri_to_test_name(self, uri):
- """Return the base layout test name for a given URI.
-
- This returns the test name for a given URI, e.g., if you passed in
- "file:///src/LayoutTests/fast/html/keygen.html" it would return
- "fast/html/keygen.html".
-
- """
- test = uri
- if uri.startswith("file:///"):
- prefix = "file://" + self.layout_tests_dir() + "/"
- return test[len(prefix):]
-
- if uri.startswith("http://127.0.0.1:8880/"):
- # websocket tests
- return test.replace('http://127.0.0.1:8880/', '')
-
- if uri.startswith("http://"):
- # regular HTTP test
- return test.replace('http://127.0.0.1:8000/', 'http/tests/')
-
- if uri.startswith("https://"):
- return test.replace('https://127.0.0.1:8443/', 'http/tests/')
-
- raise NotImplementedError('unknown url type: %s' % uri)
-
-
class TestDriver(Driver):
"""Test/Dummy implementation of the DumpRenderTree interface."""
Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py (104339 => 104340)
--- trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py 2012-01-06 22:22:45 UTC (rev 104339)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/webkit.py 2012-01-06 22:27:18 UTC (rev 104340)
@@ -521,8 +521,10 @@
return self._crashed_subprocess_name or self._server_process.process_name()
def _command_from_driver_input(self, driver_input):
- uri = self._port.test_to_uri(driver_input.test_name)
- command = uri[7:] if uri.startswith("file:///") else uri
+ if self.is_http_test(driver_input.test_name):
+ command = self.test_to_uri(driver_input.test_name)
+ else:
+ command = self._port.abspath_for_test(driver_input.test_name)
if driver_input.image_hash:
# FIXME: Why the leading quote?