OLD | NEW |
1 # Copyright (C) 2010 Google Inc. All rights reserved. | 1 # Copyright (C) 2010 Google Inc. All rights reserved. |
2 # | 2 # |
3 # Redistribution and use in source and binary forms, with or without | 3 # Redistribution and use in source and binary forms, with or without |
4 # modification, are permitted provided that the following conditions are | 4 # modification, are permitted provided that the following conditions are |
5 # met: | 5 # met: |
6 # | 6 # |
7 # * Redistributions of source code must retain the above copyright | 7 # * Redistributions of source code must retain the above copyright |
8 # notice, this list of conditions and the following disclaimer. | 8 # notice, this list of conditions and the following disclaimer. |
9 # * Redistributions in binary form must reproduce the above | 9 # * Redistributions in binary form must reproduce the above |
10 # copyright notice, this list of conditions and the following disclaimer | 10 # copyright notice, this list of conditions and the following disclaimer |
(...skipping 15 matching lines...) Expand all Loading... |
26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 26 # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 27 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
28 | 28 |
29 import codecs | 29 import codecs |
30 import os | 30 import os |
31 import shutil | 31 import shutil |
32 import tempfile | 32 import tempfile |
33 import unittest2 as unittest | 33 import unittest2 as unittest |
34 | 34 |
35 from .checkout import Checkout | 35 from .checkout import Checkout |
36 from .scm import CommitMessage, SCMDetector | 36 from .scm import SCMDetector |
37 from .scm.scm_mock import MockSCM | 37 from .scm.scm_mock import MockSCM |
38 from webkitpy.common.webkit_finder import WebKitFinder | 38 from webkitpy.common.webkit_finder import WebKitFinder |
39 from webkitpy.common.system.executive import Executive, ScriptError | 39 from webkitpy.common.system.executive import Executive, ScriptError |
40 from webkitpy.common.system.filesystem import FileSystem # FIXME: This should n
ot be needed. | 40 from webkitpy.common.system.filesystem import FileSystem # FIXME: This should n
ot be needed. |
41 from webkitpy.common.system.filesystem_mock import MockFileSystem | 41 from webkitpy.common.system.filesystem_mock import MockFileSystem |
42 from webkitpy.common.system.executive_mock import MockExecutive | 42 from webkitpy.common.system.executive_mock import MockExecutive |
43 from webkitpy.common.system.outputcapture import OutputCapture | 43 from webkitpy.common.system.outputcapture import OutputCapture |
44 from webkitpy.thirdparty.mock import Mock | 44 from webkitpy.thirdparty.mock import Mock |
45 | 45 |
46 | 46 |
47 _changelog1entry1 = u"""2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org> | |
48 | |
49 Unreviewed build fix to un-break webkit-patch land. | |
50 | |
51 Move commit_message_for_this_commit from scm to checkout | |
52 https://bugs.webkit.org/show_bug.cgi?id=36629 | |
53 | |
54 * Scripts/webkitpy/common/checkout/api.py: import scm.CommitMessage | |
55 """ | |
56 _changelog1entry2 = u"""2010-03-25 Adam Barth <abarth@webkit.org> | |
57 | |
58 Reviewed by Eric Seidel. | |
59 | |
60 Move commit_message_for_this_commit from scm to checkout | |
61 https://bugs.webkit.org/show_bug.cgi?id=36629 | |
62 | |
63 * Scripts/webkitpy/common/checkout/api.py: | |
64 """ | |
65 _changelog1 = u"\n".join([_changelog1entry1, _changelog1entry2]) | |
66 _changelog2 = u"""2010-03-25 Tor Arne Vestb\u00f8 <vestbo@webkit.org> | |
67 | |
68 Unreviewed build fix to un-break webkit-patch land. | |
69 | |
70 Second part of this complicated change by me, Tor Arne Vestb\u00f8! | |
71 | |
72 * Path/To/Complicated/File: Added. | |
73 | |
74 2010-03-25 Adam Barth <abarth@webkit.org> | |
75 | |
76 Reviewed by Eric Seidel. | |
77 | |
78 Filler change. | |
79 """ | |
80 | |
81 class CommitMessageForThisCommitTest(unittest.TestCase): | |
82 expected_commit_message = u"""Unreviewed build fix to un-break webkit-patch
land. | |
83 | |
84 Tools: | |
85 | |
86 Move commit_message_for_this_commit from scm to checkout | |
87 https://bugs.webkit.org/show_bug.cgi?id=36629 | |
88 | |
89 * Scripts/webkitpy/common/checkout/api.py: import scm.CommitMessage | |
90 | |
91 LayoutTests: | |
92 | |
93 Second part of this complicated change by me, Tor Arne Vestb\u00f8! | |
94 | |
95 * Path/To/Complicated/File: Added. | |
96 """ | |
97 | |
98 def setUp(self): | |
99 # FIXME: This should not need to touch the filesystem, however | |
100 # ChangeLog is difficult to mock at current. | |
101 self.filesystem = FileSystem() | |
102 self.temp_dir = str(self.filesystem.mkdtemp(suffix="changelogs")) | |
103 self.old_cwd = self.filesystem.getcwd() | |
104 self.filesystem.chdir(self.temp_dir) | |
105 self.webkit_base = WebKitFinder(self.filesystem).webkit_base() | |
106 | |
107 # Trick commit-log-editor into thinking we're in a Subversion working co
py so it won't | |
108 # complain about not being able to figure out what SCM is in use. | |
109 # FIXME: VCSTools.pm is no longer so easily fooled. It logs because "sv
n info" doesn't | |
110 # treat a bare .svn directory being part of an svn checkout. | |
111 self.filesystem.maybe_make_directory(".svn") | |
112 | |
113 self.changelogs = map(self.filesystem.abspath, (self.filesystem.join("To
ols", "ChangeLog"), self.filesystem.join("LayoutTests", "ChangeLog"))) | |
114 for path, contents in zip(self.changelogs, (_changelog1, _changelog2)): | |
115 self.filesystem.maybe_make_directory(self.filesystem.dirname(path)) | |
116 self.filesystem.write_text_file(path, contents) | |
117 | |
118 def tearDown(self): | |
119 self.filesystem.rmtree(self.temp_dir) | |
120 self.filesystem.chdir(self.old_cwd) | |
121 | |
122 | |
123 class CheckoutTest(unittest.TestCase): | 47 class CheckoutTest(unittest.TestCase): |
124 def _make_checkout(self): | 48 def _make_checkout(self): |
125 return Checkout(scm=MockSCM(), filesystem=MockFileSystem(), executive=Mo
ckExecutive()) | 49 return Checkout(scm=MockSCM(), filesystem=MockFileSystem(), executive=Mo
ckExecutive()) |
126 | 50 |
127 def test_apply_patch(self): | 51 def test_apply_patch(self): |
128 checkout = self._make_checkout() | 52 checkout = self._make_checkout() |
129 checkout._executive = MockExecutive(should_log=True) | 53 checkout._executive = MockExecutive(should_log=True) |
130 checkout._scm.script_path = lambda script: script | 54 checkout._scm.script_path = lambda script: script |
131 mock_patch = Mock() | 55 mock_patch = Mock() |
132 mock_patch.contents = lambda: "foo" | 56 mock_patch.contents = lambda: "foo" |
133 mock_patch.reviewer = lambda: None | 57 mock_patch.reviewer = lambda: None |
134 expected_logs = "MOCK run_command: ['svn-apply', '--force'], cwd=/mock-c
heckout, input=foo\n" | 58 expected_logs = "MOCK run_command: ['svn-apply', '--force'], cwd=/mock-c
heckout, input=foo\n" |
135 OutputCapture().assert_outputs(self, checkout.apply_patch, [mock_patch],
expected_logs=expected_logs) | 59 OutputCapture().assert_outputs(self, checkout.apply_patch, [mock_patch],
expected_logs=expected_logs) |
OLD | NEW |