[SCM] WebKit Debian packaging branch, debian/experimental, updated. upstream/1.3.3-9427-gc2be6fc
dpranke at chromium.org
dpranke at chromium.org
Wed Dec 22 14:41:37 UTC 2010
The following commit has been merged in the debian/experimental branch:
commit bb3966d581c617d7f6417587a37948b9cf3bb4c0
Author: dpranke at chromium.org <dpranke at chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Date: Sat Oct 16 01:31:15 2010 +0000
2010-10-15 Dirk Pranke <dpranke at chromium.org>
Reviewed by Eric Siedel.
mocktool.MockOptions is inheriting from Mock, which has the side
effect of defaulting any attribute to another MockObject. So,
MockOptions().foo would always evaluate to true. This was
covering over bugs in the unit tests, and is probably the wrong
default behavior for anything attempting to mock out the options
argument returned from optparse.parse_args().
This patch changes the default behavior. The new MockOptions()
class takes an optional list of keyword parameters to set; this
patch doesn't use that feature but the fix for bug 47510 will.
Also, this patch just fills in the default values necessary to
get all of the tests to pass; I didn't stare at each test by
hand to determine the "right" values. We can either fix that in
subsequent patches or let me know if we want to do that now (and
give me some guidance on what those values might want to be).
https://bugs.webkit.org/show_bug.cgi?id=47709
* Scripts/webkitpy/tool/commands/commandtest.py:
* Scripts/webkitpy/tool/commands/download_unittest.py:
* Scripts/webkitpy/tool/commands/upload_unittest.py:
* Scripts/webkitpy/tool/mocktool.py:
* Scripts/webkitpy/tool/steps/steps_unittest.py:
* Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py:
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@69905 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/WebKitTools/ChangeLog b/WebKitTools/ChangeLog
index 6a4c3a3..f4486bd 100644
--- a/WebKitTools/ChangeLog
+++ b/WebKitTools/ChangeLog
@@ -1,3 +1,33 @@
+2010-10-15 Dirk Pranke <dpranke at chromium.org>
+
+ Reviewed by Eric Siedel.
+
+ mocktool.MockOptions is inheriting from Mock, which has the side
+ effect of defaulting any attribute to another MockObject. So,
+ MockOptions().foo would always evaluate to true. This was
+ covering over bugs in the unit tests, and is probably the wrong
+ default behavior for anything attempting to mock out the options
+ argument returned from optparse.parse_args().
+
+ This patch changes the default behavior. The new MockOptions()
+ class takes an optional list of keyword parameters to set; this
+ patch doesn't use that feature but the fix for bug 47510 will.
+
+ Also, this patch just fills in the default values necessary to
+ get all of the tests to pass; I didn't stare at each test by
+ hand to determine the "right" values. We can either fix that in
+ subsequent patches or let me know if we want to do that now (and
+ give me some guidance on what those values might want to be).
+
+ https://bugs.webkit.org/show_bug.cgi?id=47709
+
+ * Scripts/webkitpy/tool/commands/commandtest.py:
+ * Scripts/webkitpy/tool/commands/download_unittest.py:
+ * Scripts/webkitpy/tool/commands/upload_unittest.py:
+ * Scripts/webkitpy/tool/mocktool.py:
+ * Scripts/webkitpy/tool/steps/steps_unittest.py:
+ * Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py:
+
2010-10-15 Simon Fraser <simon.fraser at apple.com>
Fix the build; need to add new slot to PageUIClient callbacks.
diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/commandtest.py b/WebKitTools/Scripts/webkitpy/tool/commands/commandtest.py
index de92cd3..adc6d81 100644
--- a/WebKitTools/Scripts/webkitpy/tool/commands/commandtest.py
+++ b/WebKitTools/Scripts/webkitpy/tool/commands/commandtest.py
@@ -33,5 +33,16 @@ from webkitpy.tool.mocktool import MockOptions, MockTool
class CommandsTest(unittest.TestCase):
def assert_execute_outputs(self, command, args, expected_stdout="", expected_stderr="", options=MockOptions(), tool=MockTool()):
+ options.blocks = True
+ options.cc = 'MOCK cc'
+ options.component = 'MOCK component'
+ options.confirm = True
+ options.email = 'MOCK email'
+ options.git_commit = 'MOCK git commit'
+ options.obsolete_patches = True
+ options.open_bug = True
+ options.port = 'MOCK port'
+ options.quiet = True
+ options.reviewer = 'MOCK reviewer'
command.bind_to_tool(tool)
OutputCapture().assert_outputs(self, command.execute, [options, args, tool], expected_stdout=expected_stdout, expected_stderr=expected_stderr)
diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/download_unittest.py b/WebKitTools/Scripts/webkitpy/tool/commands/download_unittest.py
index faddd50..6af1f64 100644
--- a/WebKitTools/Scripts/webkitpy/tool/commands/download_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/tool/commands/download_unittest.py
@@ -57,15 +57,19 @@ class AbstractRolloutPrepCommandTest(unittest.TestCase):
class DownloadCommandsTest(CommandsTest):
def _default_options(self):
options = MockOptions()
- options.force_clean = False
- options.clean = True
+ options.build = True
+ options.build_style = True
options.check_builders = True
- options.quiet = False
+ options.check_style = True
+ options.clean = True
+ options.close_bug = True
+ options.force_clean = False
+ options.force_patch = True
options.non_interactive = False
- options.update = True
- options.build = True
+ options.parent_command = 'MOCK parent command'
+ options.quiet = False
options.test = True
- options.close_bug = True
+ options.update = True
return options
def test_build(self):
diff --git a/WebKitTools/Scripts/webkitpy/tool/commands/upload_unittest.py b/WebKitTools/Scripts/webkitpy/tool/commands/upload_unittest.py
index 887d3b6..0d096b6 100644
--- a/WebKitTools/Scripts/webkitpy/tool/commands/upload_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/tool/commands/upload_unittest.py
@@ -52,11 +52,12 @@ class UploadCommandsTest(CommandsTest):
def test_post(self):
options = MockOptions()
+ options.cc = None
+ options.check_style = True
+ options.comment = None
options.description = "MOCK description"
options.request_commit = False
options.review = True
- options.comment = None
- options.cc = None
expected_stderr = """Running check-webkit-style
MOCK: user.open_url: file://...
Obsoleting 2 old patches on bug 42
@@ -81,11 +82,12 @@ MOCK: user.open_url: http://example.com/42
def test_upload(self):
options = MockOptions()
+ options.cc = None
+ options.check_style = True
+ options.comment = None
options.description = "MOCK description"
options.request_commit = False
options.review = True
- options.comment = None
- options.cc = None
expected_stderr = """Running check-webkit-style
MOCK: user.open_url: file://...
Obsoleting 2 old patches on bug 42
diff --git a/WebKitTools/Scripts/webkitpy/tool/mocktool.py b/WebKitTools/Scripts/webkitpy/tool/mocktool.py
index 5285837..45b1a2a 100644
--- a/WebKitTools/Scripts/webkitpy/tool/mocktool.py
+++ b/WebKitTools/Scripts/webkitpy/tool/mocktool.py
@@ -581,9 +581,17 @@ class MockExecute(Mock):
return "MOCK output of child process"
-class MockOptions(Mock):
- no_squash = False
- squash = False
+class MockOptions(object):
+ """Mock implementation of optparse.Values."""
+
+ def __init__(self, **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
class MockRietveld():
diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py b/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py
index 69575db..7eb8e3a 100644
--- a/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/tool/steps/steps_unittest.py
@@ -37,20 +37,29 @@ from webkitpy.tool.steps.promptforbugortitle import PromptForBugOrTitle
class StepsTest(unittest.TestCase):
+ def _step_options(self):
+ options = MockOptions()
+ options.non_interactive = True
+ options.port = 'MOCK port'
+ options.quiet = True
+ options.test = True
+ return options
+
def _run_step(self, step, tool=None, options=None, state=None):
if not tool:
tool = MockTool()
if not options:
- options = MockOptions()
+ options = self._step_options()
if not state:
state = {}
step(tool, options).run(state)
def test_update_step(self):
- options = MockOptions()
+ tool = MockTool()
+ options = self._step_options()
options.update = True
expected_stderr = "Updating working directory\n"
- OutputCapture().assert_outputs(self, self._run_step, [Update, options], expected_stderr=expected_stderr)
+ OutputCapture().assert_outputs(self, self._run_step, [Update, tool, options], expected_stderr=expected_stderr)
def test_prompt_for_bug_or_title_step(self):
tool = MockTool()
@@ -62,8 +71,8 @@ class StepsTest(unittest.TestCase):
OutputCapture().assert_outputs(self, self._run_step, [RunTests], expected_stderr=expected_stderr)
def test_runtests_leopard_commit_queue_hack_command(self):
- mock_options = MockOptions()
- mock_options.non_interactive = True
+ mock_options = self._step_options()
+ step = RunTests(MockTool(log_executive=True), mock_options)
# FIXME: We shouldn't use a real port-object here, but there is too much to mock at the moment.
mock_port = WebKitPort()
mock_port.name = lambda: "Mac"
diff --git a/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py b/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py
index a037422..b475378 100644
--- a/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/tool/steps/updatechangelogswithreview_unittest.py
@@ -41,5 +41,8 @@ class UpdateChangeLogsWithReviewerTest(unittest.TestCase):
def test_empty_state(self):
capture = OutputCapture()
- step = UpdateChangeLogsWithReviewer(MockTool(), MockOptions())
+ options = MockOptions()
+ options.reviewer = 'MOCK reviewer'
+ options.git_commit = 'MOCK git commit'
+ step = UpdateChangeLogsWithReviewer(MockTool(), options)
capture.assert_outputs(self, step.run, [{}])
--
WebKit Debian packaging
More information about the Pkg-webkit-commits
mailing list