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

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

Issue 173983002: Refactoring: Redesign option parsing in push and merge scripts. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/push-to-trunk/push_to_trunk.py ('k') | no next file » | 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
(...skipping 11 matching lines...) Expand all
57 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", 56 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg",
58 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", 57 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium",
59 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", 58 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS",
60 SETTINGS_LOCATION: None, 59 SETTINGS_LOCATION: None,
61 ALREADY_MERGING_SENTINEL_FILE: 60 ALREADY_MERGING_SENTINEL_FILE:
62 "/tmp/test-merge-to-branch-tempfile-already-merging", 61 "/tmp/test-merge-to-branch-tempfile-already-merging",
63 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", 62 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES",
64 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch", 63 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch",
65 } 64 }
66 65
67 66 AUTO_ROLL_ARGS = [
68 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None, a=None, 67 "-a", "author@chromium.org",
69 status_password=None, revert_bleeding_edge=None, p=None): 68 "-c", TEST_CONFIG[CHROMIUM],
70 """Convenience wrapper.""" 69 "-r", "reviewer@chromium.org",
71 class Options(object): 70 ]
72 pass
73 options = Options()
74 options.s = s
75 options.l = l
76 options.f = f
77 options.m = m
78 options.reviewer = r
79 options.c = c
80 options.a = a
81 options.p = p
82 options.status_password = status_password
83 options.revert_bleeding_edge = revert_bleeding_edge
84 return options
85 71
86 72
87 class ToplevelTest(unittest.TestCase): 73 class ToplevelTest(unittest.TestCase):
88 def testMakeComment(self): 74 def testMakeComment(self):
89 self.assertEquals("# Line 1\n# Line 2\n#", 75 self.assertEquals("# Line 1\n# Line 2\n#",
90 MakeComment(" Line 1\n Line 2\n")) 76 MakeComment(" Line 1\n Line 2\n"))
91 self.assertEquals("#Line 1\n#Line 2", 77 self.assertEquals("#Line 1\n#Line 2",
92 MakeComment("Line 1\n Line 2")) 78 MakeComment("Line 1\n Line 2"))
93 79
94 def testStripComments(self): 80 def testStripComments(self):
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 f.write(" // Some line...\n") 274 f.write(" // Some line...\n")
289 f.write("\n") 275 f.write("\n")
290 f.write("#define MAJOR_VERSION 3\n") 276 f.write("#define MAJOR_VERSION 3\n")
291 f.write("#define MINOR_VERSION 22\n") 277 f.write("#define MINOR_VERSION 22\n")
292 f.write("#define BUILD_NUMBER 5\n") 278 f.write("#define BUILD_NUMBER 5\n")
293 f.write("#define PATCH_LEVEL 0\n") 279 f.write("#define PATCH_LEVEL 0\n")
294 f.write(" // Some line...\n") 280 f.write(" // Some line...\n")
295 f.write("#define IS_CANDIDATE_VERSION 0\n") 281 f.write("#define IS_CANDIDATE_VERSION 0\n")
296 return name 282 return name
297 283
298 def MakeStep(self, step_class=Step, state=None, options=None): 284 def MakeStep(self):
299 """Convenience wrapper.""" 285 """Convenience wrapper."""
300 options = options or CommonOptions(MakeOptions()) 286 options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([])
301 state = state if state is not None else self._state 287 return MakeStep(step_class=Step, state=self._state,
302 return MakeStep(step_class=step_class, number=0, state=state, 288 config=TEST_CONFIG, side_effect_handler=self,
303 config=TEST_CONFIG, options=options, 289 options=options)
304 side_effect_handler=self) 290
291 def RunStep(self, script=PushToTrunk, step_class=Step, args=None):
292 """Convenience wrapper."""
293 args = args or ["-m"]
294 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args)
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,
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after
476 ["log -1 --format=%an rev4", "author4@chromium.org"], 466 ["log -1 --format=%an rev4", "author4@chromium.org"],
477 ]) 467 ])
478 468
479 # The cl for rev4 on rietveld has an updated LOG flag. 469 # The cl for rev4 on rietveld has an updated LOG flag.
480 self.ExpectReadURL([ 470 self.ExpectReadURL([
481 ["https://codereview.chromium.org/9876543210/description", 471 ["https://codereview.chromium.org/9876543210/description",
482 "Title\n\nBUG=456\nLOG=N\n\n"], 472 "Title\n\nBUG=456\nLOG=N\n\n"],
483 ]) 473 ])
484 474
485 self._state["last_push_bleeding_edge"] = "1234" 475 self._state["last_push_bleeding_edge"] = "1234"
486 self.MakeStep(PrepareChangeLog).Run() 476 self.RunStep(PushToTrunk, PrepareChangeLog)
487 477
488 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 478 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
489 479
490 expected_cl = """1999-07-31: Version 3.22.5 480 expected_cl = """1999-07-31: Version 3.22.5
491 481
492 Title text 1. 482 Title text 1.
493 483
494 Title text 3 (Chromium issue 321). 484 Title text 3 (Chromium issue 321).
495 485
496 Performance and stability improvements on all platforms. 486 Performance and stability improvements on all platforms.
(...skipping 26 matching lines...) Expand all
523 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 513 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
524 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 514 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
525 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) 515 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE])
526 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 516 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE])
527 os.environ["EDITOR"] = "vi" 517 os.environ["EDITOR"] = "vi"
528 518
529 self.ExpectReadline([ 519 self.ExpectReadline([
530 "", # Open editor. 520 "", # Open editor.
531 ]) 521 ])
532 522
533 self.MakeStep(EditChangeLog).Run() 523 self.RunStep(PushToTrunk, EditChangeLog)
534
535 self.assertEquals("New\n Lines\n\n\n Original CL", 524 self.assertEquals("New\n Lines\n\n\n Original CL",
536 FileToText(TEST_CONFIG[CHANGELOG_FILE])) 525 FileToText(TEST_CONFIG[CHANGELOG_FILE]))
537 526
538 def testIncrementVersion(self): 527 def testIncrementVersion(self):
539 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 528 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
540 self._state["build"] = "5" 529 self._state["build"] = "5"
541 530
542 self.ExpectReadline([ 531 self.ExpectReadline([
543 "Y", # Increment build number. 532 "Y", # Increment build number.
544 ]) 533 ])
545 534
546 self.MakeStep(IncrementVersion).Run() 535 self.RunStep(PushToTrunk, IncrementVersion)
547
548 self.assertEquals("3", self._state["new_major"]) 536 self.assertEquals("3", self._state["new_major"])
549 self.assertEquals("22", self._state["new_minor"]) 537 self.assertEquals("22", self._state["new_minor"])
550 self.assertEquals("6", self._state["new_build"]) 538 self.assertEquals("6", self._state["new_build"])
551 self.assertEquals("0", self._state["new_patch"]) 539 self.assertEquals("0", self._state["new_patch"])
552 540
553 def testLastChangeLogEntries(self): 541 def testLastChangeLogEntries(self):
554 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 542 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
555 l = """ 543 l = """
556 Fixed something. 544 Fixed something.
557 (issue 1234)\n""" 545 (issue 1234)\n"""
(...skipping 14 matching lines...) Expand all
572 f.write(change_log) 560 f.write(change_log)
573 561
574 self.ExpectGit([ 562 self.ExpectGit([
575 ["diff svn/trunk hash1", "patch content"], 563 ["diff svn/trunk hash1", "patch content"],
576 ["svn find-rev hash1", "123455\n"], 564 ["svn find-rev hash1", "123455\n"],
577 ]) 565 ])
578 566
579 self._state["prepare_commit_hash"] = "hash1" 567 self._state["prepare_commit_hash"] = "hash1"
580 self._state["date"] = "1999-11-11" 568 self._state["date"] = "1999-11-11"
581 569
582 self.MakeStep(SquashCommits).Run() 570 self.RunStep(PushToTrunk, SquashCommits)
583 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg) 571 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg)
584 572
585 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) 573 patch = FileToText(TEST_CONFIG[ PATCH_FILE])
586 self.assertTrue(re.search(r"patch content", patch)) 574 self.assertTrue(re.search(r"patch content", patch))
587 575
588 def testSquashCommitsUnformatted(self): 576 def testSquashCommitsUnformatted(self):
589 change_log = """1999-11-11: Version 3.22.5 577 change_log = """1999-11-11: Version 3.22.5
590 578
591 Log text 1. 579 Log text 1.
592 Chromium issue 12345 580 Chromium issue 12345
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 args = ["-a", "author@chromium.org", "-c", TEST_CONFIG[CHROMIUM]]
744 r="reviewer@chromium.org" if not manual else None, 732 if force: args.append("-f")
745 c = TEST_CONFIG[CHROMIUM]) 733 if manual: args.append("-m")
746 RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self) 734 else: args += ["-r", "reviewer@chromium.org"]
735 PushToTrunk(TEST_CONFIG, self).Run(args)
747 736
748 deps = FileToText(TEST_CONFIG[DEPS_FILE]) 737 deps = FileToText(TEST_CONFIG[DEPS_FILE])
749 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) 738 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps))
750 739
751 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) 740 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
752 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) 741 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)) 742 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl))
754 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) 743 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl))
755 744
756 # Note: The version file is on build number 5 again in the end of this test 745 # Note: The version file is on build number 5 again in the end of this test
757 # since the git command that merges to the bleeding edge branch is mocked 746 # since the git command that merges to the bleeding edge branch is mocked
758 # out. 747 # out.
759 748
760 def testPushToTrunkManual(self): 749 def testPushToTrunkManual(self):
761 self._PushToTrunk(manual=True) 750 self._PushToTrunk(manual=True)
762 751
763 def testPushToTrunkSemiAutomatic(self): 752 def testPushToTrunkSemiAutomatic(self):
764 self._PushToTrunk() 753 self._PushToTrunk()
765 754
766 def testPushToTrunkForced(self): 755 def testPushToTrunkForced(self):
767 self._PushToTrunk(force=True) 756 self._PushToTrunk(force=True)
768 757
769 def testCheckLastPushRecently(self): 758 def testCheckLastPushRecently(self):
770 self.ExpectGit([ 759 self.ExpectGit([
771 ["svn log -1 --oneline", "r101 | Text"], 760 ["svn log -1 --oneline", "r101 | Text"],
772 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], 761 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."],
773 ]) 762 ])
774 763
775 state = {} 764 self.RunStep(auto_roll.AutoRoll, FetchLatestRevision, AUTO_ROLL_ARGS)
776 self.MakeStep(FetchLatestRevision, state=state).Run() 765 self.assertRaises(Exception, lambda: self.RunStep(auto_roll.AutoRoll,
777 self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run) 766 CheckLastPush,
767 AUTO_ROLL_ARGS))
778 768
779 def testAutoRoll(self): 769 def testAutoRoll(self):
780 status_password = self.MakeEmptyTempFile() 770 password = self.MakeEmptyTempFile()
781 TextToFile("PW", status_password) 771 TextToFile("PW", password)
782 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 772 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
783 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" 773 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist"
784 774
785 self.ExpectReadURL([ 775 self.ExpectReadURL([
786 ["https://v8-status.appspot.com/current?format=json", 776 ["https://v8-status.appspot.com/current?format=json",
787 "{\"message\": \"Tree is throttled\"}"], 777 "{\"message\": \"Tree is throttled\"}"],
788 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], 778 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")],
789 ["https://v8-status.appspot.com/lkgr", "100"], 779 ["https://v8-status.appspot.com/lkgr", "100"],
790 ["https://v8-status.appspot.com/status", 780 ["https://v8-status.appspot.com/status",
791 ("username=v8-auto-roll%40chromium.org&" 781 ("username=v8-auto-roll%40chromium.org&"
792 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), 782 "message=Tree+is+closed+%28preparing+to+push%29&password=PW"),
793 ""], 783 ""],
794 ["https://v8-status.appspot.com/status", 784 ["https://v8-status.appspot.com/status",
795 ("username=v8-auto-roll%40chromium.org&" 785 ("username=v8-auto-roll%40chromium.org&"
796 "message=Tree+is+throttled&password=PW"), ""], 786 "message=Tree+is+throttled&password=PW"), ""],
797 ]) 787 ])
798 788
799 self.ExpectGit([ 789 self.ExpectGit([
800 ["status -s -uno", ""], 790 ["status -s -uno", ""],
801 ["status -s -b -uno", "## some_branch\n"], 791 ["status -s -b -uno", "## some_branch\n"],
802 ["svn fetch", ""], 792 ["svn fetch", ""],
803 ["svn log -1 --oneline", "r100 | Text"], 793 ["svn log -1 --oneline", "r100 | Text"],
804 [("log -1 --format=%H --grep=\"" 794 [("log -1 --format=%H --grep=\""
805 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" 795 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\""
806 " svn/trunk"), "push_hash\n"], 796 " svn/trunk"), "push_hash\n"],
807 ["svn find-rev push_hash", "65"], 797 ["svn find-rev push_hash", "65"],
808 ]) 798 ])
809 799
810 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions( 800 auto_roll.AutoRoll(TEST_CONFIG, self).Run(
811 MakeOptions(status_password=status_password)), self) 801 AUTO_ROLL_ARGS + ["--status-password", password])
812 802
813 state = json.loads(FileToText("%s-state.json" 803 state = json.loads(FileToText("%s-state.json"
814 % TEST_CONFIG[PERSISTFILE_BASENAME])) 804 % TEST_CONFIG[PERSISTFILE_BASENAME]))
815 805
816 self.assertEquals("100", state["lkgr"]) 806 self.assertEquals("100", state["lkgr"])
817 self.assertEquals("100", state["latest"]) 807 self.assertEquals("100", state["latest"])
818 808
819 def testAutoRollStoppedBySettings(self): 809 def testAutoRollStoppedBySettings(self):
820 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 810 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
821 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() 811 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile()
822 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) 812 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION])
823 813
824 self.ExpectReadURL([]) 814 self.ExpectReadURL([])
825 815
826 self.ExpectGit([ 816 self.ExpectGit([
827 ["status -s -uno", ""], 817 ["status -s -uno", ""],
828 ["status -s -b -uno", "## some_branch\n"], 818 ["status -s -b -uno", "## some_branch\n"],
829 ["svn fetch", ""], 819 ["svn fetch", ""],
830 ]) 820 ])
831 821
832 def RunAutoRoll(): 822 def RunAutoRoll():
833 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) 823 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS)
834 self.assertRaises(Exception, RunAutoRoll) 824 self.assertRaises(Exception, RunAutoRoll)
835 825
836 def testAutoRollStoppedByTreeStatus(self): 826 def testAutoRollStoppedByTreeStatus(self):
837 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 827 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
838 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" 828 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist"
839 829
840 self.ExpectReadURL([ 830 self.ExpectReadURL([
841 ["https://v8-status.appspot.com/current?format=json", 831 ["https://v8-status.appspot.com/current?format=json",
842 "{\"message\": \"Tree is throttled (no push)\"}"], 832 "{\"message\": \"Tree is throttled (no push)\"}"],
843 ]) 833 ])
844 834
845 self.ExpectGit([ 835 self.ExpectGit([
846 ["status -s -uno", ""], 836 ["status -s -uno", ""],
847 ["status -s -b -uno", "## some_branch\n"], 837 ["status -s -b -uno", "## some_branch\n"],
848 ["svn fetch", ""], 838 ["svn fetch", ""],
849 ]) 839 ])
850 840
851 def RunAutoRoll(): 841 def RunAutoRoll():
852 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) 842 auto_roll.AutoRoll(TEST_CONFIG, self).Run(AUTO_ROLL_ARGS)
853 self.assertRaises(Exception, RunAutoRoll) 843 self.assertRaises(Exception, RunAutoRoll)
854 844
855 def testMergeToBranch(self): 845 def testMergeToBranch(self):
856 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile() 846 TEST_CONFIG[ALREADY_MERGING_SENTINEL_FILE] = self.MakeEmptyTempFile()
857 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 847 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
858 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 848 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
859 os.environ["EDITOR"] = "vi" 849 os.environ["EDITOR"] = "vi"
860 extra_patch = self.MakeEmptyTempFile() 850 extra_patch = self.MakeEmptyTempFile()
861 851
862 def VerifyPatch(patch): 852 def VerifyPatch(patch):
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
959 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], 949 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""],
960 ]) 950 ])
961 951
962 self.ExpectReadline([ 952 self.ExpectReadline([
963 "Y", # Automatically add corresponding ports (34567, 56789)? 953 "Y", # Automatically add corresponding ports (34567, 56789)?
964 "Y", # Automatically increment patch level? 954 "Y", # Automatically increment patch level?
965 "reviewer@chromium.org", # V8 reviewer. 955 "reviewer@chromium.org", # V8 reviewer.
966 "LGTM", # Enter LGTM for V8 CL. 956 "LGTM", # Enter LGTM for V8 CL.
967 ]) 957 ])
968 958
969 options = MakeOptions(p=extra_patch, f=True)
970 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS 959 # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS
971 # ports of r12345. r56789 is the MIPS port of r34567. 960 # ports of r12345. r56789 is the MIPS port of r34567.
972 args = ["trunk", "12345", "23456", "34567"] 961 args = ["-f", "-p", extra_patch, "--branch", "trunk", "12345", "23456",
973 self.assertTrue(merge_to_branch.ProcessOptions(options, args)) 962 "34567"]
974 963
975 # The first run of the script stops because of the svn being down. 964 # The first run of the script stops because of the svn being down.
976 self.assertRaises(GitFailedException, 965 self.assertRaises(GitFailedException,
977 lambda: RunMergeToBranch(TEST_CONFIG, 966 lambda: MergeToBranch(TEST_CONFIG, self).Run(args))
978 MergeToBranchOptions(options, args),
979 self))
980 967
981 # Test that state recovery after restarting the script works. 968 # Test that state recovery after restarting the script works.
982 options.s = 3 969 args += ["-s", "3"]
983 RunMergeToBranch(TEST_CONFIG, MergeToBranchOptions(options, args), self) 970 MergeToBranch(TEST_CONFIG, self).Run(args)
984 971
985 972
986 class SystemTest(unittest.TestCase): 973 class SystemTest(unittest.TestCase):
987 def testReload(self): 974 def testReload(self):
988 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, 975 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={},
989 options=CommonOptions(MakeOptions()),
990 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) 976 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER)
991 body = step.Reload( 977 body = step.Reload(
992 """------------------------------------------------------------------------ 978 """------------------------------------------------------------------------
993 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines 979 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines
994 980
995 Prepare push to trunk. Now working on version 3.23.11. 981 Prepare push to trunk. Now working on version 3.23.11.
996 982
997 R=danno@chromium.org 983 R=danno@chromium.org
998 984
999 Review URL: https://codereview.chromium.org/83173002 985 Review URL: https://codereview.chromium.org/83173002
1000 986
1001 ------------------------------------------------------------------------""") 987 ------------------------------------------------------------------------""")
1002 self.assertEquals( 988 self.assertEquals(
1003 """Prepare push to trunk. Now working on version 3.23.11. 989 """Prepare push to trunk. Now working on version 3.23.11.
1004 990
1005 R=danno@chromium.org 991 R=danno@chromium.org
1006 992
1007 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) 993 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') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698