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

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

Issue 196133017: Experimental parser: merge r19949 (Closed) Base URL: https://v8.googlecode.com/svn/branches/experimental/parser
Patch Set: Created 6 years, 9 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/script_test.py ('k') | tools/v8heapconst.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 14 matching lines...) Expand all
25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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 os 29 import os
30 import tempfile 30 import tempfile
31 import traceback 31 import traceback
32 import unittest 32 import unittest
33 33
34 import auto_roll 34 import auto_roll
35 from auto_roll import AutoRollOptions
36 from auto_roll import CheckLastPush 35 from auto_roll import CheckLastPush
37 from auto_roll import FetchLatestRevision 36 from auto_roll import FetchLatestRevision
38 from auto_roll import SETTINGS_LOCATION 37 from auto_roll import SETTINGS_LOCATION
39 import common_includes 38 import common_includes
40 from common_includes import * 39 from common_includes import *
41 import merge_to_branch 40 import merge_to_branch
42 from merge_to_branch import * 41 from merge_to_branch import *
43 import push_to_trunk 42 import push_to_trunk
44 from push_to_trunk import * 43 from push_to_trunk import *
45 44
46 45
47 TEST_CONFIG = { 46 TEST_CONFIG = {
48 BRANCHNAME: "test-prepare-push", 47 BRANCHNAME: "test-prepare-push",
49 TRUNKBRANCH: "test-trunk-push", 48 TRUNKBRANCH: "test-trunk-push",
50 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", 49 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile",
51 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", 50 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script",
52 DOT_GIT_LOCATION: None, 51 DOT_GIT_LOCATION: None,
53 VERSION_FILE: None, 52 VERSION_FILE: None,
54 CHANGELOG_FILE: None, 53 CHANGELOG_FILE: None,
55 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", 54 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry",
55 NEW_CHANGELOG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-new-changelog",
56 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", 56 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch",
57 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", 57 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg",
58 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", 58 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium",
59 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", 59 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS",
60 SETTINGS_LOCATION: None, 60 SETTINGS_LOCATION: None,
61 ALREADY_MERGING_SENTINEL_FILE: 61 ALREADY_MERGING_SENTINEL_FILE:
62 "/tmp/test-merge-to-branch-tempfile-already-merging", 62 "/tmp/test-merge-to-branch-tempfile-already-merging",
63 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", 63 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES",
64 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch", 64 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch",
65 } 65 }
66 66
67 67
68 AUTO_ROLL_ARGS = [ 68 AUTO_ROLL_ARGS = [
69 "-a", "author@chromium.org", 69 "-a", "author@chromium.org",
70 "-c", TEST_CONFIG[CHROMIUM], 70 "-c", TEST_CONFIG[CHROMIUM],
71 "-r", "reviewer@chromium.org", 71 "-r", "reviewer@chromium.org",
72 ] 72 ]
73 73
74 74
75 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None, a=None,
76 status_password=None, revert_bleeding_edge=None, p=None):
77 """Convenience wrapper."""
78 class Options(object):
79 pass
80 options = Options()
81 options.step = s
82 options.last_push = l
83 options.force = f
84 options.manual = m
85 options.reviewer = r
86 options.chromium = c
87 options.author = a
88 options.push = p
89 options.status_password = status_password
90 options.revert_bleeding_edge = revert_bleeding_edge
91 return options
92
93
94 class ToplevelTest(unittest.TestCase): 75 class ToplevelTest(unittest.TestCase):
95 def testMakeComment(self): 76 def testMakeComment(self):
96 self.assertEquals("# Line 1\n# Line 2\n#", 77 self.assertEquals("# Line 1\n# Line 2\n#",
97 MakeComment(" Line 1\n Line 2\n")) 78 MakeComment(" Line 1\n Line 2\n"))
98 self.assertEquals("#Line 1\n#Line 2", 79 self.assertEquals("#Line 1\n#Line 2",
99 MakeComment("Line 1\n Line 2")) 80 MakeComment("Line 1\n Line 2"))
100 81
101 def testStripComments(self): 82 def testStripComments(self):
102 self.assertEquals(" Line 1\n Line 3\n", 83 self.assertEquals(" Line 1\n Line 3\n",
103 StripComments(" Line 1\n# Line 2\n Line 3\n#\n")) 84 StripComments(" Line 1\n# Line 2\n Line 3\n#\n"))
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 # -----------------00--------10--------20--------30-------- 203 # -----------------00--------10--------20--------30--------
223 self.assertEquals("(Chromium issues 234, 1234567890" 204 self.assertEquals("(Chromium issues 234, 1234567890"
224 ", 12345678901234567, " 205 ", 12345678901234567, "
225 "1234567890123456789)", 206 "1234567890123456789)",
226 MakeChangeLogBugReference("BUG=234\n" 207 MakeChangeLogBugReference("BUG=234\n"
227 "BUG=12345678901234567\n" 208 "BUG=12345678901234567\n"
228 "BUG=1234567890123456789\n" 209 "BUG=1234567890123456789\n"
229 "BUG=1234567890\n")) 210 "BUG=1234567890\n"))
230 211
231 212
213 def Git(*args, **kwargs):
214 """Convenience function returning a git test expectation."""
215 return {
216 "name": "git",
217 "args": args[:-1],
218 "ret": args[-1],
219 "cb": kwargs.get("cb"),
220 }
221
222
223 def RL(text, cb=None):
224 """Convenience function returning a readline test expectation."""
225 return {"name": "readline", "args": [], "ret": text, "cb": cb}
226
227
228 def URL(*args, **kwargs):
229 """Convenience function returning a readurl test expectation."""
230 return {
231 "name": "readurl",
232 "args": args[:-1],
233 "ret": args[-1],
234 "cb": kwargs.get("cb"),
235 }
236
237
232 class SimpleMock(object): 238 class SimpleMock(object):
233 def __init__(self, name): 239 def __init__(self, name):
234 self._name = name 240 self._name = name
235 self._recipe = [] 241 self._recipe = []
236 self._index = -1 242 self._index = -1
237 243
238 def Expect(self, recipe): 244 def Expect(self, recipe):
239 self._recipe = recipe 245 self._recipe = recipe
240 246
241 def Call(self, *args): 247 def Call(self, name, *args): # pragma: no cover
242 self._index += 1 248 self._index += 1
243 try: 249 try:
244 expected_call = self._recipe[self._index] 250 expected_call = self._recipe[self._index]
245 except IndexError: 251 except IndexError:
246 raise NoRetryException("Calling %s %s" % (self._name, " ".join(args))) 252 raise NoRetryException("Calling %s %s" % (name, " ".join(args)))
247 253
248 # Pack expectations without arguments into a list. 254 if not isinstance(expected_call, dict):
249 if not isinstance(expected_call, list): 255 raise NoRetryException("Found wrong expectation type for %s %s"
250 expected_call = [expected_call] 256 % (name, " ".join(args)))
257
251 258
252 # The number of arguments in the expectation must match the actual 259 # The number of arguments in the expectation must match the actual
253 # arguments. 260 # arguments.
254 if len(args) > len(expected_call): 261 if len(args) > len(expected_call['args']):
255 raise NoRetryException("When calling %s with arguments, the " 262 raise NoRetryException("When calling %s with arguments, the "
256 "expectations must consist of at least as many arguments.") 263 "expectations must consist of at least as many arguments.")
257 264
258 # Compare expected and actual arguments. 265 # Compare expected and actual arguments.
259 for (expected_arg, actual_arg) in zip(expected_call, args): 266 for (expected_arg, actual_arg) in zip(expected_call['args'], args):
260 if expected_arg != actual_arg: 267 if expected_arg != actual_arg:
261 raise NoRetryException("Expected: %s - Actual: %s" 268 raise NoRetryException("Expected: %s - Actual: %s"
262 % (expected_arg, actual_arg)) 269 % (expected_arg, actual_arg))
263 270
264 # The expectation list contains a mandatory return value and an optional 271 # The expected call contains an optional callback for checking the context
265 # callback for checking the context at the time of the call. 272 # at the time of the call.
266 if len(expected_call) == len(args) + 2: 273 if expected_call['cb']:
267 try: 274 try:
268 expected_call[len(args) + 1]() 275 expected_call['cb']()
269 except: 276 except:
270 tb = traceback.format_exc() 277 tb = traceback.format_exc()
271 raise NoRetryException("Caught exception from callback: %s" % tb) 278 raise NoRetryException("Caught exception from callback: %s" % tb)
272 return_value = expected_call[len(args)]
273 279
274 # If the return value is an exception, raise it instead of returning. 280 # If the return value is an exception, raise it instead of returning.
275 if isinstance(return_value, Exception): 281 if isinstance(expected_call['ret'], Exception):
276 raise return_value 282 raise expected_call['ret']
277 return return_value 283 return expected_call['ret']
278 284
279 def AssertFinished(self): 285 def AssertFinished(self): # pragma: no cover
280 if self._index < len(self._recipe) -1: 286 if self._index < len(self._recipe) -1:
281 raise NoRetryException("Called %s too seldom: %d vs. %d" 287 raise NoRetryException("Called %s too seldom: %d vs. %d"
282 % (self._name, self._index, len(self._recipe))) 288 % (self._name, self._index, len(self._recipe)))
283 289
284 290
285 class ScriptTest(unittest.TestCase): 291 class ScriptTest(unittest.TestCase):
286 def MakeEmptyTempFile(self): 292 def MakeEmptyTempFile(self):
287 handle, name = tempfile.mkstemp() 293 handle, name = tempfile.mkstemp()
288 os.close(handle) 294 os.close(handle)
289 self._tmp_files.append(name) 295 self._tmp_files.append(name)
290 return name 296 return name
291 297
292 def MakeTempVersionFile(self): 298 def MakeTempVersionFile(self):
293 name = self.MakeEmptyTempFile() 299 name = self.MakeEmptyTempFile()
294 with open(name, "w") as f: 300 with open(name, "w") as f:
295 f.write(" // Some line...\n") 301 f.write(" // Some line...\n")
296 f.write("\n") 302 f.write("\n")
297 f.write("#define MAJOR_VERSION 3\n") 303 f.write("#define MAJOR_VERSION 3\n")
298 f.write("#define MINOR_VERSION 22\n") 304 f.write("#define MINOR_VERSION 22\n")
299 f.write("#define BUILD_NUMBER 5\n") 305 f.write("#define BUILD_NUMBER 5\n")
300 f.write("#define PATCH_LEVEL 0\n") 306 f.write("#define PATCH_LEVEL 0\n")
301 f.write(" // Some line...\n") 307 f.write(" // Some line...\n")
302 f.write("#define IS_CANDIDATE_VERSION 0\n") 308 f.write("#define IS_CANDIDATE_VERSION 0\n")
303 return name 309 return name
304 310
305 def MakeStep(self, step_class=Step, state=None, options=None): 311 def MakeStep(self):
306 """Convenience wrapper.""" 312 """Convenience wrapper."""
307 options = options or CommonOptions(MakeOptions()) 313 options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([])
308 state = state if state is not None else self._state 314 return MakeStep(step_class=Step, state=self._state,
309 return MakeStep(step_class=step_class, number=0, state=state, 315 config=TEST_CONFIG, side_effect_handler=self,
310 config=TEST_CONFIG, options=options, 316 options=options)
311 side_effect_handler=self) 317
318 def RunStep(self, script=PushToTrunk, step_class=Step, args=None):
319 """Convenience wrapper."""
320 args = args or ["-m"]
321 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args)
312 322
313 def GitMock(self, cmd, args="", pipe=True): 323 def GitMock(self, cmd, args="", pipe=True):
314 print "%s %s" % (cmd, args) 324 print "%s %s" % (cmd, args)
315 return self._git_mock.Call(args) 325 return self._git_mock.Call("git", args)
316 326
317 def LogMock(self, cmd, args=""): 327 def LogMock(self, cmd, args=""):
318 print "Log: %s %s" % (cmd, args) 328 print "Log: %s %s" % (cmd, args)
319 329
320 MOCKS = { 330 MOCKS = {
321 "git": GitMock, 331 "git": GitMock,
322 # TODO(machenbach): Little hack to reuse the git mock for the one svn call 332 # TODO(machenbach): Little hack to reuse the git mock for the one svn call
323 # in merge-to-branch. The command should be made explicit in the test 333 # in merge-to-branch. The command should be made explicit in the test
324 # expectations. 334 # expectations.
325 "svn": GitMock, 335 "svn": GitMock,
326 "vi": LogMock, 336 "vi": LogMock,
327 } 337 }
328 338
329 def Call(self, fun, *args, **kwargs): 339 def Call(self, fun, *args, **kwargs):
330 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs)) 340 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs))
331 341
332 def Command(self, cmd, args="", prefix="", pipe=True): 342 def Command(self, cmd, args="", prefix="", pipe=True):
333 return ScriptTest.MOCKS[cmd](self, cmd, args) 343 return ScriptTest.MOCKS[cmd](self, cmd, args)
334 344
335 def ReadLine(self): 345 def ReadLine(self):
336 return self._rl_mock.Call() 346 return self._rl_mock.Call("readline")
337 347
338 def ReadURL(self, url, params): 348 def ReadURL(self, url, params):
339 if params is not None: 349 if params is not None:
340 return self._url_mock.Call(url, params) 350 return self._url_mock.Call("readurl", url, params)
341 else: 351 else:
342 return self._url_mock.Call(url) 352 return self._url_mock.Call("readurl", url)
343 353
344 def Sleep(self, seconds): 354 def Sleep(self, seconds):
345 pass 355 pass
346 356
347 def GetDate(self): 357 def GetDate(self):
348 return "1999-07-31" 358 return "1999-07-31"
349 359
350 def ExpectGit(self, *args): 360 def ExpectGit(self, *args):
351 """Convenience wrapper.""" 361 """Convenience wrapper."""
352 self._git_mock.Expect(*args) 362 self._git_mock.Expect(*args)
(...skipping 22 matching lines...) Expand all
375 os.remove(name) 385 os.remove(name)
376 386
377 self._git_mock.AssertFinished() 387 self._git_mock.AssertFinished()
378 self._rl_mock.AssertFinished() 388 self._rl_mock.AssertFinished()
379 self._url_mock.AssertFinished() 389 self._url_mock.AssertFinished()
380 390
381 def testGitOrig(self): 391 def testGitOrig(self):
382 self.assertTrue(Command("git", "--version").startswith("git version")) 392 self.assertTrue(Command("git", "--version").startswith("git version"))
383 393
384 def testGitMock(self): 394 def testGitMock(self):
385 self.ExpectGit([["--version", "git version 1.2.3"], ["dummy", ""]]) 395 self.ExpectGit([Git("--version", "git version 1.2.3"), Git("dummy", "")])
386 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) 396 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version"))
387 self.assertEquals("", self.MakeStep().Git("dummy")) 397 self.assertEquals("", self.MakeStep().Git("dummy"))
388 398
389 def testCommonPrepareDefault(self): 399 def testCommonPrepareDefault(self):
390 self.ExpectGit([ 400 self.ExpectGit([
391 ["status -s -uno", ""], 401 Git("status -s -uno", ""),
392 ["status -s -b -uno", "## some_branch"], 402 Git("status -s -b -uno", "## some_branch"),
393 ["svn fetch", ""], 403 Git("svn fetch", ""),
394 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 404 Git("branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]),
395 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], 405 Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""),
396 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], 406 Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""),
397 ["branch", ""], 407 Git("branch", ""),
398 ]) 408 ])
399 self.ExpectReadline(["Y"]) 409 self.ExpectReadline([RL("Y")])
400 self.MakeStep().CommonPrepare() 410 self.MakeStep().CommonPrepare()
401 self.MakeStep().PrepareBranch() 411 self.MakeStep().PrepareBranch()
402 self.assertEquals("some_branch", self._state["current_branch"]) 412 self.assertEquals("some_branch", self._state["current_branch"])
403 413
404 def testCommonPrepareNoConfirm(self): 414 def testCommonPrepareNoConfirm(self):
405 self.ExpectGit([ 415 self.ExpectGit([
406 ["status -s -uno", ""], 416 Git("status -s -uno", ""),
407 ["status -s -b -uno", "## some_branch"], 417 Git("status -s -b -uno", "## some_branch"),
408 ["svn fetch", ""], 418 Git("svn fetch", ""),
409 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 419 Git("branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]),
410 ]) 420 ])
411 self.ExpectReadline(["n"]) 421 self.ExpectReadline([RL("n")])
412 self.MakeStep().CommonPrepare() 422 self.MakeStep().CommonPrepare()
413 self.assertRaises(Exception, self.MakeStep().PrepareBranch) 423 self.assertRaises(Exception, self.MakeStep().PrepareBranch)
414 self.assertEquals("some_branch", self._state["current_branch"]) 424 self.assertEquals("some_branch", self._state["current_branch"])
415 425
416 def testCommonPrepareDeleteBranchFailure(self): 426 def testCommonPrepareDeleteBranchFailure(self):
417 self.ExpectGit([ 427 self.ExpectGit([
418 ["status -s -uno", ""], 428 Git("status -s -uno", ""),
419 ["status -s -b -uno", "## some_branch"], 429 Git("status -s -b -uno", "## some_branch"),
420 ["svn fetch", ""], 430 Git("svn fetch", ""),
421 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 431 Git("branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]),
422 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None], 432 Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None),
423 ]) 433 ])
424 self.ExpectReadline(["Y"]) 434 self.ExpectReadline([RL("Y")])
425 self.MakeStep().CommonPrepare() 435 self.MakeStep().CommonPrepare()
426 self.assertRaises(Exception, self.MakeStep().PrepareBranch) 436 self.assertRaises(Exception, self.MakeStep().PrepareBranch)
427 self.assertEquals("some_branch", self._state["current_branch"]) 437 self.assertEquals("some_branch", self._state["current_branch"])
428 438
429 def testInitialEnvironmentChecks(self): 439 def testInitialEnvironmentChecks(self):
430 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 440 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
431 os.environ["EDITOR"] = "vi" 441 os.environ["EDITOR"] = "vi"
432 self.MakeStep().InitialEnvironmentChecks() 442 self.MakeStep().InitialEnvironmentChecks()
433 443
434 def testReadAndPersistVersion(self): 444 def testReadAndPersistVersion(self):
(...skipping 24 matching lines...) Expand all
459 self.assertEqual("//\n#define BUILD_NUMBER 3\n", 469 self.assertEqual("//\n#define BUILD_NUMBER 3\n",
460 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", 470 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
461 r"\g<space>3", 471 r"\g<space>3",
462 "//\n#define BUILD_NUMBER 321\n")) 472 "//\n#define BUILD_NUMBER 321\n"))
463 473
464 def testPrepareChangeLog(self): 474 def testPrepareChangeLog(self):
465 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 475 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
466 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 476 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
467 477
468 self.ExpectGit([ 478 self.ExpectGit([
469 ["log --format=%H 1234..HEAD", "rev1\nrev2\nrev3\nrev4"], 479 Git("log --format=%H 1234..HEAD", "rev1\nrev2\nrev3\nrev4"),
470 ["log -1 --format=%s rev1", "Title text 1"], 480 Git("log -1 --format=%s rev1", "Title text 1"),
471 ["log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"], 481 Git("log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"),
472 ["log -1 --format=%an rev1", "author1@chromium.org"], 482 Git("log -1 --format=%an rev1", "author1@chromium.org"),
473 ["log -1 --format=%s rev2", "Title text 2."], 483 Git("log -1 --format=%s rev2", "Title text 2."),
474 ["log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"], 484 Git("log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"),
475 ["log -1 --format=%an rev2", "author2@chromium.org"], 485 Git("log -1 --format=%an rev2", "author2@chromium.org"),
476 ["log -1 --format=%s rev3", "Title text 3"], 486 Git("log -1 --format=%s rev3", "Title text 3"),
477 ["log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"], 487 Git("log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"),
478 ["log -1 --format=%an rev3", "author3@chromium.org"], 488 Git("log -1 --format=%an rev3", "author3@chromium.org"),
479 ["log -1 --format=%s rev4", "Title text 4"], 489 Git("log -1 --format=%s rev4", "Title text 4"),
480 ["log -1 --format=%B rev4", 490 Git("log -1 --format=%B rev4",
481 ("Title\n\nBUG=456\nLOG=Y\n\n" 491 ("Title\n\nBUG=456\nLOG=Y\n\n"
482 "Review URL: https://codereview.chromium.org/9876543210\n")], 492 "Review URL: https://codereview.chromium.org/9876543210\n")),
483 ["log -1 --format=%an rev4", "author4@chromium.org"], 493 Git("log -1 --format=%an rev4", "author4@chromium.org"),
484 ]) 494 ])
485 495
486 # The cl for rev4 on rietveld has an updated LOG flag. 496 # The cl for rev4 on rietveld has an updated LOG flag.
487 self.ExpectReadURL([ 497 self.ExpectReadURL([
488 ["https://codereview.chromium.org/9876543210/description", 498 URL("https://codereview.chromium.org/9876543210/description",
489 "Title\n\nBUG=456\nLOG=N\n\n"], 499 "Title\n\nBUG=456\nLOG=N\n\n"),
490 ]) 500 ])
491 501
492 self._state["last_push_bleeding_edge"] = "1234" 502 self._state["last_push_bleeding_edge"] = "1234"
493 self.MakeStep(PrepareChangeLog).Run() 503 self.RunStep(PushToTrunk, PrepareChangeLog)
494 504
495 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 505 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
496 506
497 expected_cl = """1999-07-31: Version 3.22.5 507 expected_cl = """1999-07-31: Version 3.22.5
498 508
499 Title text 1. 509 Title text 1.
500 510
501 Title text 3 (Chromium issue 321). 511 Title text 3 (Chromium issue 321).
502 512
503 Performance and stability improvements on all platforms. 513 Performance and stability improvements on all platforms.
(...skipping 23 matching lines...) Expand all
527 self.assertEquals("0", self._state["patch"]) 537 self.assertEquals("0", self._state["patch"])
528 538
529 def testEditChangeLog(self): 539 def testEditChangeLog(self):
530 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 540 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
531 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 541 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
532 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) 542 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE])
533 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 543 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE])
534 os.environ["EDITOR"] = "vi" 544 os.environ["EDITOR"] = "vi"
535 545
536 self.ExpectReadline([ 546 self.ExpectReadline([
537 "", # Open editor. 547 RL(""), # Open editor.
538 ]) 548 ])
539 549
540 self.MakeStep(EditChangeLog).Run() 550 self.RunStep(PushToTrunk, EditChangeLog)
541 551
542 self.assertEquals("New\n Lines\n\n\n Original CL", 552 self.assertEquals("New\n Lines\n\n\n Original CL",
543 FileToText(TEST_CONFIG[CHANGELOG_FILE])) 553 FileToText(TEST_CONFIG[CHANGELOG_FILE]))
544 554
545 def testIncrementVersion(self): 555 def testIncrementVersion(self):
546 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 556 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
547 self._state["build"] = "5" 557 self._state["build"] = "5"
548 558
549 self.ExpectReadline([ 559 self.ExpectReadline([
550 "Y", # Increment build number. 560 RL("Y"), # Increment build number.
551 ]) 561 ])
552 562
553 self.MakeStep(IncrementVersion).Run() 563 self.RunStep(PushToTrunk, IncrementVersion)
554 564
555 self.assertEquals("3", self._state["new_major"]) 565 self.assertEquals("3", self._state["new_major"])
556 self.assertEquals("22", self._state["new_minor"]) 566 self.assertEquals("22", self._state["new_minor"])
557 self.assertEquals("6", self._state["new_build"]) 567 self.assertEquals("6", self._state["new_build"])
558 self.assertEquals("0", self._state["new_patch"]) 568 self.assertEquals("0", self._state["new_patch"])
559 569
560 def testLastChangeLogEntries(self): 570 def testLastChangeLogEntries(self):
561 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 571 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
562 l = """ 572 l = """
563 Fixed something. 573 Fixed something.
564 (issue 1234)\n""" 574 (issue 1234)\n"""
565 for _ in xrange(10): l = l + l 575 for _ in xrange(10): l = l + l
566 576
567 cl_chunk = """2013-11-12: Version 3.23.2\n%s 577 cl_chunk = """2013-11-12: Version 3.23.2\n%s
568 Performance and stability improvements on all platforms.\n\n\n""" % l 578 Performance and stability improvements on all platforms.\n\n\n""" % l
569 579
570 cl_chunk_full = cl_chunk + cl_chunk + cl_chunk 580 cl_chunk_full = cl_chunk + cl_chunk + cl_chunk
571 TextToFile(cl_chunk_full, TEST_CONFIG[CHANGELOG_FILE]) 581 TextToFile(cl_chunk_full, TEST_CONFIG[CHANGELOG_FILE])
572 582
573 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE]) 583 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE])
574 self.assertEquals(cl_chunk, cl) 584 self.assertEquals(cl_chunk, cl)
575 585
576 def _TestSquashCommits(self, change_log, expected_msg): 586 def _TestSquashCommits(self, change_log, expected_msg):
577 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 587 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
578 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: 588 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f:
579 f.write(change_log) 589 f.write(change_log)
580 590
581 self.ExpectGit([ 591 self.ExpectGit([
582 ["diff svn/trunk hash1", "patch content"], 592 Git("diff svn/trunk hash1", "patch content"),
583 ["svn find-rev hash1", "123455\n"], 593 Git("svn find-rev hash1", "123455\n"),
584 ]) 594 ])
585 595
586 self._state["prepare_commit_hash"] = "hash1" 596 self._state["prepare_commit_hash"] = "hash1"
587 self._state["date"] = "1999-11-11" 597 self._state["date"] = "1999-11-11"
588 598
589 self.MakeStep(SquashCommits).Run() 599 self.RunStep(PushToTrunk, SquashCommits)
590 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg) 600 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg)
591 601
592 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) 602 patch = FileToText(TEST_CONFIG[ PATCH_FILE])
593 self.assertTrue(re.search(r"patch content", patch)) 603 self.assertTrue(re.search(r"patch content", patch))
594 604
595 def testSquashCommitsUnformatted(self): 605 def testSquashCommitsUnformatted(self):
596 change_log = """1999-11-11: Version 3.22.5 606 change_log = """1999-11-11: Version 3.22.5
597 607
598 Log text 1. 608 Log text 1.
599 Chromium issue 12345 609 Chromium issue 12345
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
660 version = FileToText(TEST_CONFIG[VERSION_FILE]) 670 version = FileToText(TEST_CONFIG[VERSION_FILE])
661 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) 671 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
662 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) 672 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
663 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) 673 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version))
664 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) 674 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version))
665 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) 675 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
666 676
667 force_flag = " -f" if not manual else "" 677 force_flag = " -f" if not manual else ""
668 review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else "" 678 review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else ""
669 self.ExpectGit([ 679 self.ExpectGit([
670 ["status -s -uno", ""], 680 Git("status -s -uno", ""),
671 ["status -s -b -uno", "## some_branch\n"], 681 Git("status -s -b -uno", "## some_branch\n"),
672 ["svn fetch", ""], 682 Git("svn fetch", ""),
673 ["branch", " branch1\n* branch2\n"], 683 Git("branch", " branch1\n* branch2\n"),
674 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], 684 Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""),
675 ["branch", " branch1\n* branch2\n"], 685 Git("branch", " branch1\n* branch2\n"),
676 ["branch", " branch1\n* branch2\n"], 686 Git("branch", " branch1\n* branch2\n"),
677 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], 687 Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""),
678 [("log -1 --format=%H --grep=" 688 Git(("log -1 --format=%H --grep="
679 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " 689 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
680 "svn/trunk"), "hash2\n"], 690 "svn/trunk"), "hash2\n"),
681 ["log -1 hash2", "Log message\n"], 691 Git("log -1 hash2", "Log message\n"),
682 ["log -1 --format=%s hash2", 692 Git("log -1 --format=%s hash2",
683 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"], 693 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"),
684 ["svn find-rev r1234", "hash3\n"], 694 Git("svn find-rev r1234", "hash3\n"),
685 ["log --format=%H hash3..HEAD", "rev1\n"], 695 Git("log --format=%H hash3..HEAD", "rev1\n"),
686 ["log -1 --format=%s rev1", "Log text 1.\n"], 696 Git("log -1 --format=%s rev1", "Log text 1.\n"),
687 ["log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"], 697 Git("log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
688 ["log -1 --format=%an rev1", "author1@chromium.org\n"], 698 Git("log -1 --format=%an rev1", "author1@chromium.org\n"),
689 [("commit -am \"Prepare push to trunk. " 699 Git(("commit -am \"Prepare push to trunk. "
690 "Now working on version 3.22.6.%s\"" % review_suffix), 700 "Now working on version 3.22.6.%s\"" % review_suffix),
691 " 2 files changed\n", 701 " 2 files changed\n",
692 CheckPreparePush], 702 cb=CheckPreparePush),
693 [("cl upload --send-mail --email \"author@chromium.org\" " 703 Git(("cl upload --send-mail --email \"author@chromium.org\" "
694 "-r \"reviewer@chromium.org\"%s" % force_flag), 704 "-r \"reviewer@chromium.org\"%s" % force_flag),
695 "done\n"], 705 "done\n"),
696 ["cl presubmit", "Presubmit successfull\n"], 706 Git("cl presubmit", "Presubmit successfull\n"),
697 ["cl dcommit -f --bypass-hooks", "Closing issue\n"], 707 Git("cl dcommit -f --bypass-hooks", "Closing issue\n"),
698 ["svn fetch", "fetch result\n"], 708 Git("svn fetch", "fetch result\n"),
699 ["checkout -f svn/bleeding_edge", ""], 709 Git("checkout -f svn/bleeding_edge", ""),
700 [("log -1 --format=%H --grep=\"Prepare push to trunk. " 710 Git(("log -1 --format=%H --grep=\"Prepare push to trunk. "
701 "Now working on version 3.22.6.\""), 711 "Now working on version 3.22.6.\""),
702 "hash1\n"], 712 "hash1\n"),
703 ["diff svn/trunk hash1", "patch content\n"], 713 Git("diff svn/trunk hash1", "patch content\n"),
704 ["svn find-rev hash1", "123455\n"], 714 Git("svn find-rev hash1", "123455\n"),
705 ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""], 715 Git("checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""),
706 ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""], 716 Git("apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""),
707 ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""], 717 Git("add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""),
708 ["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit], 718 Git("commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "",
709 ["svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"], 719 cb=CheckSVNCommit),
710 ["svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""], 720 Git("svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"),
711 ["status -s -uno", ""], 721 Git("svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""),
712 ["checkout -f master", ""], 722 Git("status -s -uno", ""),
713 ["pull", ""], 723 Git("checkout -f master", ""),
714 ["checkout -b v8-roll-123456", ""], 724 Git("pull", ""),
715 [("commit -am \"Update V8 to version 3.22.5 " 725 Git("checkout -b v8-roll-123456", ""),
716 "(based on bleeding_edge revision r123455).\n\n" 726 Git(("commit -am \"Update V8 to version 3.22.5 "
717 "TBR=reviewer@chromium.org\""), 727 "(based on bleeding_edge revision r123455).\n\n"
718 ""], 728 "TBR=reviewer@chromium.org\""),
719 ["cl upload --send-mail --email \"author@chromium.org\"%s" % force_flag, 729 ""),
720 ""], 730 Git(("cl upload --send-mail --email \"author@chromium.org\"%s"
721 ["checkout -f some_branch", ""], 731 % force_flag), ""),
722 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], 732 Git("checkout -f some_branch", ""),
723 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], 733 Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""),
724 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], 734 Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""),
735 Git("branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""),
725 ]) 736 ])
726 737
727 # Expected keyboard input in manual mode: 738 # Expected keyboard input in manual mode:
728 if manual: 739 if manual:
729 self.ExpectReadline([ 740 self.ExpectReadline([
730 "Y", # Confirm last push. 741 RL("Y"), # Confirm last push.
731 "", # Open editor. 742 RL(""), # Open editor.
732 "Y", # Increment build number. 743 RL("Y"), # Increment build number.
733 "reviewer@chromium.org", # V8 reviewer. 744 RL("reviewer@chromium.org"), # V8 reviewer.
734 "LGTX", # Enter LGTM for V8 CL (wrong). 745 RL("LGTX"), # Enter LGTM for V8 CL (wrong).
735 "LGTM", # Enter LGTM for V8 CL. 746 RL("LGTM"), # Enter LGTM for V8 CL.
736 "Y", # Sanity check. 747 RL("Y"), # Sanity check.
737 "reviewer@chromium.org", # Chromium reviewer. 748 RL("reviewer@chromium.org"), # Chromium reviewer.
738 ]) 749 ])
739 750
740 # Expected keyboard input in semi-automatic mode: 751 # Expected keyboard input in semi-automatic mode:
741 if not manual and not force: 752 if not manual and not force:
742 self.ExpectReadline([ 753 self.ExpectReadline([
743 "LGTM", # Enter LGTM for V8 CL. 754 RL("LGTM"), # Enter LGTM for V8 CL.
744 ]) 755 ])
745 756
746 # No keyboard input in forced mode: 757 # No keyboard input in forced mode:
747 if force: 758 if force:
748 self.ExpectReadline([]) 759 self.ExpectReadline([])
749 760
750 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM]] 761 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM]]
751 if force: args.append("-f") 762 if force: args.append("-f")
752 if manual: args.append("-m") 763 if manual: args.append("-m")
753 else: args += ["-r", "reviewer@chromium.org"] 764 else: args += ["-r", "reviewer@chromium.org"]
754 options = push_to_trunk.BuildOptions().parse_args(args) 765 PushToTrunk(TEST_CONFIG, self).Run(args)
755 RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self)
756 766
757 deps = FileToText(TEST_CONFIG[DEPS_FILE]) 767 deps = FileToText(TEST_CONFIG[DEPS_FILE])
758 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) 768 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps))
759 769
760 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) 770 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
761 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) 771 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl))
762 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) 772 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl))
763 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) 773 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl))
764 774
765 # Note: The version file is on build number 5 again in the end of this test 775 # Note: The version file is on build number 5 again in the end of this test
766 # since the git command that merges to the bleeding edge branch is mocked 776 # since the git command that merges to the bleeding edge branch is mocked
767 # out. 777 # out.
768 778
769 def testPushToTrunkManual(self): 779 def testPushToTrunkManual(self):
770 self._PushToTrunk(manual=True) 780 self._PushToTrunk(manual=True)
771 781
772 def testPushToTrunkSemiAutomatic(self): 782 def testPushToTrunkSemiAutomatic(self):
773 self._PushToTrunk() 783 self._PushToTrunk()
774 784
775 def testPushToTrunkForced(self): 785 def testPushToTrunkForced(self):
776 self._PushToTrunk(force=True) 786 self._PushToTrunk(force=True)
777 787
778 def testCheckLastPushRecently(self): 788 def testCheckLastPushRecently(self):
779 self.ExpectGit([ 789 self.ExpectGit([
780 ["svn log -1 --oneline", "r101 | Text"], 790 Git("svn log -1 --oneline", "r101 | Text"),
781 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], 791 Git("svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."),
782 ]) 792 ])
783 793
784 state = {} 794 self.RunStep(auto_roll.AutoRoll, FetchLatestRevision, AUTO_ROLL_ARGS)
785 self.MakeStep(FetchLatestRevision, state=state).Run() 795 self.assertRaises(Exception, lambda: self.RunStep(auto_roll.AutoRoll,
786 self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run) 796 CheckLastPush,
797 AUTO_ROLL_ARGS))
787 798
788 def testAutoRoll(self): 799 def testAutoRoll(self):
789 password = self.MakeEmptyTempFile() 800 password = self.MakeEmptyTempFile()
790 TextToFile("PW", password) 801 TextToFile("PW", password)
791 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 802 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
792 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" 803 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist"
793 804
794 self.ExpectReadURL([ 805 self.ExpectReadURL([
795 ["https://v8-status.appspot.com/current?format=json", 806 URL("https://v8-status.appspot.com/current?format=json",
796 "{\"message\": \"Tree is throttled\"}"], 807 "{\"message\": \"Tree is throttled\"}"),
797 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], 808 URL("https://v8-status.appspot.com/lkgr", Exception("Network problem")),
798 ["https://v8-status.appspot.com/lkgr", "100"], 809 URL("https://v8-status.appspot.com/lkgr", "100"),
799 ["https://v8-status.appspot.com/status", 810 URL("https://v8-status.appspot.com/status",
800 ("username=v8-auto-roll%40chromium.org&" 811 ("username=v8-auto-roll%40chromium.org&"
801 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), 812 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), ""),
802 ""], 813 URL("https://v8-status.appspot.com/status",
803 ["https://v8-status.appspot.com/status", 814 ("username=v8-auto-roll%40chromium.org&"
804 ("username=v8-auto-roll%40chromium.org&" 815 "message=Tree+is+throttled&password=PW"), ""),
805 "message=Tree+is+throttled&password=PW"), ""],
806 ]) 816 ])
807 817
808 self.ExpectGit([ 818 self.ExpectGit([
809 ["status -s -uno", ""], 819 Git("status -s -uno", ""),
810 ["status -s -b -uno", "## some_branch\n"], 820 Git("status -s -b -uno", "## some_branch\n"),
811 ["svn fetch", ""], 821 Git("svn fetch", ""),
812 ["svn log -1 --oneline", "r100 | Text"], 822 Git("svn log -1 --oneline", "r100 | Text"),
813 [("log -1 --format=%H --grep=\"" 823 Git(("log -1 --format=%H --grep=\""
814 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" 824 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\""
815 " svn/trunk"), "push_hash\n"], 825 " svn/trunk"), "push_hash\n"),
816 ["svn find-rev push_hash", "65"], 826 Git("svn find-rev push_hash", "65"),
817 ]) 827 ])
818 828
819 options = auto_roll.BuildOptions().parse_args( 829 auto_roll.AutoRoll(TEST_CONFIG, self).Run(
820 AUTO_ROLL_ARGS + ["--status-password", password]) 830 AUTO_ROLL_ARGS + ["--status-password", password, "--push"])
821 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(options), self)
822 831
823 state = json.loads(FileToText("%s-state.json" 832 state = json.loads(FileToText("%s-state.json"
824 % TEST_CONFIG[PERSISTFILE_BASENAME])) 833 % TEST_CONFIG[PERSISTFILE_BASENAME]))
825 834
826 self.assertEquals("100", state["lkgr"]) 835 self.assertEquals("100", state["lkgr"])
827 self.assertEquals("100", state["latest"]) 836 self.assertEquals("100", state["latest"])
828 837
829 def testAutoRollStoppedBySettings(self): 838 def testAutoRollStoppedBySettings(self):
830 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 839 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
831 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() 840 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile()
832 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) 841 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION])
833 842
834 self.ExpectReadURL([]) 843 self.ExpectReadURL([])
835 844
836 self.ExpectGit([ 845 self.ExpectGit([
837 ["status -s -uno", ""], 846 Git("status -s -uno", ""),
838 ["status -s -b -uno", "## some_branch\n"], 847 Git("status -s -b -uno", "## some_branch\n"),
839 ["svn fetch", ""], 848 Git("svn fetch", ""),
840 ]) 849 ])
841 850
842 options = auto_roll.BuildOptions().parse_args(AUTO_ROLL_ARGS)
843 def RunAutoRoll(): 851 def RunAutoRoll():
844 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(options), self) 852 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS)
845 self.assertRaises(Exception, RunAutoRoll) 853 self.assertRaises(Exception, RunAutoRoll)
846 854
847 def testAutoRollStoppedByTreeStatus(self): 855 def testAutoRollStoppedByTreeStatus(self):
848 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 856 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
849 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" 857 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist"
850 858
851 self.ExpectReadURL([ 859 self.ExpectReadURL([
852 ["https://v8-status.appspot.com/current?format=json", 860 URL("https://v8-status.appspot.com/current?format=json",
853 "{\"message\": \"Tree is throttled (no push)\"}"], 861 "{\"message\": \"Tree is throttled (no push)\"}"),
854 ]) 862 ])
855 863
856 self.ExpectGit([ 864 self.ExpectGit([
857 ["status -s -uno", ""], 865 Git("status -s -uno", ""),
858 ["status -s -b -uno", "## some_branch\n"], 866 Git("status -s -b -uno", "## some_branch\n"),
859 ["svn fetch", ""], 867 Git("svn fetch", ""),
860 ]) 868 ])
861 869
862 options = auto_roll.BuildOptions().parse_args(AUTO_ROLL_ARGS)
863 def RunAutoRoll(): 870 def RunAutoRoll():
864 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(options), self) 871 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS)
865 self.assertRaises(Exception, RunAutoRoll) 872 self.assertRaises(Exception, RunAutoRoll)
866 873
867 def testMergeToBranch(self): 874 def testMergeToBranch(self):
868 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() 875 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile()
869 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 876 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
870 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 877 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
871 os.environ["EDITOR"] = "vi" 878 os.environ["EDITOR"] = "vi"
872 extra_patch = self.MakeEmptyTempFile() 879 extra_patch = self.MakeEmptyTempFile()
873 880
874 def VerifyPatch(patch): 881 def VerifyPatch(patch):
(...skipping 19 matching lines...) Expand all
894 def VerifySVNCommit(): 901 def VerifySVNCommit():
895 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) 902 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE])
896 self.assertEquals(msg, commit) 903 self.assertEquals(msg, commit)
897 version = FileToText(TEST_CONFIG[VERSION_FILE]) 904 version = FileToText(TEST_CONFIG[VERSION_FILE])
898 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) 905 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
899 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) 906 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
900 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version)) 907 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version))
901 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) 908 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
902 909
903 self.ExpectGit([ 910 self.ExpectGit([
904 ["status -s -uno", ""], 911 Git("status -s -uno", ""),
905 ["status -s -b -uno", "## some_branch\n"], 912 Git("status -s -b -uno", "## some_branch\n"),
906 ["svn fetch", ""], 913 Git("svn fetch", ""),
907 ["branch", " branch1\n* branch2\n"], 914 Git("branch", " branch1\n* branch2\n"),
908 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], 915 Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""),
909 ["branch", " branch1\n* branch2\n"], 916 Git("branch", " branch1\n* branch2\n"),
910 ["checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""], 917 Git("checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""),
911 ["log --format=%H --grep=\"Port r12345\" --reverse svn/bleeding_edge", 918 Git("log --format=%H --grep=\"Port r12345\" --reverse svn/bleeding_edge",
912 "hash1\nhash2"], 919 "hash1\nhash2"),
913 ["svn find-rev hash1 svn/bleeding_edge", "45678"], 920 Git("svn find-rev hash1 svn/bleeding_edge", "45678"),
914 ["log -1 --format=%s hash1", "Title1"], 921 Git("log -1 --format=%s hash1", "Title1"),
915 ["svn find-rev hash2 svn/bleeding_edge", "23456"], 922 Git("svn find-rev hash2 svn/bleeding_edge", "23456"),
916 ["log -1 --format=%s hash2", "Title2"], 923 Git("log -1 --format=%s hash2", "Title2"),
917 ["log --format=%H --grep=\"Port r23456\" --reverse svn/bleeding_edge", 924 Git("log --format=%H --grep=\"Port r23456\" --reverse svn/bleeding_edge",
918 ""], 925 ""),
919 ["log --format=%H --grep=\"Port r34567\" --reverse svn/bleeding_edge", 926 Git("log --format=%H --grep=\"Port r34567\" --reverse svn/bleeding_edge",
920 "hash3"], 927 "hash3"),
921 ["svn find-rev hash3 svn/bleeding_edge", "56789"], 928 Git("svn find-rev hash3 svn/bleeding_edge", "56789"),
922 ["log -1 --format=%s hash3", "Title3"], 929 Git("log -1 --format=%s hash3", "Title3"),
923 ["svn find-rev r12345 svn/bleeding_edge", "hash4"], 930 Git("svn find-rev r12345 svn/bleeding_edge", "hash4"),
924 # Simulate svn being down which stops the script. 931 # Simulate svn being down which stops the script.
925 ["svn find-rev r23456 svn/bleeding_edge", None], 932 Git("svn find-rev r23456 svn/bleeding_edge", None),
926 # Restart script in the failing step. 933 # Restart script in the failing step.
927 ["svn find-rev r12345 svn/bleeding_edge", "hash4"], 934 Git("svn find-rev r12345 svn/bleeding_edge", "hash4"),
928 ["svn find-rev r23456 svn/bleeding_edge", "hash2"], 935 Git("svn find-rev r23456 svn/bleeding_edge", "hash2"),
929 ["svn find-rev r34567 svn/bleeding_edge", "hash3"], 936 Git("svn find-rev r34567 svn/bleeding_edge", "hash3"),
930 ["svn find-rev r45678 svn/bleeding_edge", "hash1"], 937 Git("svn find-rev r45678 svn/bleeding_edge", "hash1"),
931 ["svn find-rev r56789 svn/bleeding_edge", "hash5"], 938 Git("svn find-rev r56789 svn/bleeding_edge", "hash5"),
932 ["log -1 --format=%s hash4", "Title4"], 939 Git("log -1 --format=%s hash4", "Title4"),
933 ["log -1 --format=%s hash2", "Title2"], 940 Git("log -1 --format=%s hash2", "Title2"),
934 ["log -1 --format=%s hash3", "Title3"], 941 Git("log -1 --format=%s hash3", "Title3"),
935 ["log -1 --format=%s hash1", "Title1"], 942 Git("log -1 --format=%s hash1", "Title1"),
936 ["log -1 --format=%s hash5", "Title5"], 943 Git("log -1 --format=%s hash5", "Title5"),
937 ["log -1 hash4", "Title4\nBUG=123\nBUG=234"], 944 Git("log -1 hash4", "Title4\nBUG=123\nBUG=234"),
938 ["log -1 hash2", "Title2\n BUG = v8:123,345"], 945 Git("log -1 hash2", "Title2\n BUG = v8:123,345"),
939 ["log -1 hash3", "Title3\nLOG=n\nBUG=567, 456"], 946 Git("log -1 hash3", "Title3\nLOG=n\nBUG=567, 456"),
940 ["log -1 hash1", "Title1"], 947 Git("log -1 hash1", "Title1"),
941 ["log -1 hash5", "Title5"], 948 Git("log -1 hash5", "Title5"),
942 ["log -1 -p hash4", "patch4"], 949 Git("log -1 -p hash4", "patch4"),
943 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], 950 Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
944 "", VerifyPatch("patch4")], 951 "", cb=VerifyPatch("patch4")),
945 ["log -1 -p hash2", "patch2"], 952 Git("log -1 -p hash2", "patch2"),
946 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], 953 Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
947 "", VerifyPatch("patch2")], 954 "", cb=VerifyPatch("patch2")),
948 ["log -1 -p hash3", "patch3"], 955 Git("log -1 -p hash3", "patch3"),
949 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], 956 Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
950 "", VerifyPatch("patch3")], 957 "", cb=VerifyPatch("patch3")),
951 ["log -1 -p hash1", "patch1"], 958 Git("log -1 -p hash1", "patch1"),
952 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], 959 Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
953 "", VerifyPatch("patch1")], 960 "", cb=VerifyPatch("patch1")),
954 ["log -1 -p hash5", "patch5\n"], 961 Git("log -1 -p hash5", "patch5\n"),
955 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], 962 Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
956 "", VerifyPatch("patch5\n")], 963 "", cb=VerifyPatch("patch5\n")),
957 ["apply --index --reject \"%s\"" % extra_patch, ""], 964 Git("apply --index --reject \"%s\"" % extra_patch, ""),
958 ["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""], 965 Git("commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""),
959 ["cl upload --send-mail -r \"reviewer@chromium.org\"", ""], 966 Git("cl upload --send-mail -r \"reviewer@chromium.org\"", ""),
960 ["checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""], 967 Git("checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""),
961 ["cl presubmit", "Presubmit successfull\n"], 968 Git("cl presubmit", "Presubmit successfull\n"),
962 ["cl dcommit -f --bypass-hooks", "Closing issue\n", VerifySVNCommit], 969 Git("cl dcommit -f --bypass-hooks", "Closing issue\n", cb=VerifySVNCommit) ,
963 ["svn fetch", ""], 970 Git("svn fetch", ""),
964 ["log -1 --format=%%H --grep=\"%s\" svn/trunk" % msg, "hash6"], 971 Git("log -1 --format=%%H --grep=\"%s\" svn/trunk" % msg, "hash6"),
965 ["svn find-rev hash6", "1324"], 972 Git("svn find-rev hash6", "1324"),
966 [("copy -r 1324 https://v8.googlecode.com/svn/trunk " 973 Git(("copy -r 1324 https://v8.googlecode.com/svn/trunk "
967 "https://v8.googlecode.com/svn/tags/3.22.5.1 -m " 974 "https://v8.googlecode.com/svn/tags/3.22.5.1 -m "
968 "\"Tagging version 3.22.5.1\""), ""], 975 "\"Tagging version 3.22.5.1\""), ""),
969 ["checkout -f some_branch", ""], 976 Git("checkout -f some_branch", ""),
970 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], 977 Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""),
971 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], 978 Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""),
972 ]) 979 ])
973 980
974 self.ExpectReadline([ 981 self.ExpectReadline([
975 "Y", # Automatically add corresponding ports (34567, 56789)? 982 RL("Y"), # Automatically add corresponding ports (34567, 56789)?
976 "Y", # Automatically increment patch level? 983 RL("Y"), # Automatically increment patch level?
977 "reviewer@chromium.org", # V8 reviewer. 984 RL("reviewer@chromium.org"), # V8 reviewer.
978 "LGTM", # Enter LGTM for V8 CL. 985 RL("LGTM"), # Enter LGTM for V8 CL.
979 ]) 986 ])
980 987
981 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS 988 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS
982 # ports of r12345. r56789 is the MIPS port of r34567. 989 # ports of r12345. r56789 is the MIPS port of r34567.
983 args = ["-f", "-p", extra_patch, "--branch", "trunk", "12345", "23456", 990 args = ["-f", "-p", extra_patch, "--branch", "trunk", "12345", "23456",
984 "34567"] 991 "34567"]
985 options = merge_to_branch.BuildOptions().parse_args(args)
986 self.assertTrue(merge_to_branch.ProcessOptions(options))
987 992
988 # The first run of the script stops because of the svn being down. 993 # The first run of the script stops because of the svn being down.
989 self.assertRaises(GitFailedException, 994 self.assertRaises(GitFailedException,
990 lambda: RunMergeToBranch(TEST_CONFIG, 995 lambda: MergeToBranch(TEST_CONFIG, self).Run(args))
991 MergeToBranchOptions(options),
992 self))
993 996
994 # Test that state recovery after restarting the script works. 997 # Test that state recovery after restarting the script works.
995 options.step = 3 998 args += ["-s", "3"]
996 RunMergeToBranch(TEST_CONFIG, MergeToBranchOptions(options), self) 999 MergeToBranch(TEST_CONFIG, self).Run(args)
997 1000
998 1001
999 class SystemTest(unittest.TestCase): 1002 class SystemTest(unittest.TestCase):
1000 def testReload(self): 1003 def testReload(self):
1001 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, 1004 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={},
1002 options=CommonOptions(MakeOptions()),
1003 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) 1005 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER)
1004 body = step.Reload( 1006 body = step.Reload(
1005 """------------------------------------------------------------------------ 1007 """------------------------------------------------------------------------
1006 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines 1008 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines
1007 1009
1008 Prepare push to trunk. Now working on version 3.23.11. 1010 Prepare push to trunk. Now working on version 3.23.11.
1009 1011
1010 R=danno@chromium.org 1012 R=danno@chromium.org
1011 1013
1012 Review URL: https://codereview.chromium.org/83173002 1014 Review URL: https://codereview.chromium.org/83173002
1013 1015
1014 ------------------------------------------------------------------------""") 1016 ------------------------------------------------------------------------""")
1015 self.assertEquals( 1017 self.assertEquals(
1016 """Prepare push to trunk. Now working on version 3.23.11. 1018 """Prepare push to trunk. Now working on version 3.23.11.
1017 1019
1018 R=danno@chromium.org 1020 R=danno@chromium.org
1019 1021
1020 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) 1022 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body)
OLDNEW
« no previous file with comments | « tools/push-to-trunk/script_test.py ('k') | tools/v8heapconst.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698