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

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

Issue 178223011: Reset trunk to 3.24.35.4 (Closed) Base URL: https://v8.googlecode.com/svn/trunk
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/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 13 matching lines...) Expand all
24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
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 common_includes
35 from common_includes import *
36 import push_to_trunk
37 from push_to_trunk import *
34 import auto_roll 38 import auto_roll
35 from auto_roll import AutoRollOptions 39 from auto_roll import AutoRollOptions
36 from auto_roll import CheckLastPush 40 from auto_roll import CheckLastPush
37 from auto_roll import FetchLatestRevision 41 from auto_roll import FetchLatestRevision
38 from auto_roll import SETTINGS_LOCATION 42 from auto_roll import SETTINGS_LOCATION
39 import common_includes
40 from common_includes import *
41 import merge_to_branch
42 from merge_to_branch import *
43 import push_to_trunk
44 from push_to_trunk import *
45 43
46 44
47 TEST_CONFIG = { 45 TEST_CONFIG = {
48 BRANCHNAME: "test-prepare-push", 46 BRANCHNAME: "test-prepare-push",
49 TRUNKBRANCH: "test-trunk-push", 47 TRUNKBRANCH: "test-trunk-push",
50 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", 48 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile",
51 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", 49 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script",
52 DOT_GIT_LOCATION: None, 50 DOT_GIT_LOCATION: None,
53 VERSION_FILE: None, 51 VERSION_FILE: None,
54 CHANGELOG_FILE: None, 52 CHANGELOG_FILE: None,
55 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", 53 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry",
56 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", 54 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch",
57 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", 55 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg",
58 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", 56 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium",
59 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", 57 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS",
60 SETTINGS_LOCATION: None, 58 SETTINGS_LOCATION: None,
61 ALREADY_MERGING_SENTINEL_FILE:
62 "/tmp/test-merge-to-branch-tempfile-already-merging",
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",
65 } 59 }
66 60
67 61
68 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None, a=None, 62 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None,
69 status_password=None, revert_bleeding_edge=None, p=None): 63 status_password=None):
70 """Convenience wrapper.""" 64 """Convenience wrapper."""
71 class Options(object): 65 class Options(object):
72 pass 66 pass
73 options = Options() 67 options = Options()
74 options.s = s 68 options.s = s
75 options.l = l 69 options.l = l
76 options.f = f 70 options.f = f
77 options.m = m 71 options.m = m
78 options.reviewer = r 72 options.r = r
79 options.c = c 73 options.c = c
80 options.a = a
81 options.p = p
82 options.status_password = status_password 74 options.status_password = status_password
83 options.revert_bleeding_edge = revert_bleeding_edge
84 return options 75 return options
85 76
86 77
87 class ToplevelTest(unittest.TestCase): 78 class ToplevelTest(unittest.TestCase):
88 def testMakeComment(self): 79 def testMakeComment(self):
89 self.assertEquals("# Line 1\n# Line 2\n#", 80 self.assertEquals("# Line 1\n# Line 2\n#",
90 MakeComment(" Line 1\n Line 2\n")) 81 MakeComment(" Line 1\n Line 2\n"))
91 self.assertEquals("#Line 1\n#Line 2", 82 self.assertEquals("#Line 1\n#Line 2",
92 MakeComment("Line 1\n Line 2")) 83 MakeComment("Line 1\n Line 2"))
93 84
(...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after
229 self._index = -1 220 self._index = -1
230 221
231 def Expect(self, recipe): 222 def Expect(self, recipe):
232 self._recipe = recipe 223 self._recipe = recipe
233 224
234 def Call(self, *args): 225 def Call(self, *args):
235 self._index += 1 226 self._index += 1
236 try: 227 try:
237 expected_call = self._recipe[self._index] 228 expected_call = self._recipe[self._index]
238 except IndexError: 229 except IndexError:
239 raise NoRetryException("Calling %s %s" % (self._name, " ".join(args))) 230 raise Exception("Calling %s %s" % (self._name, " ".join(args)))
240 231
241 # Pack expectations without arguments into a list. 232 # Pack expectations without arguments into a list.
242 if not isinstance(expected_call, list): 233 if not isinstance(expected_call, list):
243 expected_call = [expected_call] 234 expected_call = [expected_call]
244 235
245 # The number of arguments in the expectation must match the actual 236 # The number of arguments in the expectation must match the actual
246 # arguments. 237 # arguments.
247 if len(args) > len(expected_call): 238 if len(args) > len(expected_call):
248 raise NoRetryException("When calling %s with arguments, the " 239 raise NoRetryException("When calling %s with arguments, the "
249 "expectations must consist of at least as many arguments.") 240 "expectations must consist of at least as many arguments.")
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 f.write("#define MINOR_VERSION 22\n") 282 f.write("#define MINOR_VERSION 22\n")
292 f.write("#define BUILD_NUMBER 5\n") 283 f.write("#define BUILD_NUMBER 5\n")
293 f.write("#define PATCH_LEVEL 0\n") 284 f.write("#define PATCH_LEVEL 0\n")
294 f.write(" // Some line...\n") 285 f.write(" // Some line...\n")
295 f.write("#define IS_CANDIDATE_VERSION 0\n") 286 f.write("#define IS_CANDIDATE_VERSION 0\n")
296 return name 287 return name
297 288
298 def MakeStep(self, step_class=Step, state=None, options=None): 289 def MakeStep(self, step_class=Step, state=None, options=None):
299 """Convenience wrapper.""" 290 """Convenience wrapper."""
300 options = options or CommonOptions(MakeOptions()) 291 options = options or CommonOptions(MakeOptions())
301 state = state if state is not None else self._state
302 return MakeStep(step_class=step_class, number=0, state=state, 292 return MakeStep(step_class=step_class, number=0, state=state,
303 config=TEST_CONFIG, options=options, 293 config=TEST_CONFIG, options=options,
304 side_effect_handler=self) 294 side_effect_handler=self)
305 295
306 def GitMock(self, cmd, args="", pipe=True): 296 def GitMock(self, cmd, args="", pipe=True):
307 print "%s %s" % (cmd, args) 297 print "%s %s" % (cmd, args)
308 return self._git_mock.Call(args) 298 return self._git_mock.Call(args)
309 299
310 def LogMock(self, cmd, args=""): 300 def LogMock(self, cmd, args=""):
311 print "Log: %s %s" % (cmd, args) 301 print "Log: %s %s" % (cmd, args)
312 302
313 MOCKS = { 303 MOCKS = {
314 "git": GitMock, 304 "git": GitMock,
315 # TODO(machenbach): Little hack to reuse the git mock for the one svn call
316 # in merge-to-branch. The command should be made explicit in the test
317 # expectations.
318 "svn": GitMock,
319 "vi": LogMock, 305 "vi": LogMock,
320 } 306 }
321 307
322 def Call(self, fun, *args, **kwargs): 308 def Call(self, fun, *args, **kwargs):
323 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs)) 309 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs))
324 310
325 def Command(self, cmd, args="", prefix="", pipe=True): 311 def Command(self, cmd, args="", prefix="", pipe=True):
326 return ScriptTest.MOCKS[cmd](self, cmd, args) 312 return ScriptTest.MOCKS[cmd](self, cmd, args)
327 313
328 def ReadLine(self): 314 def ReadLine(self):
(...skipping 21 matching lines...) Expand all
350 336
351 def ExpectReadURL(self, *args): 337 def ExpectReadURL(self, *args):
352 """Convenience wrapper.""" 338 """Convenience wrapper."""
353 self._url_mock.Expect(*args) 339 self._url_mock.Expect(*args)
354 340
355 def setUp(self): 341 def setUp(self):
356 self._git_mock = SimpleMock("git") 342 self._git_mock = SimpleMock("git")
357 self._rl_mock = SimpleMock("readline") 343 self._rl_mock = SimpleMock("readline")
358 self._url_mock = SimpleMock("readurl") 344 self._url_mock = SimpleMock("readurl")
359 self._tmp_files = [] 345 self._tmp_files = []
360 self._state = {}
361 346
362 def tearDown(self): 347 def tearDown(self):
363 Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME]) 348 Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME])
364 349
365 # Clean up temps. Doesn't work automatically. 350 # Clean up temps. Doesn't work automatically.
366 for name in self._tmp_files: 351 for name in self._tmp_files:
367 if os.path.exists(name): 352 if os.path.exists(name):
368 os.remove(name) 353 os.remove(name)
369 354
370 self._git_mock.AssertFinished() 355 self._git_mock.AssertFinished()
371 self._rl_mock.AssertFinished() 356 self._rl_mock.AssertFinished()
372 self._url_mock.AssertFinished() 357 self._url_mock.AssertFinished()
373 358
359 def testPersistRestore(self):
360 self.MakeStep().Persist("test1", "")
361 self.assertEquals("", self.MakeStep().Restore("test1"))
362 self.MakeStep().Persist("test2", "AB123")
363 self.assertEquals("AB123", self.MakeStep().Restore("test2"))
364
374 def testGitOrig(self): 365 def testGitOrig(self):
375 self.assertTrue(Command("git", "--version").startswith("git version")) 366 self.assertTrue(Command("git", "--version").startswith("git version"))
376 367
377 def testGitMock(self): 368 def testGitMock(self):
378 self.ExpectGit([["--version", "git version 1.2.3"], ["dummy", ""]]) 369 self.ExpectGit([["--version", "git version 1.2.3"], ["dummy", ""]])
379 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) 370 self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version"))
380 self.assertEquals("", self.MakeStep().Git("dummy")) 371 self.assertEquals("", self.MakeStep().Git("dummy"))
381 372
382 def testCommonPrepareDefault(self): 373 def testCommonPrepareDefault(self):
383 self.ExpectGit([ 374 self.ExpectGit([
384 ["status -s -uno", ""], 375 ["status -s -uno", ""],
385 ["status -s -b -uno", "## some_branch"], 376 ["status -s -b -uno", "## some_branch"],
386 ["svn fetch", ""], 377 ["svn fetch", ""],
387 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 378 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]],
388 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], 379 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""],
389 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], 380 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""],
390 ["branch", ""], 381 ["branch", ""],
391 ]) 382 ])
392 self.ExpectReadline(["Y"]) 383 self.ExpectReadline(["Y"])
393 self.MakeStep().CommonPrepare() 384 self.MakeStep().CommonPrepare()
394 self.MakeStep().PrepareBranch() 385 self.MakeStep().PrepareBranch()
395 self.assertEquals("some_branch", self._state["current_branch"]) 386 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch"))
396 387
397 def testCommonPrepareNoConfirm(self): 388 def testCommonPrepareNoConfirm(self):
398 self.ExpectGit([ 389 self.ExpectGit([
399 ["status -s -uno", ""], 390 ["status -s -uno", ""],
400 ["status -s -b -uno", "## some_branch"], 391 ["status -s -b -uno", "## some_branch"],
401 ["svn fetch", ""], 392 ["svn fetch", ""],
402 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 393 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]],
403 ]) 394 ])
404 self.ExpectReadline(["n"]) 395 self.ExpectReadline(["n"])
405 self.MakeStep().CommonPrepare() 396 self.MakeStep().CommonPrepare()
406 self.assertRaises(Exception, self.MakeStep().PrepareBranch) 397 self.assertRaises(Exception, self.MakeStep().PrepareBranch)
407 self.assertEquals("some_branch", self._state["current_branch"]) 398 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch"))
408 399
409 def testCommonPrepareDeleteBranchFailure(self): 400 def testCommonPrepareDeleteBranchFailure(self):
410 self.ExpectGit([ 401 self.ExpectGit([
411 ["status -s -uno", ""], 402 ["status -s -uno", ""],
412 ["status -s -b -uno", "## some_branch"], 403 ["status -s -b -uno", "## some_branch"],
413 ["svn fetch", ""], 404 ["svn fetch", ""],
414 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], 405 ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]],
415 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None], 406 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None],
416 ]) 407 ])
417 self.ExpectReadline(["Y"]) 408 self.ExpectReadline(["Y"])
418 self.MakeStep().CommonPrepare() 409 self.MakeStep().CommonPrepare()
419 self.assertRaises(Exception, self.MakeStep().PrepareBranch) 410 self.assertRaises(Exception, self.MakeStep().PrepareBranch)
420 self.assertEquals("some_branch", self._state["current_branch"]) 411 self.assertEquals("some_branch", self.MakeStep().Restore("current_branch"))
421 412
422 def testInitialEnvironmentChecks(self): 413 def testInitialEnvironmentChecks(self):
423 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 414 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
424 os.environ["EDITOR"] = "vi" 415 os.environ["EDITOR"] = "vi"
425 self.MakeStep().InitialEnvironmentChecks() 416 self.MakeStep().InitialEnvironmentChecks()
426 417
427 def testReadAndPersistVersion(self): 418 def testReadAndPersistVersion(self):
428 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 419 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
429 step = self.MakeStep() 420 step = self.MakeStep()
430 step.ReadAndPersistVersion() 421 step.ReadAndPersistVersion()
431 self.assertEquals("3", step["major"]) 422 self.assertEquals("3", self.MakeStep().Restore("major"))
432 self.assertEquals("22", step["minor"]) 423 self.assertEquals("22", self.MakeStep().Restore("minor"))
433 self.assertEquals("5", step["build"]) 424 self.assertEquals("5", self.MakeStep().Restore("build"))
434 self.assertEquals("0", step["patch"]) 425 self.assertEquals("0", self.MakeStep().Restore("patch"))
426 self.assertEquals("3", step._state["major"])
427 self.assertEquals("22", step._state["minor"])
428 self.assertEquals("5", step._state["build"])
429 self.assertEquals("0", step._state["patch"])
435 430
436 def testRegex(self): 431 def testRegex(self):
437 self.assertEqual("(issue 321)", 432 self.assertEqual("(issue 321)",
438 re.sub(r"BUG=v8:(.*)$", r"(issue \1)", "BUG=v8:321")) 433 re.sub(r"BUG=v8:(.*)$", r"(issue \1)", "BUG=v8:321"))
439 self.assertEqual("(Chromium issue 321)", 434 self.assertEqual("(Chromium issue 321)",
440 re.sub(r"BUG=(.*)$", r"(Chromium issue \1)", "BUG=321")) 435 re.sub(r"BUG=(.*)$", r"(Chromium issue \1)", "BUG=321"))
441 436
442 cl = " too little\n\ttab\ttab\n too much\n trailing " 437 cl = " too little\n\ttab\ttab\n too much\n trailing "
443 cl = MSub(r"\t", r" ", cl) 438 cl = MSub(r"\t", r" ", cl)
444 cl = MSub(r"^ {1,7}([^ ])", r" \1", cl) 439 cl = MSub(r"^ {1,7}([^ ])", r" \1", cl)
445 cl = MSub(r"^ {9,80}([^ ])", r" \1", cl) 440 cl = MSub(r"^ {9,80}([^ ])", r" \1", cl)
446 cl = MSub(r" +$", r"", cl) 441 cl = MSub(r" +$", r"", cl)
447 self.assertEqual(" too little\n" 442 self.assertEqual(" too little\n"
448 " tab tab\n" 443 " tab tab\n"
449 " too much\n" 444 " too much\n"
450 " trailing", cl) 445 " trailing", cl)
451 446
452 self.assertEqual("//\n#define BUILD_NUMBER 3\n", 447 self.assertEqual("//\n#define BUILD_NUMBER 3\n",
453 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", 448 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
454 r"\g<space>3", 449 r"\g<space>3",
455 "//\n#define BUILD_NUMBER 321\n")) 450 "//\n#define BUILD_NUMBER 321\n"))
456 451
457 def testPrepareChangeLog(self): 452 def testPrepareChangeLog(self):
458 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 453 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
459 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 454 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
460 455
461 self.ExpectGit([ 456 self.ExpectGit([
462 ["log --format=%H 1234..HEAD", "rev1\nrev2\nrev3\nrev4"], 457 ["log 1234..HEAD --format=%H", "rev1\nrev2\nrev3\nrev4"],
463 ["log -1 --format=%s rev1", "Title text 1"], 458 ["log -1 rev1 --format=\"%s\"", "Title text 1"],
464 ["log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"], 459 ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\nLOG=y\n"],
465 ["log -1 --format=%an rev1", "author1@chromium.org"], 460 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org"],
466 ["log -1 --format=%s rev2", "Title text 2."], 461 ["log -1 rev2 --format=\"%s\"", "Title text 2."],
467 ["log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"], 462 ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=123\nLOG= \n"],
468 ["log -1 --format=%an rev2", "author2@chromium.org"], 463 ["log -1 rev2 --format=\"%an\"", "author2@chromium.org"],
469 ["log -1 --format=%s rev3", "Title text 3"], 464 ["log -1 rev3 --format=\"%s\"", "Title text 3"],
470 ["log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"], 465 ["log -1 rev3 --format=\"%B\"", "Title\n\nBUG=321\nLOG=true\n"],
471 ["log -1 --format=%an rev3", "author3@chromium.org"], 466 ["log -1 rev3 --format=\"%an\"", "author3@chromium.org"],
472 ["log -1 --format=%s rev4", "Title text 4"], 467 ["log -1 rev4 --format=\"%s\"", "Title text 4"],
473 ["log -1 --format=%B rev4", 468 ["log -1 rev4 --format=\"%B\"",
474 ("Title\n\nBUG=456\nLOG=Y\n\n" 469 ("Title\n\nBUG=456\nLOG=Y\n\n"
475 "Review URL: https://codereview.chromium.org/9876543210\n")], 470 "Review URL: https://codereview.chromium.org/9876543210\n")],
476 ["log -1 --format=%an rev4", "author4@chromium.org"], 471 ["log -1 rev4 --format=\"%an\"", "author4@chromium.org"],
477 ]) 472 ])
478 473
479 # The cl for rev4 on rietveld has an updated LOG flag. 474 # The cl for rev4 on rietveld has an updated LOG flag.
480 self.ExpectReadURL([ 475 self.ExpectReadURL([
481 ["https://codereview.chromium.org/9876543210/description", 476 ["https://codereview.chromium.org/9876543210/description",
482 "Title\n\nBUG=456\nLOG=N\n\n"], 477 "Title\n\nBUG=456\nLOG=N\n\n"],
483 ]) 478 ])
484 479
485 self._state["last_push_bleeding_edge"] = "1234" 480 self.MakeStep().Persist("last_push", "1234")
486 self.MakeStep(PrepareChangeLog).Run() 481 self.MakeStep(PrepareChangeLog).Run()
487 482
488 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 483 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
489 484
490 expected_cl = """1999-07-31: Version 3.22.5 485 expected_cl = """1999-07-31: Version 3.22.5
491 486
492 Title text 1. 487 Title text 1.
493 488
494 Title text 3 (Chromium issue 321). 489 Title text 3 (Chromium issue 321).
495 490
(...skipping 11 matching lines...) Expand all
507 # 502 #
508 # Title text 3 (Chromium issue 321). 503 # Title text 3 (Chromium issue 321).
509 # (author3@chromium.org) 504 # (author3@chromium.org)
510 # 505 #
511 # Title text 4 (Chromium issue 456). 506 # Title text 4 (Chromium issue 456).
512 # (author4@chromium.org) 507 # (author4@chromium.org)
513 # 508 #
514 #""" 509 #"""
515 510
516 self.assertEquals(expected_cl, actual_cl) 511 self.assertEquals(expected_cl, actual_cl)
517 self.assertEquals("3", self._state["major"]) 512 self.assertEquals("3", self.MakeStep().Restore("major"))
518 self.assertEquals("22", self._state["minor"]) 513 self.assertEquals("22", self.MakeStep().Restore("minor"))
519 self.assertEquals("5", self._state["build"]) 514 self.assertEquals("5", self.MakeStep().Restore("build"))
520 self.assertEquals("0", self._state["patch"]) 515 self.assertEquals("0", self.MakeStep().Restore("patch"))
521 516
522 def testEditChangeLog(self): 517 def testEditChangeLog(self):
523 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 518 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
524 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 519 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
525 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) 520 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE])
526 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 521 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE])
527 os.environ["EDITOR"] = "vi" 522 os.environ["EDITOR"] = "vi"
528 523
529 self.ExpectReadline([ 524 self.ExpectReadline([
530 "", # Open editor. 525 "", # Open editor.
531 ]) 526 ])
532 527
533 self.MakeStep(EditChangeLog).Run() 528 self.MakeStep(EditChangeLog).Run()
534 529
535 self.assertEquals("New\n Lines\n\n\n Original CL", 530 self.assertEquals("New\n Lines\n\n\n Original CL",
536 FileToText(TEST_CONFIG[CHANGELOG_FILE])) 531 FileToText(TEST_CONFIG[CHANGELOG_FILE]))
537 532
538 def testIncrementVersion(self): 533 def testIncrementVersion(self):
539 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 534 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
540 self._state["build"] = "5" 535 self.MakeStep().Persist("build", "5")
541 536
542 self.ExpectReadline([ 537 self.ExpectReadline([
543 "Y", # Increment build number. 538 "Y", # Increment build number.
544 ]) 539 ])
545 540
546 self.MakeStep(IncrementVersion).Run() 541 self.MakeStep(IncrementVersion).Run()
547 542
548 self.assertEquals("3", self._state["new_major"]) 543 self.assertEquals("3", self.MakeStep().Restore("new_major"))
549 self.assertEquals("22", self._state["new_minor"]) 544 self.assertEquals("22", self.MakeStep().Restore("new_minor"))
550 self.assertEquals("6", self._state["new_build"]) 545 self.assertEquals("6", self.MakeStep().Restore("new_build"))
551 self.assertEquals("0", self._state["new_patch"]) 546 self.assertEquals("0", self.MakeStep().Restore("new_patch"))
552 547
553 def testLastChangeLogEntries(self): 548 def testLastChangeLogEntries(self):
554 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 549 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
555 l = """ 550 l = """
556 Fixed something. 551 Fixed something.
557 (issue 1234)\n""" 552 (issue 1234)\n"""
558 for _ in xrange(10): l = l + l 553 for _ in xrange(10): l = l + l
559 554
560 cl_chunk = """2013-11-12: Version 3.23.2\n%s 555 cl_chunk = """2013-11-12: Version 3.23.2\n%s
561 Performance and stability improvements on all platforms.\n\n\n""" % l 556 Performance and stability improvements on all platforms.\n\n\n""" % l
562 557
563 cl_chunk_full = cl_chunk + cl_chunk + cl_chunk 558 cl_chunk_full = cl_chunk + cl_chunk + cl_chunk
564 TextToFile(cl_chunk_full, TEST_CONFIG[CHANGELOG_FILE]) 559 TextToFile(cl_chunk_full, TEST_CONFIG[CHANGELOG_FILE])
565 560
566 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE]) 561 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE])
567 self.assertEquals(cl_chunk, cl) 562 self.assertEquals(cl_chunk, cl)
568 563
569 def _TestSquashCommits(self, change_log, expected_msg): 564 def _TestSquashCommits(self, change_log, expected_msg):
570 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 565 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
571 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: 566 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f:
572 f.write(change_log) 567 f.write(change_log)
573 568
574 self.ExpectGit([ 569 self.ExpectGit([
575 ["diff svn/trunk hash1", "patch content"], 570 ["diff svn/trunk hash1", "patch content"],
576 ["svn find-rev hash1", "123455\n"], 571 ["svn find-rev hash1", "123455\n"],
577 ]) 572 ])
578 573
579 self._state["prepare_commit_hash"] = "hash1" 574 self.MakeStep().Persist("prepare_commit_hash", "hash1")
580 self._state["date"] = "1999-11-11" 575 self.MakeStep().Persist("date", "1999-11-11")
581 576
582 self.MakeStep(SquashCommits).Run() 577 self.MakeStep(SquashCommits).Run()
583 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg) 578 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg)
584 579
585 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) 580 patch = FileToText(TEST_CONFIG[ PATCH_FILE])
586 self.assertTrue(re.search(r"patch content", patch)) 581 self.assertTrue(re.search(r"patch content", patch))
587 582
588 def testSquashCommitsUnformatted(self): 583 def testSquashCommitsUnformatted(self):
589 change_log = """1999-11-11: Version 3.22.5 584 change_log = """1999-11-11: Version 3.22.5
590 585
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
661 review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else "" 656 review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else ""
662 self.ExpectGit([ 657 self.ExpectGit([
663 ["status -s -uno", ""], 658 ["status -s -uno", ""],
664 ["status -s -b -uno", "## some_branch\n"], 659 ["status -s -b -uno", "## some_branch\n"],
665 ["svn fetch", ""], 660 ["svn fetch", ""],
666 ["branch", " branch1\n* branch2\n"], 661 ["branch", " branch1\n* branch2\n"],
667 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], 662 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""],
668 ["branch", " branch1\n* branch2\n"], 663 ["branch", " branch1\n* branch2\n"],
669 ["branch", " branch1\n* branch2\n"], 664 ["branch", " branch1\n* branch2\n"],
670 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], 665 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""],
671 [("log -1 --format=%H --grep=" 666 ["log -1 --format=%H ChangeLog", "1234\n"],
672 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " 667 ["log -1 1234", "Last push ouput\n"],
673 "svn/trunk"), "hash2\n"], 668 ["log 1234..HEAD --format=%H", "rev1\n"],
674 ["log -1 hash2", "Log message\n"], 669 ["log -1 rev1 --format=\"%s\"", "Log text 1.\n"],
675 ["log -1 --format=%s hash2", 670 ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"],
676 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"], 671 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org\n"],
677 ["svn find-rev r1234", "hash3\n"], 672 [("commit -a -m \"Prepare push to trunk. "
678 ["log --format=%H hash3..HEAD", "rev1\n"],
679 ["log -1 --format=%s rev1", "Log text 1.\n"],
680 ["log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"],
681 ["log -1 --format=%an rev1", "author1@chromium.org\n"],
682 [("commit -am \"Prepare push to trunk. "
683 "Now working on version 3.22.6.%s\"" % review_suffix), 673 "Now working on version 3.22.6.%s\"" % review_suffix),
684 " 2 files changed\n", 674 " 2 files changed\n",
685 CheckPreparePush], 675 CheckPreparePush],
686 [("cl upload --send-mail --email \"author@chromium.org\" " 676 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag,
687 "-r \"reviewer@chromium.org\"%s" % force_flag),
688 "done\n"], 677 "done\n"],
689 ["cl presubmit", "Presubmit successfull\n"], 678 ["cl presubmit", "Presubmit successfull\n"],
690 ["cl dcommit -f --bypass-hooks", "Closing issue\n"], 679 ["cl dcommit -f --bypass-hooks", "Closing issue\n"],
691 ["svn fetch", "fetch result\n"], 680 ["svn fetch", "fetch result\n"],
692 ["checkout -f svn/bleeding_edge", ""], 681 ["checkout svn/bleeding_edge", ""],
693 [("log -1 --format=%H --grep=\"Prepare push to trunk. " 682 [("log -1 --format=%H --grep=\"Prepare push to trunk. "
694 "Now working on version 3.22.6.\""), 683 "Now working on version 3.22.6.\""),
695 "hash1\n"], 684 "hash1\n"],
696 ["diff svn/trunk hash1", "patch content\n"], 685 ["diff svn/trunk hash1", "patch content\n"],
697 ["svn find-rev hash1", "123455\n"], 686 ["svn find-rev hash1", "123455\n"],
698 ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""], 687 ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""],
699 ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""], 688 ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""],
700 ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""], 689 ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""],
701 ["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit], 690 ["commit -F \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit],
702 ["svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"], 691 ["svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"],
703 ["svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""], 692 ["svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""],
704 ["status -s -uno", ""], 693 ["status -s -uno", ""],
705 ["checkout -f master", ""], 694 ["checkout master", ""],
706 ["pull", ""], 695 ["pull", ""],
707 ["checkout -b v8-roll-123456", ""], 696 ["checkout -b v8-roll-123456", ""],
708 [("commit -am \"Update V8 to version 3.22.5 " 697 [("commit -am \"Update V8 to version 3.22.5 "
709 "(based on bleeding_edge revision r123455).\n\n" 698 "(based on bleeding_edge revision r123455).\n\n"
710 "TBR=reviewer@chromium.org\""), 699 "TBR=reviewer@chromium.org\""),
711 ""], 700 ""],
712 ["cl upload --send-mail --email \"author@chromium.org\"%s" % force_flag, 701 ["cl upload --send-mail%s" % force_flag, ""],
713 ""],
714 ["checkout -f some_branch", ""], 702 ["checkout -f some_branch", ""],
715 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], 703 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""],
716 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], 704 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""],
717 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], 705 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""],
718 ]) 706 ])
719 707
720 # Expected keyboard input in manual mode: 708 # Expected keyboard input in manual mode:
721 if manual: 709 if manual:
722 self.ExpectReadline([ 710 self.ExpectReadline([
723 "Y", # Confirm last push. 711 "Y", # Confirm last push.
724 "", # Open editor. 712 "", # Open editor.
725 "Y", # Increment build number. 713 "Y", # Increment build number.
726 "reviewer@chromium.org", # V8 reviewer. 714 "reviewer@chromium.org", # V8 reviewer.
727 "LGTX", # Enter LGTM for V8 CL (wrong). 715 "LGTX", # Enter LGTM for V8 CL (wrong).
728 "LGTM", # Enter LGTM for V8 CL. 716 "LGTM", # Enter LGTM for V8 CL.
729 "Y", # Sanity check. 717 "Y", # Sanity check.
730 "reviewer@chromium.org", # Chromium reviewer. 718 "reviewer@chromium.org", # Chromium reviewer.
731 ]) 719 ])
732 720
733 # Expected keyboard input in semi-automatic mode: 721 # Expected keyboard input in semi-automatic mode:
734 if not manual and not force: 722 if not manual and not force:
735 self.ExpectReadline([ 723 self.ExpectReadline([
736 "LGTM", # Enter LGTM for V8 CL. 724 "LGTM", # Enter LGTM for V8 CL.
737 ]) 725 ])
738 726
739 # No keyboard input in forced mode: 727 # No keyboard input in forced mode:
740 if force: 728 if force:
741 self.ExpectReadline([]) 729 self.ExpectReadline([])
742 730
743 options = MakeOptions(f=force, m=manual, a="author@chromium.org", 731 options = MakeOptions(f=force, m=manual,
744 r="reviewer@chromium.org" if not manual else None, 732 r="reviewer@chromium.org" if not manual else None,
745 c = TEST_CONFIG[CHROMIUM]) 733 c = TEST_CONFIG[CHROMIUM])
746 RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self) 734 RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self)
747 735
748 deps = FileToText(TEST_CONFIG[DEPS_FILE]) 736 deps = FileToText(TEST_CONFIG[DEPS_FILE])
749 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) 737 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps))
750 738
751 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) 739 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
752 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) 740 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl))
753 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) 741 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl))
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 ["https://v8-status.appspot.com/status", 782 ["https://v8-status.appspot.com/status",
795 ("username=v8-auto-roll%40chromium.org&" 783 ("username=v8-auto-roll%40chromium.org&"
796 "message=Tree+is+throttled&password=PW"), ""], 784 "message=Tree+is+throttled&password=PW"), ""],
797 ]) 785 ])
798 786
799 self.ExpectGit([ 787 self.ExpectGit([
800 ["status -s -uno", ""], 788 ["status -s -uno", ""],
801 ["status -s -b -uno", "## some_branch\n"], 789 ["status -s -b -uno", "## some_branch\n"],
802 ["svn fetch", ""], 790 ["svn fetch", ""],
803 ["svn log -1 --oneline", "r100 | Text"], 791 ["svn log -1 --oneline", "r100 | Text"],
804 [("log -1 --format=%H --grep=\"" 792 ["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."],
805 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\""
806 " svn/trunk"), "push_hash\n"],
807 ["svn find-rev push_hash", "65"],
808 ]) 793 ])
809 794
810 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions( 795 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(
811 MakeOptions(status_password=status_password)), self) 796 MakeOptions(status_password=status_password)), self)
812 797
813 state = json.loads(FileToText("%s-state.json" 798 self.assertEquals("100", self.MakeStep().Restore("lkgr"))
814 % TEST_CONFIG[PERSISTFILE_BASENAME])) 799 self.assertEquals("100", self.MakeStep().Restore("latest"))
815
816 self.assertEquals("100", state["lkgr"])
817 self.assertEquals("100", state["latest"])
818 800
819 def testAutoRollStoppedBySettings(self): 801 def testAutoRollStoppedBySettings(self):
820 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 802 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
821 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() 803 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile()
822 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) 804 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION])
823 805
824 self.ExpectReadURL([]) 806 self.ExpectReadURL([])
825 807
826 self.ExpectGit([ 808 self.ExpectGit([
827 ["status -s -uno", ""], 809 ["status -s -uno", ""],
(...skipping 17 matching lines...) Expand all
845 self.ExpectGit([ 827 self.ExpectGit([
846 ["status -s -uno", ""], 828 ["status -s -uno", ""],
847 ["status -s -b -uno", "## some_branch\n"], 829 ["status -s -b -uno", "## some_branch\n"],
848 ["svn fetch", ""], 830 ["svn fetch", ""],
849 ]) 831 ])
850 832
851 def RunAutoRoll(): 833 def RunAutoRoll():
852 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) 834 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self)
853 self.assertRaises(Exception, RunAutoRoll) 835 self.assertRaises(Exception, RunAutoRoll)
854 836
855 def testMergeToBranch(self):
856 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile()
857 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
858 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
859 os.environ["EDITOR"] = "vi"
860 extra_patch = self.MakeEmptyTempFile()
861
862 def VerifyPatch(patch):
863 return lambda: self.assertEquals(patch,
864 FileToText(TEST_CONFIG[TEMPORARY_PATCH_FILE]))
865
866 msg = """Merged r12345, r23456, r34567, r45678, r56789 into trunk branch.
867
868 Title4
869
870 Title2
871
872 Title3
873
874 Title1
875
876 Title5
877
878 BUG=123,234,345,456,567,v8:123
879 LOG=N
880 """
881
882 def VerifySVNCommit():
883 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE])
884 self.assertEquals(msg, commit)
885 version = FileToText(TEST_CONFIG[VERSION_FILE])
886 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
887 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
888 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version))
889 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
890
891 self.ExpectGit([
892 ["status -s -uno", ""],
893 ["status -s -b -uno", "## some_branch\n"],
894 ["svn fetch", ""],
895 ["branch", " branch1\n* branch2\n"],
896 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""],
897 ["branch", " branch1\n* branch2\n"],
898 ["checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""],
899 ["log --format=%H --grep=\"Port r12345\" --reverse svn/bleeding_edge",
900 "hash1\nhash2"],
901 ["svn find-rev hash1 svn/bleeding_edge", "45678"],
902 ["log -1 --format=%s hash1", "Title1"],
903 ["svn find-rev hash2 svn/bleeding_edge", "23456"],
904 ["log -1 --format=%s hash2", "Title2"],
905 ["log --format=%H --grep=\"Port r23456\" --reverse svn/bleeding_edge",
906 ""],
907 ["log --format=%H --grep=\"Port r34567\" --reverse svn/bleeding_edge",
908 "hash3"],
909 ["svn find-rev hash3 svn/bleeding_edge", "56789"],
910 ["log -1 --format=%s hash3", "Title3"],
911 ["svn find-rev r12345 svn/bleeding_edge", "hash4"],
912 # Simulate svn being down which stops the script.
913 ["svn find-rev r23456 svn/bleeding_edge", None],
914 # Restart script in the failing step.
915 ["svn find-rev r12345 svn/bleeding_edge", "hash4"],
916 ["svn find-rev r23456 svn/bleeding_edge", "hash2"],
917 ["svn find-rev r34567 svn/bleeding_edge", "hash3"],
918 ["svn find-rev r45678 svn/bleeding_edge", "hash1"],
919 ["svn find-rev r56789 svn/bleeding_edge", "hash5"],
920 ["log -1 --format=%s hash4", "Title4"],
921 ["log -1 --format=%s hash2", "Title2"],
922 ["log -1 --format=%s hash3", "Title3"],
923 ["log -1 --format=%s hash1", "Title1"],
924 ["log -1 --format=%s hash5", "Title5"],
925 ["log -1 hash4", "Title4\nBUG=123\nBUG=234"],
926 ["log -1 hash2", "Title2\n BUG = v8:123,345"],
927 ["log -1 hash3", "Title3\nLOG=n\nBUG=567, 456"],
928 ["log -1 hash1", "Title1"],
929 ["log -1 hash5", "Title5"],
930 ["log -1 -p hash4", "patch4"],
931 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
932 "", VerifyPatch("patch4")],
933 ["log -1 -p hash2", "patch2"],
934 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
935 "", VerifyPatch("patch2")],
936 ["log -1 -p hash3", "patch3"],
937 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
938 "", VerifyPatch("patch3")],
939 ["log -1 -p hash1", "patch1"],
940 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
941 "", VerifyPatch("patch1")],
942 ["log -1 -p hash5", "patch5"],
943 ["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
944 "", VerifyPatch("patch5")],
945 ["apply --index --reject \"%s\"" % extra_patch, ""],
946 ["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""],
947 ["cl upload --send-mail -r \"reviewer@chromium.org\"", ""],
948 ["checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""],
949 ["cl presubmit", "Presubmit successfull\n"],
950 ["cl dcommit -f --bypass-hooks", "Closing issue\n", VerifySVNCommit],
951 ["svn fetch", ""],
952 ["log -1 --format=%%H --grep=\"%s\" svn/trunk" % msg, "hash6"],
953 ["svn find-rev hash6", "1324"],
954 [("copy -r 1324 https://v8.googlecode.com/svn/trunk "
955 "https://v8.googlecode.com/svn/tags/3.22.5.1 -m "
956 "\"Tagging version 3.22.5.1\""), ""],
957 ["checkout -f some_branch", ""],
958 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""],
959 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""],
960 ])
961
962 self.ExpectReadline([
963 "Y", # Automatically add corresponding ports (34567, 56789)?
964 "Y", # Automatically increment patch level?
965 "reviewer@chromium.org", # V8 reviewer.
966 "LGTM", # Enter LGTM for V8 CL.
967 ])
968
969 options = MakeOptions(p=extra_patch, f=True)
970 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS
971 # ports of r12345. r56789 is the MIPS port of r34567.
972 args = ["trunk", "12345", "23456", "34567"]
973 self.assertTrue(merge_to_branch.ProcessOptions(options, args))
974
975 # The first run of the script stops because of the svn being down.
976 self.assertRaises(GitFailedException,
977 lambda: RunMergeToBranch(TEST_CONFIG,
978 MergeToBranchOptions(options, args),
979 self))
980
981 # Test that state recovery after restarting the script works.
982 options.s = 3
983 RunMergeToBranch(TEST_CONFIG, MergeToBranchOptions(options, args), self)
984
985
986 class SystemTest(unittest.TestCase): 837 class SystemTest(unittest.TestCase):
987 def testReload(self): 838 def testReload(self):
988 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, 839 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={},
989 options=CommonOptions(MakeOptions()), 840 options=CommonOptions(MakeOptions()),
990 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) 841 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER)
991 body = step.Reload( 842 body = step.Reload(
992 """------------------------------------------------------------------------ 843 """------------------------------------------------------------------------
993 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines 844 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines
994 845
995 Prepare push to trunk. Now working on version 3.23.11. 846 Prepare push to trunk. Now working on version 3.23.11.
996 847
997 R=danno@chromium.org 848 R=danno@chromium.org
998 849
999 Review URL: https://codereview.chromium.org/83173002 850 Review URL: https://codereview.chromium.org/83173002
1000 851
1001 ------------------------------------------------------------------------""") 852 ------------------------------------------------------------------------""")
1002 self.assertEquals( 853 self.assertEquals(
1003 """Prepare push to trunk. Now working on version 3.23.11. 854 """Prepare push to trunk. Now working on version 3.23.11.
1004 855
1005 R=danno@chromium.org 856 R=danno@chromium.org
1006 857
1007 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) 858 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