Title: [137781] trunk/Tools
Revision
137781
Author
dpra...@chromium.org
Date
2012-12-14 15:18:25 -0800 (Fri, 14 Dec 2012)

Log Message

webkitpy: make port_name a required parameter to the non-test ports
https://bugs.webkit.org/show_bug.cgi?id=105057

Reviewed by Eric Seidel.

This is just minor code cleanup along the path to making Port
constructors simpler and pushing more logic into the port factory.

* Scripts/webkitpy/layout_tests/port/base.py:
(Port.__init__):
* Scripts/webkitpy/layout_tests/port/base_unittest.py:
(PortTest.make_port):
* Scripts/webkitpy/layout_tests/port/port_testcase.py:
(TestWebKitPort.__init__):
* Scripts/webkitpy/layout_tests/port/test.py:
(TestPort):
(TestPort.determine_full_port_name):
(TestPort.__init__):
* Scripts/webkitpy/layout_tests/port/xvfbdriver_unittest.py:
(XvfbDriverTest.make_driver):
(XvfbDriverTest.test_stop):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (137780 => 137781)


--- trunk/Tools/ChangeLog	2012-12-14 23:17:03 UTC (rev 137780)
+++ trunk/Tools/ChangeLog	2012-12-14 23:18:25 UTC (rev 137781)
@@ -1,5 +1,29 @@
 2012-12-14  Dirk Pranke  <dpra...@chromium.org>
 
