Title: [120419] trunk/Tools
Revision
120419
Author
[email protected]
Date
2012-06-15 00:50:57 -0700 (Fri, 15 Jun 2012)

Log Message

Unreviewed, rolling out r120370.
http://trac.webkit.org/changeset/120370
https://bugs.webkit.org/show_bug.cgi?id=89183

Broke webkit-patch rebaseline (Requested by zdobersek on
#webkit).

Patch by Sheriff Bot <[email protected]> on 2012-06-15

* Scripts/webkitpy/layout_tests/port/base.py:
(DummyOptions):
(DummyOptions.__init__):
(DummyOptions.__init__.this):
(Port.__init__):
(Port.get_option):
(Port.set_option_default):
* Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
(ChromiumWinTest.RegisterCygwinOption):
(ChromiumWinTest.RegisterCygwinOption.__init__):
(ChromiumWinTest.test_setup_environ_for_server_register_cygwin):
* Scripts/webkitpy/style/checkers/test_expectations.py:
(TestExpectationsChecker._determine_port_from_expectations_path):
* Scripts/webkitpy/tool/mocktool.py:
(MockOptions.update):

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (120418 => 120419)


--- trunk/Tools/ChangeLog	2012-06-15 07:40:30 UTC (rev 120418)
+++ trunk/Tools/ChangeLog	2012-06-15 07:50:57 UTC (rev 120419)
@@ -1,3 +1,28 @@
+2012-06-15  Sheriff Bot  <[email protected]>
+
+        Unreviewed, rolling out r120370.
+        http://trac.webkit.org/changeset/120370
+        https://bugs.webkit.org/show_bug.cgi?id=89183
+
+        Broke webkit-patch rebaseline (Requested by zdobersek on
+        #webkit).
+
+        * Scripts/webkitpy/layout_tests/port/base.py:
+        (DummyOptions):
+        (DummyOptions.__init__):
+        (DummyOptions.__init__.this):
+        (Port.__init__):
+        (Port.get_option):
+        (Port.set_option_default):
+        * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py:
+        (ChromiumWinTest.RegisterCygwinOption):
+        (ChromiumWinTest.RegisterCygwinOption.__init__):
+        (ChromiumWinTest.test_setup_environ_for_server_register_cygwin):
+        * Scripts/webkitpy/style/checkers/test_expectations.py:
+        (TestExpectationsChecker._determine_port_from_expectations_path):
+        * Scripts/webkitpy/tool/mocktool.py:
+        (MockOptions.update):
+
 2012-06-14  Xianzhu Wang  <[email protected]>
 
         [Chromium-Android] Initialize font rendering in DumpRenderTree

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


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2012-06-15 07:40:30 UTC (rev 120418)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py	2012-06-15 07:50:57 UTC (rev 120419)
@@ -34,7 +34,6 @@
 import difflib
 import errno
 import os
-import optparse
 import re
 
 try:
@@ -62,6 +61,19 @@
 _log = logutils.get_logger(__file__)
 
 
+class DummyOptions(object):
+    """Fake implementation of optparse.Values. Cloned from webkitpy.tool.mocktool.MockOptions."""
+
+    def __init__(self, *args, **kwargs):
+        # The caller can set option values using keyword arguments. We don't
+        # set any values by default because we don't know how this
+        # object will be used. Generally speaking unit tests should
+        # subclass this or provider wrapper functions that set a common
+        # set of options.
+        for key, value in kwargs.items():
+            self.__dict__[key] = value
+
+
 # FIXME: This class should merge with WebKitPort now that Chromium behaves mostly like other webkit ports.
 class Port(object):
     """Abstract class for Port-specific hooks for the layout_test package."""
@@ -99,7 +111,7 @@
         # FIXME: Ideally we'd have a package-wide way to get a
         # well-formed options object that had all of the necessary
         # options defined on it.
-        self._options = options or optparse.Values()
+        self._options = options or DummyOptions()
 
         self.host = host
         self._executive = host.executive
@@ -666,10 +678,18 @@
         return self._architecture
 
     def get_option(self, name, default_value=None):
-        return getattr(self._options, name, default_value)
+        # FIXME: Eventually we should not have to do a test for
+        # hasattr(), and we should be able to just do
+        # self.options.value. See additional FIXME in the constructor.
+        if hasattr(self._options, name):
+            return getattr(self._options, name)
+        return default_value
 
     def set_option_default(self, name, default_value):
-        return self._options.ensure_value(name, default_value)
+        # FIXME: Callers could also use optparse_parser.Values.ensure_value,
+        # since this should always be a optparse_parser.Values object.
+        if not hasattr(self._options, name) or getattr(self._options, name) is None:
+            return setattr(self._options, name, default_value)
 
     def path_from_webkit_base(self, *comps):
         """Returns the full path to path made by joining the top of the

Modified: trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py (120418 => 120419)


--- trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py	2012-06-15 07:40:30 UTC (rev 120418)
+++ trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py	2012-06-15 07:50:57 UTC (rev 120419)
@@ -38,6 +38,11 @@
 
 
 class ChromiumWinTest(port_testcase.PortTestCase):
+    class RegisterCygwinOption(object):
+        def __init__(self):
+            self.register_cygwin = True
+            self.results_directory = '/'
+
     port_name = 'chromium-win'
     port_maker = chromium_win.ChromiumWinPort
     os_name = 'win'
@@ -62,7 +67,7 @@
         self.assertEquals(env['CYGWIN_PATH'], '/mock-checkout/Source/WebKit/chromium/third_party/cygwin/bin')
 
     def test_setup_environ_for_server_register_cygwin(self):
-        port = self.make_port(options=MockOptions(register_cygwin=True, results_directory='/'))
+        port = self.make_port(options=ChromiumWinTest.RegisterCygwinOption())
         port._executive = MockExecutive(should_log=True)
         expected_stderr = "MOCK run_command: ['/mock-checkout/Source/WebKit/chromium/third_party/cygwin/setup_mount.bat'], cwd=None\n"
         output = outputcapture.OutputCapture()

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py (120418 => 120419)


--- trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py	2012-06-15 07:40:30 UTC (rev 120418)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py	2012-06-15 07:50:57 UTC (rev 120419)
@@ -29,7 +29,6 @@
 """Checks WebKit style for test_expectations files."""
 
 import logging
-import optparse
 import os
 import re
 import sys
@@ -37,6 +36,7 @@
 from common import TabChecker
 from webkitpy.common.host import Host
 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser
+from webkitpy.layout_tests.port.base import DummyOptions
 
 
 _log = logging.getLogger(__name__)
@@ -49,7 +49,7 @@
 
     def _determine_port_from_expectations_path(self, host, expectations_path):
         # Pass a configuration to avoid calling default_configuration() when initializing the port (takes 0.5 seconds on a Mac Pro!).
-        options = optparse.Values({'configuration': 'Release'})
+        options = DummyOptions(configuration='Release')
         for port_name in host.port_factory.all_port_names():
             port = host.port_factory.get(port_name, options=options)
             if port.path_to_test_expectations_file().replace(port.path_from_webkit_base() + host.filesystem.sep, '') == expectations_path:

Modified: trunk/Tools/Scripts/webkitpy/tool/mocktool.py (120418 => 120419)


--- trunk/Tools/Scripts/webkitpy/tool/mocktool.py	2012-06-15 07:40:30 UTC (rev 120418)
+++ trunk/Tools/Scripts/webkitpy/tool/mocktool.py	2012-06-15 07:50:57 UTC (rev 120419)
@@ -36,7 +36,8 @@
 from webkitpy.common.config.ports_mock import MockPort
 
 
-# FIXME: We should just replace this with optparse.Values(default=kwargs)
+# FIXME: This should be moved somewhere in common and renamed
+# something without Mock in the name.
 class MockOptions(object):
     """Mock implementation of optparse.Values."""
 
@@ -52,12 +53,7 @@
         self.__dict__.update(**kwargs)
         return self
 
-    def ensure_value(self, key, value):
-        if getattr(self, key, None) == None:
-            self.__dict__[key] = value
-        return self.__dict__[key]
 
-
 # FIXME: This should be renamed MockWebKitPatch.
 class MockTool(MockHost):
     def __init__(self, *args, **kwargs):
_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to