Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(151)

Side by Side Diff: tools/push-to-trunk/test_scripts.py

Issue 148593004: A64: Synchronize with r18084. (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/a64
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/push-to-trunk/push_to_trunk.py ('k') | tools/run-tests.py » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 #!/usr/bin/env python 1 #!/usr/bin/env python
2 # Copyright 2013 the V8 project authors. All rights reserved. 2 # Copyright 2013 the V8 project authors. All rights reserved.
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 10 # copyright notice, this list of conditions and the following
(...skipping 16 matching lines...) Expand all
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 os 29 import os
30 import tempfile 30 import tempfile
31 import unittest 31 import unittest
32 32
33 import common_includes 33 import common_includes
34 from common_includes import * 34 from common_includes import *
35 import push_to_trunk 35 import push_to_trunk
36 from push_to_trunk import * 36 from push_to_trunk import *
37 import auto_roll
37 38
38 39
39 TEST_CONFIG = { 40 TEST_CONFIG = {
40 BRANCHNAME: "test-prepare-push", 41 BRANCHNAME: "test-prepare-push",
41 TRUNKBRANCH: "test-trunk-push", 42 TRUNKBRANCH: "test-trunk-push",
42 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", 43 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile",
43 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", 44 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script",
44 DOT_GIT_LOCATION: None, 45 DOT_GIT_LOCATION: None,
45 VERSION_FILE: None, 46 VERSION_FILE: None,
46 CHANGELOG_FILE: None, 47 CHANGELOG_FILE: None,
47 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", 48 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry",
48 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", 49 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch",
49 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", 50 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg",
50 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", 51 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium",
51 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", 52 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS",
52 } 53 }
53 54
54 55
55 class ToplevelTest(unittest.TestCase): 56 class ToplevelTest(unittest.TestCase):
57 def testMakeComment(self):
58 self.assertEquals("# Line 1\n# Line 2\n#",
59 MakeComment(" Line 1\n Line 2\n"))
60 self.assertEquals("#Line 1\n#Line 2",
61 MakeComment("Line 1\n Line 2"))
62
63 def testStripComments(self):
64 self.assertEquals(" Line 1\n Line 3\n",
65 StripComments(" Line 1\n# Line 2\n Line 3\n#\n"))
66 self.assertEquals("\nLine 2 ### Test\n #",
67 StripComments("###\n# \n\n# Line 1\nLine 2 ### Test\n #"))
68
56 def testMakeChangeLogBodySimple(self): 69 def testMakeChangeLogBodySimple(self):
57 commits = lambda: [ 70 commits = [
58 [" Title text 1", 71 ["Title text 1",
59 "Title text 1\n\nBUG=\n", 72 "Title text 1\n\nBUG=\n",
60 " author1@chromium.org"], 73 "author1@chromium.org"],
61 [" Title text 2", 74 ["Title text 2.",
62 "Title text 2\n\nBUG=1234\n", 75 "Title text 2\n\nBUG=1234\n",
63 " author2@chromium.org"], 76 "author2@chromium.org"],
64 ] 77 ]
65 self.assertEquals(" Title text 1\n" 78 self.assertEquals(" Title text 1.\n"
66 " author1@chromium.org\n\n" 79 " (author1@chromium.org)\n\n"
67 " Title text 2\n" 80 " Title text 2 (Chromium issue 1234).\n"
68 " (Chromium issue 1234)\n" 81 " (author2@chromium.org)\n\n",
69 " author2@chromium.org\n\n",
70 MakeChangeLogBody(commits)) 82 MakeChangeLogBody(commits))
71 83
72 def testMakeChangeLogBodyEmpty(self): 84 def testMakeChangeLogBodyEmpty(self):
73 commits = lambda: [] 85 self.assertEquals("", MakeChangeLogBody([]))
74 self.assertEquals("", MakeChangeLogBody(commits)) 86
87 def testMakeChangeLogBodyAutoFormat(self):
88 commits = [
89 ["Title text 1!",
90 "Title text 1\nLOG=y\nBUG=\n",
91 "author1@chromium.org"],
92 ["Title text 2",
93 "Title text 2\n\nBUG=1234\n",
94 "author2@chromium.org"],
95 ["Title text 3",
96 "Title text 3\n\nBUG=1234\nLOG = Yes\n",
97 "author3@chromium.org"],
98 ["Title text 3",
99 "Title text 4\n\nBUG=1234\nLOG=\n",
100 "author4@chromium.org"],
101 ]
102 self.assertEquals(" Title text 1.\n\n"
103 " Title text 3 (Chromium issue 1234).\n\n",
104 MakeChangeLogBody(commits, True))
75 105
76 def testMakeChangeLogBugReferenceEmpty(self): 106 def testMakeChangeLogBugReferenceEmpty(self):
77 self.assertEquals("", MakeChangeLogBugReference("")) 107 self.assertEquals("", MakeChangeLogBugReference(""))
78 self.assertEquals("", MakeChangeLogBugReference("LOG=")) 108 self.assertEquals("", MakeChangeLogBugReference("LOG="))
79 self.assertEquals("", MakeChangeLogBugReference(" BUG =")) 109 self.assertEquals("", MakeChangeLogBugReference(" BUG ="))
80 self.assertEquals("", MakeChangeLogBugReference("BUG=none\t")) 110 self.assertEquals("", MakeChangeLogBugReference("BUG=none\t"))
81 111
82 def testMakeChangeLogBugReferenceSimple(self): 112 def testMakeChangeLogBugReferenceSimple(self):
83 self.assertEquals(" (issue 987654)\n", 113 self.assertEquals("(issue 987654)",
84 MakeChangeLogBugReference("BUG = v8:987654")) 114 MakeChangeLogBugReference("BUG = v8:987654"))
85 self.assertEquals(" (Chromium issue 987654)\n", 115 self.assertEquals("(Chromium issue 987654)",
86 MakeChangeLogBugReference("BUG=987654 ")) 116 MakeChangeLogBugReference("BUG=987654 "))
87 117
88 def testMakeChangeLogBugReferenceFromBody(self): 118 def testMakeChangeLogBugReferenceFromBody(self):
89 self.assertEquals(" (Chromium issue 1234567)\n", 119 self.assertEquals("(Chromium issue 1234567)",
90 MakeChangeLogBugReference("Title\n\nTBR=\nBUG=\n" 120 MakeChangeLogBugReference("Title\n\nTBR=\nBUG=\n"
91 " BUG=\tchromium:1234567\t\n" 121 " BUG=\tchromium:1234567\t\n"
92 "R=somebody\n")) 122 "R=somebody\n"))
93 123
94 def testMakeChangeLogBugReferenceMultiple(self): 124 def testMakeChangeLogBugReferenceMultiple(self):
95 # All issues should be sorted and grouped. Multiple references to the same 125 # All issues should be sorted and grouped. Multiple references to the same
96 # issue should be filtered. 126 # issue should be filtered.
97 self.assertEquals(" (issues 123, 234, Chromium issue 345)\n", 127 self.assertEquals("(issues 123, 234, Chromium issue 345)",
98 MakeChangeLogBugReference("Title\n\n" 128 MakeChangeLogBugReference("Title\n\n"
99 "BUG=v8:234\n" 129 "BUG=v8:234\n"
100 " BUG\t= 345, \tv8:234,\n" 130 " BUG\t= 345, \tv8:234,\n"
101 "BUG=v8:123\n" 131 "BUG=v8:123\n"
102 "R=somebody\n")) 132 "R=somebody\n"))
103 self.assertEquals(" (Chromium issues 123, 234)\n", 133 self.assertEquals("(Chromium issues 123, 234)",
104 MakeChangeLogBugReference("Title\n\n" 134 MakeChangeLogBugReference("Title\n\n"
105 "BUG=234,,chromium:123 \n" 135 "BUG=234,,chromium:123 \n"
106 "R=somebody\n")) 136 "R=somebody\n"))
107 self.assertEquals(" (Chromium issues 123, 234)\n", 137 self.assertEquals("(Chromium issues 123, 234)",
108 MakeChangeLogBugReference("Title\n\n" 138 MakeChangeLogBugReference("Title\n\n"
109 "BUG=chromium:234, , 123\n" 139 "BUG=chromium:234, , 123\n"
110 "R=somebody\n")) 140 "R=somebody\n"))
111 self.assertEquals(" (issues 345, 456)\n", 141 self.assertEquals("(issues 345, 456)",
112 MakeChangeLogBugReference("Title\n\n" 142 MakeChangeLogBugReference("Title\n\n"
113 "\t\tBUG=v8:345,v8:456\n" 143 "\t\tBUG=v8:345,v8:456\n"
114 "R=somebody\n")) 144 "R=somebody\n"))
115 self.assertEquals(" (issue 123, Chromium issues 345, 456)\n", 145 self.assertEquals("(issue 123, Chromium issues 345, 456)",
116 MakeChangeLogBugReference("Title\n\n" 146 MakeChangeLogBugReference("Title\n\n"
117 "BUG=chromium:456\n" 147 "BUG=chromium:456\n"
118 "BUG = none\n" 148 "BUG = none\n"
119 "R=somebody\n" 149 "R=somebody\n"
120 "BUG=456,v8:123, 345")) 150 "BUG=456,v8:123, 345"))
121 151
152 # TODO(machenbach): These test don't make much sense when the formatting is
153 # done later.
122 def testMakeChangeLogBugReferenceLong(self): 154 def testMakeChangeLogBugReferenceLong(self):
123 # -----------------00--------10--------20--------30-------- 155 # -----------------00--------10--------20--------30--------
124 self.assertEquals(" (issues 234, 1234567890, 1234567" 156 self.assertEquals("(issues 234, 1234567890, 1234567"
125 "8901234567890, Chromium issues 12345678,\n" 157 "8901234567890, Chromium issues 12345678,"
126 " 123456789)\n", 158 " 123456789)",
127 MakeChangeLogBugReference("BUG=v8:234\n" 159 MakeChangeLogBugReference("BUG=v8:234\n"
128 "BUG=v8:1234567890\n" 160 "BUG=v8:1234567890\n"
129 "BUG=v8:12345678901234567890\n" 161 "BUG=v8:12345678901234567890\n"
130 "BUG=123456789\n" 162 "BUG=123456789\n"
131 "BUG=12345678\n")) 163 "BUG=12345678\n"))
132 # -----------------00--------10--------20--------30-------- 164 # -----------------00--------10--------20--------30--------
133 self.assertEquals(" (issues 234, 1234567890, 1234567" 165 self.assertEquals("(issues 234, 1234567890, 1234567"
134 "8901234567890, Chromium issues\n" 166 "8901234567890, Chromium issues"
135 " 123456789, 1234567890)\n", 167 " 123456789, 1234567890)",
136 MakeChangeLogBugReference("BUG=v8:234\n" 168 MakeChangeLogBugReference("BUG=v8:234\n"
137 "BUG=v8:12345678901234567890\n" 169 "BUG=v8:12345678901234567890\n"
138 "BUG=v8:1234567890\n" 170 "BUG=v8:1234567890\n"
139 "BUG=123456789\n" 171 "BUG=123456789\n"
140 "BUG=1234567890\n")) 172 "BUG=1234567890\n"))
141 # -----------------00--------10--------20--------30-------- 173 # -----------------00--------10--------20--------30--------
142 self.assertEquals(" (Chromium issues 234, 1234567890" 174 self.assertEquals("(Chromium issues 234, 1234567890"
143 ", 12345678901234567,\n" 175 ", 12345678901234567, "
144 " 1234567890123456789)\n", 176 "1234567890123456789)",
145 MakeChangeLogBugReference("BUG=234\n" 177 MakeChangeLogBugReference("BUG=234\n"
146 "BUG=12345678901234567\n" 178 "BUG=12345678901234567\n"
147 "BUG=1234567890123456789\n" 179 "BUG=1234567890123456789\n"
148 "BUG=1234567890\n")) 180 "BUG=1234567890\n"))
149 181
182
183 class SimpleMock(object):
184 def __init__(self, name):
185 self._name = name
186 self._recipe = []
187 self._index = -1
188
189 def Expect(self, recipe):
190 self._recipe = recipe
191
192 def Call(self, *args):
193 self._index += 1
194 try:
195 expected_call = self._recipe[self._index]
196 except IndexError:
197 raise Exception("Calling %s %s" % (self._name, " ".join(args)))
198
199 # Pack expectations without arguments into a list.
200 if not isinstance(expected_call, list):
201 expected_call = [expected_call]
202
203 # The number of arguments in the expectation must match the actual
204 # arguments.
205 if len(args) > len(expected_call):
206 raise Exception("When calling %s with arguments, the expectations "
207 "must consist of at least as many arguments.")
208
209 # Compare expected and actual arguments.
210 for (expected_arg, actual_arg) in zip(expected_call, args):
211 if expected_arg != actual_arg:
212 raise Exception("Expected: %s - Actual: %s"
213 % (expected_arg, actual_arg))
214
215 # The expectation list contains a mandatory return value and an optional
216 # callback for checking the context at the time of the call.
217 if len(expected_call) == len(args) + 2:
218 expected_call[len(args) + 1]()
219 return expected_call[len(args)]
220
221 def AssertFinished(self):
222 if self._index < len(self._recipe) -1:
223 raise Exception("Called %s too seldom: %d vs. %d"
224 % (self._name, self._index, len(self._recipe)))
225
226
150 class ScriptTest(unittest.TestCase): 227 class ScriptTest(unittest.TestCase):
151 def MakeEmptyTempFile(self): 228 def MakeEmptyTempFile(self):
152 handle, name = tempfile.mkstemp() 229 handle, name = tempfile.mkstemp()
153 os.close(handle) 230 os.close(handle)
154 self._tmp_files.append(name) 231 self._tmp_files.append(name)
155 return name 232 return name
156 233
157 def MakeTempVersionFile(self): 234 def MakeTempVersionFile(self):
158 name = self.MakeEmptyTempFile() 235 name = self.MakeEmptyTempFile()
159 with open(name, "w") as f: 236 with open(name, "w") as f:
160 f.write(" // Some line...\n") 237 f.write(" // Some line...\n")
161 f.write("\n") 238 f.write("\n")
162 f.write("#define MAJOR_VERSION 3\n") 239 f.write("#define MAJOR_VERSION 3\n")
163 f.write("#define MINOR_VERSION 22\n") 240 f.write("#define MINOR_VERSION 22\n")
164 f.write("#define BUILD_NUMBER 5\n") 241 f.write("#define BUILD_NUMBER 5\n")
165 f.write("#define PATCH_LEVEL 0\n") 242 f.write("#define PATCH_LEVEL 0\n")
166 f.write(" // Some line...\n") 243 f.write(" // Some line...\n")
167 f.write("#define IS_CANDIDATE_VERSION 0\n") 244 f.write("#define IS_CANDIDATE_VERSION 0\n")
168 return name 245 return name
169 246
170 def MakeStep(self, step_class=Step, state=None): 247 def MakeStep(self, step_class=Step, state=None):
171 state = state or {} 248 """Convenience wrapper."""
172 step = step_class() 249 return MakeStep(step_class=step_class, number=0, state=state,
173 step.SetConfig(TEST_CONFIG) 250 config=TEST_CONFIG, options=None, side_effect_handler=self)
174 step.SetState(state)
175 step.SetNumber(0)
176 step.SetSideEffectHandler(self)
177 return step
178 251
179 def GitMock(self, cmd, args="", pipe=True): 252 def GitMock(self, cmd, args="", pipe=True):
180 self._git_index += 1 253 return self._git_mock.Call(args)
181 try:
182 git_invocation = self._git_recipe[self._git_index]
183 except IndexError:
184 raise Exception("Calling git %s" % args)
185 if git_invocation[0] != args:
186 raise Exception("Expected: %s - Actual: %s" % (git_invocation[0], args))
187 if len(git_invocation) == 3:
188 # Run optional function checking the context during this git command.
189 git_invocation[2]()
190 return git_invocation[1]
191 254
192 def LogMock(self, cmd, args=""): 255 def LogMock(self, cmd, args=""):
193 print "Log: %s %s" % (cmd, args) 256 print "Log: %s %s" % (cmd, args)
194 257
195 MOCKS = { 258 MOCKS = {
196 "git": GitMock, 259 "git": GitMock,
197 "vi": LogMock, 260 "vi": LogMock,
198 } 261 }
199 262
200 def Command(self, cmd, args="", prefix="", pipe=True): 263 def Command(self, cmd, args="", prefix="", pipe=True):
201 return ScriptTest.MOCKS[cmd](self, cmd, args) 264 return ScriptTest.MOCKS[cmd](self, cmd, args)
202 265
203 def ReadLine(self): 266 def ReadLine(self):
204 self._rl_index += 1 267 return self._rl_mock.Call()
205 try: 268
206 return self._rl_recipe[self._rl_index] 269 def ReadURL(self, url):
207 except IndexError: 270 return self._url_mock.Call(url)
208 raise Exception("Calling readline too often") 271
272 def ExpectGit(self, *args):
273 """Convenience wrapper."""
274 self._git_mock.Expect(*args)
275
276 def ExpectReadline(self, *args):
277 """Convenience wrapper."""
278 self._rl_mock.Expect(*args)
279
280 def ExpectReadURL(self, *args):
281 """Convenience wrapper."""
282 self._url_mock.Expect(*args)
209 283
210 def setUp(self): 284 def setUp(self):
211 self._git_recipe = [] 285 self._git_mock = SimpleMock("git")
212 self._git_index = -1 286 self._rl_mock = SimpleMock("readline")
213 self._rl_recipe = [] 287 self._url_mock = SimpleMock("readurl")
214 self._rl_index = -1
215 self._tmp_files = [] 288 self._tmp_files = []
216 289
217 def tearDown(self): 290 def tearDown(self):
218 Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME]) 291 Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME])
219 292
220 # Clean up temps. Doesn't work automatically. 293 # Clean up temps. Doesn't work automatically.
221 for name in self._tmp_files: 294 for name in self._tmp_files:
222 if os.path.exists(name): 295 if os.path.exists(name):
223 os.remove(name) 296 os.remove(name)
224 297
225 if self._git_index < len(self._git_recipe) -1: 298 self._git_mock.AssertFinished()
226 raise Exception("Called git too seldom: %d vs. %d" % 299 self._rl_mock.AssertFinished()
227 (self._git_index, len(self._git_recipe))) 300 self._url_mock.AssertFinished()
228 if self._rl_index < len(self._rl_recipe) -1:
229 raise Exception("Too little input: %d vs. %d" %
230 (self._rl_index, len(self._rl_recipe)))
231 301
232 def testPersistRestore(self): 302 def testPersistRestore(self):
233 self.MakeStep().Persist("test1", "") 303 self.MakeStep().Persist("test1", "")
234 self.assertEquals("", self.MakeStep().Restore("test1")) 304 self.assertEquals("", self.MakeStep().Restore("test1"))
235 self.MakeStep().Persist("test2", "AB123") 305 self.MakeStep().Persist("test2", "AB123")
236 self.assertEquals("AB123", self.MakeStep().Restore("test2")) 306 self.assertEquals("AB123", self.MakeStep().Restore("test2"))
237 307
238 def testGitOrig(self): 308 def testGitOrig(self):
239 self.assertTrue(Command("git", "--version").startswith("git version")) 309 self.assertTrue(Command("git", "--version").startswith("git version"))
240 310
241 def testGitMock(self): 311 def testGitMock(self):
242 self._git_recipe = [["--version", "git version 1.2.3"], ["dummy", ""]] 312 self.ExpectGit([["--version", "git version 1.2.3"], ["dummy", ""]])
243 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) 313 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version"))
244 self.assertEquals("", self.MakeStep().Git("dummy")) 314 self.assertEquals("", self.MakeStep().Git("dummy"))
245 315
246 def testCommonPrepareDefault(self): 316 def testCommonPrepareDefault(self):
247 self._git_recipe = [ 317 self.ExpectGit([
248 ["status -s -uno", ""], 318 ["status -s -uno", ""],
249 ["status -s -b -uno", "## some_branch"], 319 ["status -s -b -uno", "## some_branch"],
250 ["svn fetch", ""], 320 ["svn fetch", ""],
251 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 321 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]],
252 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], 322 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""],
253 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], 323 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""],
254 ["branch", ""], 324 ["branch", ""],
255 ] 325 ])
256 self._rl_recipe = ["Y"] 326 self.ExpectReadline(["Y"])
257 self.MakeStep().CommonPrepare() 327 self.MakeStep().CommonPrepare()
258 self.MakeStep().PrepareBranch() 328 self.MakeStep().PrepareBranch()
259 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) 329 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch"))
260 330
261 def testCommonPrepareNoConfirm(self): 331 def testCommonPrepareNoConfirm(self):
262 self._git_recipe = [ 332 self.ExpectGit([
263 ["status -s -uno", ""], 333 ["status -s -uno", ""],
264 ["status -s -b -uno", "## some_branch"], 334 ["status -s -b -uno", "## some_branch"],
265 ["svn fetch", ""], 335 ["svn fetch", ""],
266 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 336 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]],
267 ] 337 ])
268 self._rl_recipe = ["n"] 338 self.ExpectReadline(["n"])
269 self.MakeStep().CommonPrepare() 339 self.MakeStep().CommonPrepare()
270 self.assertRaises(Exception, self.MakeStep().PrepareBranch) 340 self.assertRaises(Exception, self.MakeStep().PrepareBranch)
271 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) 341 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch"))
272 342
273 def testCommonPrepareDeleteBranchFailure(self): 343 def testCommonPrepareDeleteBranchFailure(self):
274 self._git_recipe = [ 344 self.ExpectGit([
275 ["status -s -uno", ""], 345 ["status -s -uno", ""],
276 ["status -s -b -uno", "## some_branch"], 346 ["status -s -b -uno", "## some_branch"],
277 ["svn fetch", ""], 347 ["svn fetch", ""],
278 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 348 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]],
279 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None], 349 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None],
280 ] 350 ])
281 self._rl_recipe = ["Y"] 351 self.ExpectReadline(["Y"])
282 self.MakeStep().CommonPrepare() 352 self.MakeStep().CommonPrepare()
283 self.assertRaises(Exception, self.MakeStep().PrepareBranch) 353 self.assertRaises(Exception, self.MakeStep().PrepareBranch)
284 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) 354 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch"))
285 355
286 def testInitialEnvironmentChecks(self): 356 def testInitialEnvironmentChecks(self):
287 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 357 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
288 os.environ["EDITOR"] = "vi" 358 os.environ["EDITOR"] = "vi"
289 self.MakeStep().InitialEnvironmentChecks() 359 self.MakeStep().InitialEnvironmentChecks()
290 360
291 def testReadAndPersistVersion(self): 361 def testReadAndPersistVersion(self):
(...skipping 27 matching lines...) Expand all
319 389
320 self.assertEqual("//\n#define BUILD_NUMBER 3\n", 390 self.assertEqual("//\n#define BUILD_NUMBER 3\n",
321 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", 391 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
322 r"\g<space>3", 392 r"\g<space>3",
323 "//\n#define BUILD_NUMBER 321\n")) 393 "//\n#define BUILD_NUMBER 321\n"))
324 394
325 def testPrepareChangeLog(self): 395 def testPrepareChangeLog(self):
326 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 396 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
327 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 397 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
328 398
329 self._git_recipe = [ 399 self.ExpectGit([
330 ["log 1234..HEAD --format=%H", "rev1\nrev2"], 400 ["log 1234..HEAD --format=%H", "rev1\nrev2\nrev3\nrev4"],
331 ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Title text 1"], 401 ["log -1 rev1 --format=\"%s\"", "Title text 1"],
332 ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\n"], 402 ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\nLOG=y\n"],
333 ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", 403 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org"],
334 " author1@chromium.org"], 404 ["log -1 rev2 --format=\"%s\"", "Title text 2."],
335 ["log -1 rev2 --format=\"%w(80,8,8)%s\"", " Title text 2"], 405 ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=123\nLOG= \n"],
336 ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=321\n"], 406 ["log -1 rev2 --format=\"%an\"", "author2@chromium.org"],
337 ["log -1 rev2 --format=\"%w(80,8,8)(%an)\"", 407 ["log -1 rev3 --format=\"%s\"", "Title text 3"],
338 " author2@chromium.org"], 408 ["log -1 rev3 --format=\"%B\"", "Title\n\nBUG=321\nLOG=true\n"],
339 ] 409 ["log -1 rev3 --format=\"%an\"", "author3@chromium.org"],
410 ["log -1 rev4 --format=\"%s\"", "Title text 4"],
411 ["log -1 rev4 --format=\"%B\"",
412 ("Title\n\nBUG=456\nLOG=Y\n\n"
413 "Review URL: https://codereview.chromium.org/9876543210\n")],
414 ["log -1 rev4 --format=\"%an\"", "author4@chromium.org"],
415 ])
416
417 # The cl for rev4 on rietveld has an updated LOG flag.
418 self.ExpectReadURL([
419 ["https://codereview.chromium.org/9876543210/description",
420 "Title\n\nBUG=456\nLOG=N\n\n"],
421 ])
340 422
341 self.MakeStep().Persist("last_push", "1234") 423 self.MakeStep().Persist("last_push", "1234")
342 self.MakeStep(PrepareChangeLog).Run() 424 self.MakeStep(PrepareChangeLog).Run()
343 425
344 cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 426 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
345 self.assertTrue(re.search(r"\d+\-\d+\-\d+: Version 3\.22\.5", cl)) 427
346 self.assertTrue(re.search(r" Title text 1", cl)) 428 # TODO(machenbach): Mock out call to date() in order to make a fixed
347 self.assertTrue(re.search(r" Title text 2", cl)) 429 # comparison here instead of a regexp match.
348 self.assertTrue(re.search(r" author1@chromium.org", cl)) 430 expected_cl = """\\d+\\-\\d+\\-\\d+: Version 3\\.22\\.5
349 self.assertTrue(re.search(r" author2@chromium.org", cl)) 431
350 self.assertTrue(re.search(r" \(Chromium issue 321\)", cl)) 432 Title text 1.
351 self.assertFalse(re.search(r"BUG=", cl)) 433
434 Title text 3 \\(Chromium issue 321\\).
435
436 Performance and stability improvements on all platforms\\.
437 #
438 # The change log above is auto-generated\\. Please review if all relevant
439 # commit messages from the list below are included\\.
440 # All lines starting with # will be stripped\\.
441 #
442 # Title text 1.
443 # \\(author1@chromium\\.org\\)
444 #
445 # Title text 2 \\(Chromium issue 123\\).
446 # \\(author2@chromium\\.org\\)
447 #
448 # Title text 3 \\(Chromium issue 321\\).
449 # \\(author3@chromium\\.org\\)
450 #
451 # Title text 4 \\(Chromium issue 456\\).
452 # \\(author4@chromium\\.org\\)
453 #
454 #"""
455
456 self.assertTrue(re.match(expected_cl, actual_cl))
352 self.assertEquals("3", self.MakeStep().Restore("major")) 457 self.assertEquals("3", self.MakeStep().Restore("major"))
353 self.assertEquals("22", self.MakeStep().Restore("minor")) 458 self.assertEquals("22", self.MakeStep().Restore("minor"))
354 self.assertEquals("5", self.MakeStep().Restore("build")) 459 self.assertEquals("5", self.MakeStep().Restore("build"))
355 self.assertEquals("0", self.MakeStep().Restore("patch")) 460 self.assertEquals("0", self.MakeStep().Restore("patch"))
356 461
357 def testEditChangeLog(self): 462 def testEditChangeLog(self):
358 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 463 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
359 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 464 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
360 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) 465 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE])
361 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 466 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE])
362 os.environ["EDITOR"] = "vi" 467 os.environ["EDITOR"] = "vi"
363 468
364 self._rl_recipe = [ 469 self.ExpectReadline([
365 "", # Open editor. 470 "", # Open editor.
366 ] 471 ])
367 472
368 self.MakeStep(EditChangeLog).Run() 473 self.MakeStep(EditChangeLog).Run()
369 474
370 self.assertEquals(" New\n Lines\n\n\n Original CL", 475 self.assertEquals("New\n Lines\n\n\n Original CL",
371 FileToText(TEST_CONFIG[CHANGELOG_FILE])) 476 FileToText(TEST_CONFIG[CHANGELOG_FILE]))
372 477
373 def testIncrementVersion(self): 478 def testIncrementVersion(self):
374 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 479 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
375 self.MakeStep().Persist("build", "5") 480 self.MakeStep().Persist("build", "5")
376 481
377 self._rl_recipe = [ 482 self.ExpectReadline([
378 "Y", # Increment build number. 483 "Y", # Increment build number.
379 ] 484 ])
380 485
381 self.MakeStep(IncrementVersion).Run() 486 self.MakeStep(IncrementVersion).Run()
382 487
383 self.assertEquals("3", self.MakeStep().Restore("new_major")) 488 self.assertEquals("3", self.MakeStep().Restore("new_major"))
384 self.assertEquals("22", self.MakeStep().Restore("new_minor")) 489 self.assertEquals("22", self.MakeStep().Restore("new_minor"))
385 self.assertEquals("6", self.MakeStep().Restore("new_build")) 490 self.assertEquals("6", self.MakeStep().Restore("new_build"))
386 self.assertEquals("0", self.MakeStep().Restore("new_patch")) 491 self.assertEquals("0", self.MakeStep().Restore("new_patch"))
387 492
388 def testLastChangeLogEntries(self): 493 def testLastChangeLogEntries(self):
389 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 494 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
(...skipping 15 matching lines...) Expand all
405 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 510 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
406 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: 511 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f:
407 f.write("1999-11-11: Version 3.22.5\n") 512 f.write("1999-11-11: Version 3.22.5\n")
408 f.write("\n") 513 f.write("\n")
409 f.write(" Log text 1.\n") 514 f.write(" Log text 1.\n")
410 f.write(" Chromium issue 12345\n") 515 f.write(" Chromium issue 12345\n")
411 f.write("\n") 516 f.write("\n")
412 f.write(" Performance and stability improvements on all " 517 f.write(" Performance and stability improvements on all "
413 "platforms.\n") 518 "platforms.\n")
414 519
415 self._git_recipe = [ 520 self.ExpectGit([
416 ["diff svn/trunk hash1", "patch content"], 521 ["diff svn/trunk hash1", "patch content"],
417 ] 522 ])
418 523
419 self.MakeStep().Persist("prepare_commit_hash", "hash1") 524 self.MakeStep().Persist("prepare_commit_hash", "hash1")
420 self.MakeStep().Persist("date", "1999-11-11") 525 self.MakeStep().Persist("date", "1999-11-11")
421 526
422 self.MakeStep(SquashCommits).Run() 527 self.MakeStep(SquashCommits).Run()
423 528
424 msg = FileToText(TEST_CONFIG[COMMITMSG_FILE]) 529 msg = FileToText(TEST_CONFIG[COMMITMSG_FILE])
425 self.assertTrue(re.search(r"Version 3\.22\.5", msg)) 530 self.assertTrue(re.search(r"Version 3\.22\.5", msg))
426 self.assertTrue(re.search(r"Performance and stability", msg)) 531 self.assertTrue(re.search(r"Performance and stability", msg))
427 self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg)) 532 self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg))
(...skipping 10 matching lines...) Expand all
438 if not os.path.exists(TEST_CONFIG[CHROMIUM]): 543 if not os.path.exists(TEST_CONFIG[CHROMIUM]):
439 os.makedirs(TEST_CONFIG[CHROMIUM]) 544 os.makedirs(TEST_CONFIG[CHROMIUM])
440 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE]) 545 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE])
441 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", 546 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line",
442 TEST_CONFIG[DEPS_FILE]) 547 TEST_CONFIG[DEPS_FILE])
443 os.environ["EDITOR"] = "vi" 548 os.environ["EDITOR"] = "vi"
444 549
445 def CheckPreparePush(): 550 def CheckPreparePush():
446 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) 551 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
447 self.assertTrue(re.search(r"Version 3.22.5", cl)) 552 self.assertTrue(re.search(r"Version 3.22.5", cl))
448 self.assertTrue(re.search(r" Log text 1", cl)) 553 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl))
449 self.assertTrue(re.search(r" \(issue 321\)", cl)) 554 self.assertFalse(re.search(r" \(author1@chromium\.org\)", cl))
555
556 # Make sure all comments got stripped.
557 self.assertFalse(re.search(r"^#", cl, flags=re.M))
558
450 version = FileToText(TEST_CONFIG[VERSION_FILE]) 559 version = FileToText(TEST_CONFIG[VERSION_FILE])
451 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version)) 560 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version))
452 561
562 def CheckUpload():
563 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
564
453 def CheckSVNCommit(): 565 def CheckSVNCommit():
454 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) 566 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE])
455 self.assertTrue(re.search(r"Version 3.22.5", commit)) 567 self.assertTrue(re.search(r"Version 3.22.5", commit))
456 self.assertTrue(re.search(r"Log text 1. \(issue 321\)", commit)) 568 self.assertTrue(re.search(r"Log text 1 \(issue 321\).", commit))
457 version = FileToText(TEST_CONFIG[VERSION_FILE]) 569 version = FileToText(TEST_CONFIG[VERSION_FILE])
458 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) 570 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
459 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) 571 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
460 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) 572 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version))
461 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) 573 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version))
462 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) 574 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
463 575
464 self._git_recipe = [ 576 force_flag = " -f" if force else ""
577 self.ExpectGit([
465 ["status -s -uno", ""], 578 ["status -s -uno", ""],
466 ["status -s -b -uno", "## some_branch\n"], 579 ["status -s -b -uno", "## some_branch\n"],
467 ["svn fetch", ""], 580 ["svn fetch", ""],
468 ["branch", " branch1\n* branch2\n"], 581 ["branch", " branch1\n* branch2\n"],
469 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], 582 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""],
470 ["branch", " branch1\n* branch2\n"], 583 ["branch", " branch1\n* branch2\n"],
471 ["branch", " branch1\n* branch2\n"], 584 ["branch", " branch1\n* branch2\n"],
472 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], 585 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""],
473 ["log -1 --format=%H ChangeLog", "1234\n"], 586 ["log -1 --format=%H ChangeLog", "1234\n"],
474 ["log -1 1234", "Last push ouput\n"], 587 ["log -1 1234", "Last push ouput\n"],
475 ["log 1234..HEAD --format=%H", "rev1\n"], 588 ["log 1234..HEAD --format=%H", "rev1\n"],
476 ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Log text 1.\n"], 589 ["log -1 rev1 --format=\"%s\"", "Log text 1.\n"],
477 ["log -1 rev1 --format=\"%B\"", "Text\nBUG=v8:321\nText\n"], 590 ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"],
478 ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", 591 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org\n"],
479 " author1@chromium.org\n"],
480 [("commit -a -m \"Prepare push to trunk. " 592 [("commit -a -m \"Prepare push to trunk. "
481 "Now working on version 3.22.6.\""), 593 "Now working on version 3.22.6.\""),
482 " 2 files changed\n", 594 " 2 files changed\n",
483 CheckPreparePush], 595 CheckPreparePush],
484 ["cl upload -r \"reviewer@chromium.org\" --send-mail", "done\n"], 596 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag,
597 "done\n"],
485 ["cl dcommit -f", "Closing issue\n"], 598 ["cl dcommit -f", "Closing issue\n"],
486 ["svn fetch", "fetch result\n"], 599 ["svn fetch", "fetch result\n"],
487 ["checkout svn/bleeding_edge", ""], 600 ["checkout svn/bleeding_edge", ""],
488 [("log -1 --format=%H --grep=\"Prepare push to trunk. " 601 [("log -1 --format=%H --grep=\"Prepare push to trunk. "
489 "Now working on version 3.22.6.\""), 602 "Now working on version 3.22.6.\""),
490 "hash1\n"], 603 "hash1\n"],
491 ["diff svn/trunk hash1", "patch content\n"], 604 ["diff svn/trunk hash1", "patch content\n"],
492 ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""], 605 ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""],
493 ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""], 606 ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""],
494 ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""], 607 ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""],
495 ["commit -F \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit], 608 ["commit -F \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit],
496 ["svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"], 609 ["svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"],
497 ["svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""], 610 ["svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""],
498 ["status -s -uno", ""], 611 ["status -s -uno", ""],
499 ["checkout master", ""], 612 ["checkout master", ""],
500 ["pull", ""], 613 ["pull", ""],
501 ["checkout -b v8-roll-123456", ""], 614 ["checkout -b v8-roll-123456", ""],
502 [("commit -am \"Update V8 to version 3.22.5.\n\n" 615 [("commit -am \"Update V8 to version 3.22.5.\n\n"
503 "TBR=reviewer@chromium.org\""), 616 "TBR=reviewer@chromium.org\""),
504 ""], 617 ""],
505 ["cl upload --send-mail", ""], 618 ["cl upload --send-mail%s" % force_flag, ""],
506 ["checkout -f some_branch", ""], 619 ["checkout -f some_branch", ""],
507 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], 620 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""],
508 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], 621 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""],
509 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], 622 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""],
510 ] 623 ])
511 self._rl_recipe = [ 624 self.ExpectReadline([
512 "Y", # Confirm last push. 625 "Y", # Confirm last push.
513 "", # Open editor. 626 "", # Open editor.
514 "Y", # Increment build number. 627 "Y", # Increment build number.
515 "reviewer@chromium.org", # V8 reviewer. 628 "reviewer@chromium.org", # V8 reviewer.
516 "LGTX", # Enter LGTM for V8 CL (wrong). 629 "LGTX", # Enter LGTM for V8 CL (wrong).
517 "LGTM", # Enter LGTM for V8 CL. 630 "LGTM", # Enter LGTM for V8 CL.
518 "Y", # Sanity check. 631 "Y", # Sanity check.
519 "reviewer@chromium.org", # Chromium reviewer. 632 "reviewer@chromium.org", # Chromium reviewer.
520 ] 633 ])
521 if force: 634 if force:
522 # TODO(machenbach): The lgtm for the prepare push is just temporary. 635 # TODO(machenbach): The lgtm for the prepare push is just temporary.
523 # There should be no user input in "force" mode. 636 # There should be no user input in "force" mode.
524 self._rl_recipe = [ 637 self.ExpectReadline([
525 "LGTM", # Enter LGTM for V8 CL. 638 "LGTM", # Enter LGTM for V8 CL.
526 ] 639 ])
527 640
528 class Options( object ): 641 class Options( object ):
529 pass 642 pass
530 643
531 options = Options() 644 options = Options()
532 options.s = 0 645 options.s = 0
533 options.l = None 646 options.l = None
534 options.f = force 647 options.f = force
535 options.r = "reviewer@chromium.org" if force else None 648 options.r = "reviewer@chromium.org" if force else None
536 options.c = TEST_CONFIG[CHROMIUM] 649 options.c = TEST_CONFIG[CHROMIUM]
537 RunPushToTrunk(TEST_CONFIG, options, self) 650 RunPushToTrunk(TEST_CONFIG, options, self)
538 651
539 deps = FileToText(TEST_CONFIG[DEPS_FILE]) 652 deps = FileToText(TEST_CONFIG[DEPS_FILE])
540 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) 653 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps))
541 654
542 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) 655 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
543 self.assertTrue(re.search(r"\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) 656 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl))
544 self.assertTrue(re.search(r" Log text 1", cl)) 657 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl))
545 self.assertTrue(re.search(r" \(issue 321\)", cl))
546 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) 658 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl))
547 659
548 # Note: The version file is on build number 5 again in the end of this test 660 # Note: The version file is on build number 5 again in the end of this test
549 # since the git command that merges to the bleeding edge branch is mocked 661 # since the git command that merges to the bleeding edge branch is mocked
550 # out. 662 # out.
551 663
552 def testPushToTrunk(self): 664 def testPushToTrunk(self):
553 self._PushToTrunk() 665 self._PushToTrunk()
554 666
555 def testPushToTrunkForced(self): 667 def testPushToTrunkForced(self):
556 self._PushToTrunk(force=True) 668 self._PushToTrunk(force=True)
669
670 def testAutoRoll(self):
671 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
672
673 # TODO(machenbach): Get rid of the editor check in automatic mode.
674 os.environ["EDITOR"] = "vi"
675
676 self.ExpectReadURL([
677 ["https://v8-status.appspot.com/lkgr", "100"],
678 ])
679
680 self.ExpectGit([
681 ["status -s -uno", ""],
682 ["status -s -b -uno", "## some_branch\n"],
683 ["svn fetch", ""],
684 ["svn log -1 --oneline", "r101 | Text"],
685 ])
686
687 # TODO(machenbach): Make a convenience wrapper for this.
688 class Options( object ):
689 pass
690
691 options = Options()
692 options.s = 0
693
694 auto_roll.RunAutoRoll(TEST_CONFIG, options, self)
695
696 self.assertEquals("100", self.MakeStep().Restore("lkgr"))
697 self.assertEquals("101", self.MakeStep().Restore("latest"))
698
699
700 class SystemTest(unittest.TestCase):
701 def testReload(self):
702 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={},
703 options=None,
704 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER)
705 body = step.Reload(
706 """------------------------------------------------------------------------
707 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines
708
709 Prepare push to trunk. Now working on version 3.23.11.
710
711 R=danno@chromium.org
712
713 Review URL: https://codereview.chromium.org/83173002
714
715 ------------------------------------------------------------------------""")
716 self.assertEquals(
717 """Prepare push to trunk. Now working on version 3.23.11.
718
719 R=danno@chromium.org
720
721 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body)
OLDNEW
« no previous file with comments | « tools/push-to-trunk/push_to_trunk.py ('k') | tools/run-tests.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698