Changeset 120370 in webkit
- Timestamp:
- Jun 14, 2012, 4:18:09 PM (14 years ago)
- Location:
- trunk/Tools
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
Scripts/webkitpy/layout_tests/port/base.py (modified) (4 diffs)
-
Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py (modified) (2 diffs)
-
Scripts/webkitpy/style/checkers/test_expectations.py (modified) (3 diffs)
-
Scripts/webkitpy/tool/mocktool.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Tools/ChangeLog
r120360 r120370 1 2012-06-14 Dirk Pranke <dpranke@chromium.org> 2 3 webkitpy: remove DummyOptions and clean up the code in Port.get_option() and Port.set_option_default() 4 https://bugs.webkit.org/show_bug.cgi?id=89135 5 6 Reviewed by Ryosuke Niwa. 7 8 This patch is just some minor cleanup and simplification. There 9 should be no functional changes here. 10 11 * Scripts/webkitpy/layout_tests/port/base.py: 12 (Port.__init__): 13 (Port.get_option): 14 (Port.set_option_default): 15 * Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py: 16 (ChromiumWinTest.test_setup_environ_for_server_register_cygwin): 17 * Scripts/webkitpy/style/checkers/test_expectations.py: 18 (TestExpectationsChecker._determine_port_from_expectations_path): 19 * Scripts/webkitpy/tool/mocktool.py: 20 (MockOptions.ensure_value): 21 1 22 2012-06-14 Ian Vollick <vollick@chromium.org> 2 23 -
trunk/Tools/Scripts/webkitpy/layout_tests/port/base.py
r120349 r120370 35 35 import errno 36 36 import os 37 import optparse 37 38 import re 38 39 … … 62 63 63 64 64 class DummyOptions(object):65 """Fake implementation of optparse.Values. Cloned from webkitpy.tool.mocktool.MockOptions."""66 67 def __init__(self, *args, **kwargs):68 # The caller can set option values using keyword arguments. We don't69 # set any values by default because we don't know how this70 # object will be used. Generally speaking unit tests should71 # subclass this or provider wrapper functions that set a common72 # set of options.73 for key, value in kwargs.items():74 self.__dict__[key] = value75 76 77 65 # FIXME: This class should merge with WebKitPort now that Chromium behaves mostly like other webkit ports. 78 66 class Port(object): … … 112 100 # well-formed options object that had all of the necessary 113 101 # options defined on it. 114 self._options = options or DummyOptions()102 self._options = options or optparse.Values() 115 103 116 104 self.host = host … … 679 667 680 668 def get_option(self, name, default_value=None): 681 # FIXME: Eventually we should not have to do a test for 682 # hasattr(), and we should be able to just do 683 # self.options.value. See additional FIXME in the constructor. 684 if hasattr(self._options, name): 685 return getattr(self._options, name) 686 return default_value 669 return getattr(self._options, name, default_value) 687 670 688 671 def set_option_default(self, name, default_value): 689 # FIXME: Callers could also use optparse_parser.Values.ensure_value, 690 # since this should always be a optparse_parser.Values object. 691 if not hasattr(self._options, name) or getattr(self._options, name) is None: 692 return setattr(self._options, name, default_value) 672 return self._options.ensure_value(name, default_value) 693 673 694 674 def path_from_webkit_base(self, *comps): -
trunk/Tools/Scripts/webkitpy/layout_tests/port/chromium_win_unittest.py
r119649 r120370 39 39 40 40 class ChromiumWinTest(port_testcase.PortTestCase): 41 class RegisterCygwinOption(object):42 def __init__(self):43 self.register_cygwin = True44 self.results_directory = '/'45 46 41 port_name = 'chromium-win' 47 42 port_maker = chromium_win.ChromiumWinPort … … 68 63 69 64 def test_setup_environ_for_server_register_cygwin(self): 70 port = self.make_port(options= ChromiumWinTest.RegisterCygwinOption())65 port = self.make_port(options=MockOptions(register_cygwin=True, results_directory='/')) 71 66 port._executive = MockExecutive(should_log=True) 72 67 expected_stderr = "MOCK run_command: ['/mock-checkout/Source/WebKit/chromium/third_party/cygwin/setup_mount.bat'], cwd=None\n" -
trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py
r120238 r120370 30 30 31 31 import logging 32 import optparse 32 33 import os 33 34 import re … … 37 38 from webkitpy.common.host import Host 38 39 from webkitpy.layout_tests.models.test_expectations import TestExpectationParser 39 from webkitpy.layout_tests.port.base import DummyOptions40 40 41 41 … … 50 50 def _determine_port_from_expectations_path(self, host, expectations_path): 51 51 # Pass a configuration to avoid calling default_configuration() when initializing the port (takes 0.5 seconds on a Mac Pro!). 52 options = DummyOptions(configuration='Release')52 options = optparse.Values({'configuration': 'Release'}) 53 53 for port_name in host.port_factory.all_port_names(): 54 54 port = host.port_factory.get(port_name, options=options) -
trunk/Tools/Scripts/webkitpy/tool/mocktool.py
r113802 r120370 37 37 38 38 39 # FIXME: This should be moved somewhere in common and renamed 40 # something without Mock in the name. 39 # FIXME: We should just replace this with optparse.Values(default=kwargs) 41 40 class MockOptions(object): 42 41 """Mock implementation of optparse.Values.""" … … 53 52 self.__dict__.update(**kwargs) 54 53 return self 54 55 def ensure_value(self, key, value): 56 if getattr(self, key, None) == None: 57 self.__dict__[key] = value 58 return self.__dict__[key] 55 59 56 60
Note:
See TracChangeset
for help on using the changeset viewer.