+        webkitpy: make port_name a required parameter to the non-test ports
+        https://bugs.webkit.org/show_bug.cgi?id=105057
+
+        Reviewed by Eric Seidel.
+
+        This is just minor code cleanup along the path to making Port
+        constructors simpler and pushing more logic into the port factory.
+
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        (Port.__init__):
+        * Scripts/webkitpy/layout_tests/port/base_unittest.py:
+        (PortTest.make_port):
+        * Scripts/webkitpy/layout_tests/port/port_testcase.py:
+        (TestWebKitPort.__init__):
+        * Scripts/webkitpy/layout_tests/port/test.py:
+        (TestPort):
+        (TestPort.determine_full_port_name):
+        (TestPort.__init__):
+        * Scripts/webkitpy/layout_tests/port/xvfbdriver_unittest.py:
+        (XvfbDriverTest.make_driver):
+        (XvfbDriverTest.test_stop):
+
+2012-12-14  Dirk Pranke  <dpra...@chromium.org>
+
         garden-o-matic doesn't know about reftests
         https://bugs.webkit.org/show_bug.cgi?id=101976
 

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py (137780 => 137781)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2012-12-14 23:17:03 UTC (rev 137780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2012-12-14 23:18:25 UTC (rev 137781)
@@ -94,14 +94,12 @@
             return port_name + '-wk2'
         return port_name
 
-    def __init__(self, host, port_name=None, options=None, **kwargs):
+    def __init__(self, host, port_name, options=None, **kwargs):
 
         # This value may be different from cls.port_name by having version modifiers
         # and other fields appended to it (for example, 'qt-arm' or 'mac-wk2').
+        self._name = port_name
 
-        # FIXME: port_name should be a required parameter. It isn't yet because lots of tests need to be updatd.
-        self._name = port_name or self.port_name
-
         # These are default values that should be overridden in a subclasses.
         self._version = ''
         self._architecture = 'x86'

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py (137780 => 137781)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py	2012-12-14 23:17:03 UTC (rev 137780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base_unittest.py	2012-12-14 23:18:25 UTC (rev 137781)
@@ -46,14 +46,14 @@
 from webkitpy.layout_tests.port.test import add_unit_tests_to_mock_filesystem, TestPort
 
 class PortTest(unittest.TestCase):
-    def make_port(self, executive=None, with_tests=False, **kwargs):
+    def make_port(self, executive=None, with_tests=False, port_name=None, **kwargs):
         host = MockSystemHost()
         if executive:
             host.executive = executive
         if with_tests:
             add_unit_tests_to_mock_filesystem(host.filesystem)
             return TestPort(host, **kwargs)
-        return Port(host, **kwargs)
+        return Port(host, port_name or 'baseport', **kwargs)
 
     def test_default_child_processes(self):
         port = self.make_port()

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py (137780 => 137781)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py	2012-12-14 23:17:03 UTC (rev 137780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/port_testcase.py	2012-12-14 23:18:25 UTC (rev 137781)
@@ -55,7 +55,7 @@
                  **kwargs):
         self.symbols_string = symbols_string  # Passing "" disables all staticly-detectable features.
         host = host or MockSystemHost()
-        super(TestWebKitPort, self).__init__(host=host, **kwargs)
+        super(TestWebKitPort, self).__init__(host, TestWebKitPort.port_name, **kwargs)
 
     def all_test_configurations(self):
         return [self.test_configuration()]

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py (137780 => 137781)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py	2012-12-14 23:17:03 UTC (rev 137780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/test.py	2012-12-14 23:18:25 UTC (rev 137781)
@@ -347,6 +347,7 @@
 
 class TestPort(Port):
     port_name = 'test'
+    default_port_name = 'test-mac-leopard'
 
     """Test implementation of the Port interface."""
     ALL_BASELINE_VARIANTS = (
@@ -358,23 +359,20 @@
     @classmethod
     def determine_full_port_name(cls, host, options, port_name):
         if port_name == 'test':
-            return 'test-mac-leopard'
+            return TestPort.default_port_name
         return port_name
 
     def __init__(self, host, port_name=None, **kwargs):
-        # FIXME: Consider updating all of the callers to pass in a port_name so it can be a
-        # required parameter like all of the other Port objects.
-        port_name = port_name or 'test-mac-leopard'
-        Port.__init__(self, host, port_name, **kwargs)
+        Port.__init__(self, host, port_name or TestPort.default_port_name, **kwargs)
         self._tests = unit_test_list()
         self._flakes = set()
         self._expectations_path = LAYOUT_TEST_DIR + '/platform/test/TestExpectations'
         self._results_directory = None
 
         self._operating_system = 'mac'
-        if port_name.startswith('test-win'):
+        if self._name.startswith('test-win'):
             self._operating_system = 'win'
-        elif port_name.startswith('test-linux'):
+        elif self._name.startswith('test-linux'):
             self._operating_system = 'linux'
 
         version_map = {
@@ -385,7 +383,7 @@
             'test-mac-snowleopard': 'snowleopard',
             'test-linux-x86_64': 'lucid',
         }
-        self._version = version_map[port_name]
+        self._version = version_map[self._name]
 
     def default_pixel_tests(self):
         return True

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/xvfbdriver_unittest.py (137780 => 137781)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/xvfbdriver_unittest.py	2012-12-14 23:17:03 UTC (rev 137780)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/xvfbdriver_unittest.py	2012-12-14 23:18:25 UTC (rev 137781)
@@ -43,7 +43,7 @@
 
 class XvfbDriverTest(unittest.TestCase):
     def make_driver(self, worker_number=0, xorg_running=False, executive=None):
-        port = Port(host=MockSystemHost(log_executive=True, executive=executive), options=MockOptions(configuration='Release'))
+        port = Port(MockSystemHost(log_executive=True, executive=executive), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
         port._config.build_directory = lambda configuration: "/mock-build"
         port._server_process_constructor = MockServerProcess
         if xorg_running:
@@ -118,7 +118,7 @@
 
     def test_stop(self):
         filesystem = MockFileSystem(files={'/tmp/.X42-lock': '1234\n'})
-        port = Port(host=MockSystemHost(log_executive=True, filesystem=filesystem), options=MockOptions(configuration='Release'))
+        port = Port(MockSystemHost(log_executive=True, filesystem=filesystem), 'xvfbdrivertestport', options=MockOptions(configuration='Release'))
         port._executive.kill_process = lambda x: _log.info("MOCK kill_process pid: " + str(x))
         driver = XvfbDriver(port, worker_number=0, pixel_tests=True)
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
http://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to