Changeset 69905 in webkit
- Timestamp:
- Oct 15, 2010 6:31:15 PM (14 years ago)
- Location:
- trunk/WebKitTools
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/WebKitTools/ChangeLog
r69894 r69905 1 2010-10-15 Dirk Pranke <dpranke@chromium.org> 2 3 Reviewed by Eric Siedel. 4 5 mocktool.MockOptions is inheriting from Mock, which has the side 6 effect of defaulting any attribute to another MockObject. So, 7 MockOptions().foo would always evaluate to true. This was 8 covering over bugs in the unit tests, and is probably the wrong 9 default behavior for anything attempting to mock out the options 10 argument returned from optparse.parse_args(). 11 12 This patch changes the default behavior. The new MockOptions() 13 class takes an optional list of keyword parameters to set; this 14 patch doesn't use that feature but the fix for bug 47510 will. 15 16 Also, this patch just fills in the default values necessary to 17 get all of the tests to pass; I didn't stare at each test by 18 hand to determine the "right" values. We can either fix that in 19 subsequent patches or let me know if we want to do that now (and 20 give me some guidance on what those values might want to be). 21 22 https://bugs.webkit.org/show_bug.cgi?id=47709 23 24 * Scripts/webkitpy/tool/commands/commandtest.py: 25 * Scripts/webkitpy/tool/commands/download_unittest.py: 26 * Scripts/webkitpy/tool/commands/upload_unittest.py: 27 * Scripts/webkitpy/tool/mocktool.py: 28 * Scripts/webkitpy/tool/steps/steps_unittest.py: 29 * Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py: 30 1 31 2010-10-15 Simon Fraser <simon.fraser@apple.com> 2 32 -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/commandtest.py
r63020 r69905 34 34 class CommandsTest(unittest.TestCase): 35 35 def assert_execute_outputs(self, command, args, expected_stdout="", expected_stderr="", options=MockOptions(), tool=MockTool()): 36 options.blocks = True 37 options.cc = 'MOCK cc' 38 options.component = 'MOCK component' 39 options.confirm = True 40 options.email = 'MOCK email' 41 options.git_commit = 'MOCK git commit' 42 options.obsolete_patches = True 43 options.open_bug = True 44 options.port = 'MOCK port' 45 options.quiet = True 46 options.reviewer = 'MOCK reviewer' 36 47 command.bind_to_tool(tool) 37 48 OutputCapture().assert_outputs(self, command.execute, [options, args, tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr) -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/download_unittest.py
r66058 r69905 58 58 def _default_options(self): 59 59 options = MockOptions() 60 options.build = True 61 options.build_style = True 62 options.check_builders = True 63 options.check_style = True 64 options.clean = True 65 options.close_bug = True 60 66 options.force_clean = False 61 options.clean = True 62 options.check_builders = True 67 options.force_patch = True 68 options.non_interactive = False 69 options.parent_command = 'MOCK parent command' 63 70 options.quiet = False 64 options. non_interactive = False71 options.test = True 65 72 options.update = True 66 options.build = True67 options.test = True68 options.close_bug = True69 73 return options 70 74 -
trunk/WebKitTools/Scripts/webkitpy/tool/commands/upload_unittest.py
r68746 r69905 53 53 def test_post(self): 54 54 options = MockOptions() 55 options.cc = None 56 options.check_style = True 57 options.comment = None 55 58 options.description = "MOCK description" 56 59 options.request_commit = False 57 60 options.review = True 58 options.comment = None59 options.cc = None60 61 expected_stderr = """Running check-webkit-style 61 62 MOCK: user.open_url: file://... … … 82 83 def test_upload(self): 83 84 options = MockOptions() 85 options.cc = None 86 options.check_style = True 87 options.comment = None 84 88 options.description = "MOCK description" 85 89 options.request_commit = False 86 90 options.review = True 87 options.comment = None88 options.cc = None89 91 expected_stderr = """Running check-webkit-style 90 92 MOCK: user.open_url: file://... -
trunk/WebKitTools/Scripts/webkitpy/tool/mocktool.py
r69843 r69905 582 582 583 583 584 class MockOptions(Mock): 585 no_squash = False 586 squash = False 584 class MockOptions(object): 585 """Mock implementation of optparse.Values.""" 586 587 def __init__(self, **kwargs): 588 # The caller can set option values using keyword arguments. We don't 589 # set any values by default because we don't know how this 590 # object will be used. Generally speaking unit tests should 591 # subclass this or provider wrapper functions that set a common 592 # set of options. 593 for key, value in kwargs.items(): 594 self.__dict__[key] = value 587 595 588 596 -
trunk/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py
r69829 r69905 38 38 39 39 class StepsTest(unittest.TestCase): 40 def _step_options(self): 41 options = MockOptions() 42 options.non_interactive = True 43 options.port = 'MOCK port' 44 options.quiet = True 45 options.test = True 46 return options 47 40 48 def _run_step(self, step, tool=None, options=None, state=None): 41 49 if not tool: 42 50 tool = MockTool() 43 51 if not options: 44 options = MockOptions()52 options = self._step_options() 45 53 if not state: 46 54 state = {} … … 48 56 49 57 def test_update_step(self): 50 options = MockOptions() 58 tool = MockTool() 59 options = self._step_options() 51 60 options.update = True 52 61 expected_stderr = "Updating working directory\n" 53 OutputCapture().assert_outputs(self, self._run_step, [Update, options], expected_stderr=expected_stderr)62 OutputCapture().assert_outputs(self, self._run_step, [Update, tool, options], expected_stderr=expected_stderr) 54 63 55 64 def test_prompt_for_bug_or_title_step(self): … … 63 72 64 73 def test_runtests_leopard_commit_queue_hack_command(self): 65 mock_options = MockOptions()66 mock_options.non_interactive = True74 mock_options = self._step_options() 75 step = RunTests(MockTool(log_executive=True), mock_options) 67 76 # FIXME: We shouldn't use a real port-object here, but there is too much to mock at the moment. 68 77 mock_port = WebKitPort() -
trunk/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py
r63020 r69905 42 42 def test_empty_state(self): 43 43 capture = OutputCapture() 44 step = UpdateChangeLogsWithReviewer(MockTool(), MockOptions()) 44 options = MockOptions() 45 options.reviewer = 'MOCK reviewer' 46 options.git_commit = 'MOCK git commit' 47 step = UpdateChangeLogsWithReviewer(MockTool(), options) 45 48 capture.assert_outputs(self, step.run, [{}])
Note: See TracChangeset
for help on using the changeset viewer.