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

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

Issue 873213002: Clean up release scripts. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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
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 27 matching lines...) Expand all
38 import common_includes 38 import common_includes
39 from common_includes import * 39 from common_includes import *
40 import merge_to_branch 40 import merge_to_branch
41 from merge_to_branch import * 41 from merge_to_branch import *
42 import push_to_trunk 42 import push_to_trunk
43 from push_to_trunk import * 43 from push_to_trunk import *
44 import chromium_roll 44 import chromium_roll
45 from chromium_roll import ChromiumRoll 45 from chromium_roll import ChromiumRoll
46 import releases 46 import releases
47 from releases import Releases 47 from releases import Releases
48 import bump_up_version
49 from bump_up_version import BumpUpVersion
50 from bump_up_version import LastChangeBailout
51 from bump_up_version import LKGRVersionUpToDateBailout
52 from auto_tag import AutoTag 48 from auto_tag import AutoTag
53 49
54 50
55 TEST_CONFIG = { 51 TEST_CONFIG = {
56 "DEFAULT_CWD": None, 52 "DEFAULT_CWD": None,
57 "BRANCHNAME": "test-prepare-push", 53 "BRANCHNAME": "test-prepare-push",
58 "TRUNKBRANCH": "test-trunk-push", 54 "CANDIDATESBRANCH": "test-candidates-push",
59 "PERSISTFILE_BASENAME": "/tmp/test-v8-push-to-trunk-tempfile", 55 "PERSISTFILE_BASENAME": "/tmp/test-v8-push-to-candidates-tempfile",
60 "CHANGELOG_ENTRY_FILE": "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", 56 "CHANGELOG_ENTRY_FILE":
61 "PATCH_FILE": "/tmp/test-v8-push-to-trunk-tempfile-patch", 57 "/tmp/test-v8-push-to-candidates-tempfile-changelog-entry",
62 "COMMITMSG_FILE": "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", 58 "PATCH_FILE": "/tmp/test-v8-push-to-candidates-tempfile-patch",
63 "CHROMIUM": "/tmp/test-v8-push-to-trunk-tempfile-chromium", 59 "COMMITMSG_FILE": "/tmp/test-v8-push-to-candidates-tempfile-commitmsg",
60 "CHROMIUM": "/tmp/test-v8-push-to-candidates-tempfile-chromium",
64 "SETTINGS_LOCATION": None, 61 "SETTINGS_LOCATION": None,
65 "ALREADY_MERGING_SENTINEL_FILE": 62 "ALREADY_MERGING_SENTINEL_FILE":
66 "/tmp/test-merge-to-branch-tempfile-already-merging", 63 "/tmp/test-merge-to-branch-tempfile-already-merging",
67 "TEMPORARY_PATCH_FILE": "/tmp/test-merge-to-branch-tempfile-temporary-patch", 64 "TEMPORARY_PATCH_FILE": "/tmp/test-merge-to-branch-tempfile-temporary-patch",
68 "CLUSTERFUZZ_API_KEY_FILE": "/tmp/test-fake-cf-api-key", 65 "CLUSTERFUZZ_API_KEY_FILE": "/tmp/test-fake-cf-api-key",
69 } 66 }
70 67
71 68
72 AUTO_PUSH_ARGS = [ 69 AUTO_PUSH_ARGS = [
73 "-a", "author@chromium.org", 70 "-a", "author@chromium.org",
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 f.write(" // Some line...\n") 366 f.write(" // Some line...\n")
370 f.write("#define IS_CANDIDATE_VERSION 0\n") 367 f.write("#define IS_CANDIDATE_VERSION 0\n")
371 368
372 def MakeStep(self): 369 def MakeStep(self):
373 """Convenience wrapper.""" 370 """Convenience wrapper."""
374 options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([]) 371 options = ScriptsBase(TEST_CONFIG, self, self._state).MakeOptions([])
375 return MakeStep(step_class=Step, state=self._state, 372 return MakeStep(step_class=Step, state=self._state,
376 config=TEST_CONFIG, side_effect_handler=self, 373 config=TEST_CONFIG, side_effect_handler=self,
377 options=options) 374 options=options)
378 375
379 def RunStep(self, script=PushToTrunk, step_class=Step, args=None): 376 def RunStep(self, script=PushToCandidates, step_class=Step, args=None):
380 """Convenience wrapper.""" 377 """Convenience wrapper."""
381 args = args if args is not None else ["-m"] 378 args = args if args is not None else ["-m"]
382 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args) 379 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args)
383 380
384 def Call(self, fun, *args, **kwargs): 381 def Call(self, fun, *args, **kwargs):
385 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs)) 382 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs))
386 383
387 def Command(self, cmd, args="", prefix="", pipe=True, cwd=None): 384 def Command(self, cmd, args="", prefix="", pipe=True, cwd=None):
388 print "%s %s" % (cmd, args) 385 print "%s %s" % (cmd, args)
389 print "in %s" % cwd 386 print "in %s" % cwd
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", 530 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
534 r"\g<space>3", 531 r"\g<space>3",
535 "//\n#define BUILD_NUMBER 321\n")) 532 "//\n#define BUILD_NUMBER 321\n"))
536 533
537 def testPreparePushRevision(self): 534 def testPreparePushRevision(self):
538 # Tests the default push hash used when the --revision option is not set. 535 # Tests the default push hash used when the --revision option is not set.
539 self.Expect([ 536 self.Expect([
540 Cmd("git log -1 --format=%H HEAD", "push_hash") 537 Cmd("git log -1 --format=%H HEAD", "push_hash")
541 ]) 538 ])
542 539
543 self.RunStep(PushToTrunk, PreparePushRevision) 540 self.RunStep(PushToCandidates, PreparePushRevision)
544 self.assertEquals("push_hash", self._state["push_hash"]) 541 self.assertEquals("push_hash", self._state["push_hash"])
545 542
546 def testPrepareChangeLog(self): 543 def testPrepareChangeLog(self):
547 self.WriteFakeVersionFile() 544 self.WriteFakeVersionFile()
548 TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile() 545 TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
549 546
550 self.Expect([ 547 self.Expect([
551 Cmd("git log --format=%H 1234..push_hash", "rev1\nrev2\nrev3\nrev4"), 548 Cmd("git log --format=%H 1234..push_hash", "rev1\nrev2\nrev3\nrev4"),
552 Cmd("git log -1 --format=%s rev1", "Title text 1"), 549 Cmd("git log -1 --format=%s rev1", "Title text 1"),
553 Cmd("git log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"), 550 Cmd("git log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"),
554 Cmd("git log -1 --format=%an rev1", "author1@chromium.org"), 551 Cmd("git log -1 --format=%an rev1", "author1@chromium.org"),
555 Cmd("git log -1 --format=%s rev2", "Title text 2."), 552 Cmd("git log -1 --format=%s rev2", "Title text 2."),
556 Cmd("git log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"), 553 Cmd("git log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"),
557 Cmd("git log -1 --format=%an rev2", "author2@chromium.org"), 554 Cmd("git log -1 --format=%an rev2", "author2@chromium.org"),
558 Cmd("git log -1 --format=%s rev3", "Title text 3"), 555 Cmd("git log -1 --format=%s rev3", "Title text 3"),
559 Cmd("git log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"), 556 Cmd("git log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"),
560 Cmd("git log -1 --format=%an rev3", "author3@chromium.org"), 557 Cmd("git log -1 --format=%an rev3", "author3@chromium.org"),
561 Cmd("git log -1 --format=%s rev4", "Title text 4"), 558 Cmd("git log -1 --format=%s rev4", "Title text 4"),
562 Cmd("git log -1 --format=%B rev4", 559 Cmd("git log -1 --format=%B rev4",
563 ("Title\n\nBUG=456\nLOG=Y\n\n" 560 ("Title\n\nBUG=456\nLOG=Y\n\n"
564 "Review URL: https://codereview.chromium.org/9876543210\n")), 561 "Review URL: https://codereview.chromium.org/9876543210\n")),
565 URL("https://codereview.chromium.org/9876543210/description", 562 URL("https://codereview.chromium.org/9876543210/description",
566 "Title\n\nBUG=456\nLOG=N\n\n"), 563 "Title\n\nBUG=456\nLOG=N\n\n"),
567 Cmd("git log -1 --format=%an rev4", "author4@chromium.org"), 564 Cmd("git log -1 --format=%an rev4", "author4@chromium.org"),
568 ]) 565 ])
569 566
570 self._state["last_push_bleeding_edge"] = "1234" 567 self._state["last_push_master"] = "1234"
571 self._state["push_hash"] = "push_hash" 568 self._state["push_hash"] = "push_hash"
572 self._state["version"] = "3.22.5" 569 self._state["version"] = "3.22.5"
573 self.RunStep(PushToTrunk, PrepareChangeLog) 570 self.RunStep(PushToCandidates, PrepareChangeLog)
574 571
575 actual_cl = FileToText(TEST_CONFIG["CHANGELOG_ENTRY_FILE"]) 572 actual_cl = FileToText(TEST_CONFIG["CHANGELOG_ENTRY_FILE"])
576 573
577 expected_cl = """1999-07-31: Version 3.22.5 574 expected_cl = """1999-07-31: Version 3.22.5
578 575
579 Title text 1. 576 Title text 1.
580 577
581 Title text 3 (Chromium issue 321). 578 Title text 3 (Chromium issue 321).
582 579
583 Performance and stability improvements on all platforms. 580 Performance and stability improvements on all platforms.
(...skipping 20 matching lines...) Expand all
604 601
605 def testEditChangeLog(self): 602 def testEditChangeLog(self):
606 TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile() 603 TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
607 TextToFile(" New \n\tLines \n", TEST_CONFIG["CHANGELOG_ENTRY_FILE"]) 604 TextToFile(" New \n\tLines \n", TEST_CONFIG["CHANGELOG_ENTRY_FILE"])
608 os.environ["EDITOR"] = "vi" 605 os.environ["EDITOR"] = "vi"
609 self.Expect([ 606 self.Expect([
610 RL(""), # Open editor. 607 RL(""), # Open editor.
611 Cmd("vi %s" % TEST_CONFIG["CHANGELOG_ENTRY_FILE"], ""), 608 Cmd("vi %s" % TEST_CONFIG["CHANGELOG_ENTRY_FILE"], ""),
612 ]) 609 ])
613 610
614 self.RunStep(PushToTrunk, EditChangeLog) 611 self.RunStep(PushToCandidates, EditChangeLog)
615 612
616 self.assertEquals("New\n Lines", 613 self.assertEquals("New\n Lines",
617 FileToText(TEST_CONFIG["CHANGELOG_ENTRY_FILE"])) 614 FileToText(TEST_CONFIG["CHANGELOG_ENTRY_FILE"]))
618 615
619 TAGS = """ 616 TAGS = """
620 4425.0 617 4425.0
621 0.0.0.0 618 0.0.0.0
622 3.9.6 619 3.9.6
623 3.22.4 620 3.22.4
624 test_tag 621 test_tag
625 """ 622 """
626 623
627 # Version as tag: 3.22.4.0. Version on master: 3.22.6. 624 # Version as tag: 3.22.4.0. Version on master: 3.22.6.
628 # Make sure that the latest version is 3.22.6.0. 625 # Make sure that the latest version is 3.22.6.0.
629 def testGetLatestVersion(self): 626 def testGetLatestVersion(self):
630 self.Expect([ 627 self.Expect([
631 Cmd("git tag", self.TAGS), 628 Cmd("git tag", self.TAGS),
632 Cmd("git checkout -f origin/master -- src/version.cc", 629 Cmd("git checkout -f origin/master -- src/version.cc",
633 "", cb=lambda: self.WriteFakeVersionFile(22, 6)), 630 "", cb=lambda: self.WriteFakeVersionFile(22, 6)),
634 ]) 631 ])
635 632
636 self.RunStep(PushToTrunk, GetLatestVersion) 633 self.RunStep(PushToCandidates, GetLatestVersion)
637 634
638 self.assertEquals("3", self._state["latest_major"]) 635 self.assertEquals("3", self._state["latest_major"])
639 self.assertEquals("22", self._state["latest_minor"]) 636 self.assertEquals("22", self._state["latest_minor"])
640 self.assertEquals("6", self._state["latest_build"]) 637 self.assertEquals("6", self._state["latest_build"])
641 self.assertEquals("0", self._state["latest_patch"]) 638 self.assertEquals("0", self._state["latest_patch"])
642 639
643 def _TestSquashCommits(self, change_log, expected_msg): 640 def _TestSquashCommits(self, change_log, expected_msg):
644 TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile() 641 TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
645 with open(TEST_CONFIG["CHANGELOG_ENTRY_FILE"], "w") as f: 642 with open(TEST_CONFIG["CHANGELOG_ENTRY_FILE"], "w") as f:
646 f.write(change_log) 643 f.write(change_log)
647 644
648 self.Expect([ 645 self.Expect([
649 Cmd("git diff origin/candidates hash1", "patch content"), 646 Cmd("git diff origin/candidates hash1", "patch content"),
650 ]) 647 ])
651 648
652 self._state["push_hash"] = "hash1" 649 self._state["push_hash"] = "hash1"
653 self._state["date"] = "1999-11-11" 650 self._state["date"] = "1999-11-11"
654 651
655 self.RunStep(PushToTrunk, SquashCommits) 652 self.RunStep(PushToCandidates, SquashCommits)
656 self.assertEquals(FileToText(TEST_CONFIG["COMMITMSG_FILE"]), expected_msg) 653 self.assertEquals(FileToText(TEST_CONFIG["COMMITMSG_FILE"]), expected_msg)
657 654
658 patch = FileToText(TEST_CONFIG["PATCH_FILE"]) 655 patch = FileToText(TEST_CONFIG["PATCH_FILE"])
659 self.assertTrue(re.search(r"patch content", patch)) 656 self.assertTrue(re.search(r"patch content", patch))
660 657
661 def testSquashCommitsUnformatted(self): 658 def testSquashCommitsUnformatted(self):
662 change_log = """1999-11-11: Version 3.22.5 659 change_log = """1999-11-11: Version 3.22.5
663 660
664 Log text 1. 661 Log text 1.
665 Chromium issue 12345 662 Chromium issue 12345
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
699 696
700 # Use the test configuration without the fake testing default work dir. 697 # Use the test configuration without the fake testing default work dir.
701 fake_config = dict(TEST_CONFIG) 698 fake_config = dict(TEST_CONFIG)
702 del(fake_config["DEFAULT_CWD"]) 699 del(fake_config["DEFAULT_CWD"])
703 700
704 self.Expect([ 701 self.Expect([
705 Cmd("fetch v8", "", cwd=work_dir), 702 Cmd("fetch v8", "", cwd=work_dir),
706 ]) 703 ])
707 FakeScript(fake_config, self).Run(["--work-dir", work_dir]) 704 FakeScript(fake_config, self).Run(["--work-dir", work_dir])
708 705
709 def _PushToTrunk(self, force=False, manual=False): 706 def _PushToCandidates(self, force=False, manual=False):
710 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git")) 707 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
711 708
712 # The version file on bleeding edge has build level 5, while the version 709 # The version file on master has build level 5, while the version
713 # file from trunk has build level 4. 710 # file from candidates has build level 4.
714 self.WriteFakeVersionFile(build=5) 711 self.WriteFakeVersionFile(build=5)
715 712
716 TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile() 713 TEST_CONFIG["CHANGELOG_ENTRY_FILE"] = self.MakeEmptyTempFile()
717 bleeding_edge_change_log = "2014-03-17: Sentinel\n" 714 master_change_log = "2014-03-17: Sentinel\n"
718 TextToFile(bleeding_edge_change_log, 715 TextToFile(master_change_log,
719 os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE)) 716 os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
720 os.environ["EDITOR"] = "vi" 717 os.environ["EDITOR"] = "vi"
721 718
722 commit_msg_squashed = """Version 3.22.5 (squashed - based on push_hash) 719 commit_msg_squashed = """Version 3.22.5 (squashed - based on push_hash)
723 720
724 Log text 1 (issue 321). 721 Log text 1 (issue 321).
725 722
726 Performance and stability improvements on all platforms.""" 723 Performance and stability improvements on all platforms."""
727 724
728 commit_msg = """Version 3.22.5 (based on push_hash) 725 commit_msg = """Version 3.22.5 (based on push_hash)
729 726
730 Log text 1 (issue 321). 727 Log text 1 (issue 321).
731 728
732 Performance and stability improvements on all platforms.""" 729 Performance and stability improvements on all platforms."""
733 730
734 def ResetChangeLog(): 731 def ResetChangeLog():
735 """On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog', 732 """On 'git co -b new_branch origin/candidates',
736 the ChangLog will be reset to its content on trunk.""" 733 and 'git checkout -- ChangeLog',
737 trunk_change_log = """1999-04-05: Version 3.22.4 734 the ChangLog will be reset to its content on candidates."""
735 candidates_change_log = """1999-04-05: Version 3.22.4
738 736
739 Performance and stability improvements on all platforms.\n""" 737 Performance and stability improvements on all platforms.\n"""
740 TextToFile(trunk_change_log, 738 TextToFile(candidates_change_log,
741 os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE)) 739 os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
742 740
743 def ResetToTrunk(): 741 def ResetToCandidates():
744 ResetChangeLog() 742 ResetChangeLog()
745 self.WriteFakeVersionFile() 743 self.WriteFakeVersionFile()
746 744
747 def CheckVersionCommit(): 745 def CheckVersionCommit():
748 commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"]) 746 commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
749 self.assertEquals(commit_msg, commit) 747 self.assertEquals(commit_msg, commit)
750 version = FileToText( 748 version = FileToText(
751 os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE)) 749 os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
752 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) 750 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
753 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) 751 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
754 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) 752 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version))
755 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) 753 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version))
756 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) 754 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
757 755
758 # Check that the change log on the trunk branch got correctly modified. 756 # Check that the change log on the candidates branch got correctly
757 # modified.
759 change_log = FileToText( 758 change_log = FileToText(
760 os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE)) 759 os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
761 self.assertEquals( 760 self.assertEquals(
762 """1999-07-31: Version 3.22.5 761 """1999-07-31: Version 3.22.5
763 762
764 Log text 1 (issue 321). 763 Log text 1 (issue 321).
765 764
766 Performance and stability improvements on all platforms. 765 Performance and stability improvements on all platforms.
767 766
768 767
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
806 if manual: 805 if manual:
807 expectations.append(RL("")) # Open editor. 806 expectations.append(RL("")) # Open editor.
808 if not force: 807 if not force:
809 expectations.append( 808 expectations.append(
810 Cmd("vi %s" % TEST_CONFIG["CHANGELOG_ENTRY_FILE"], "")) 809 Cmd("vi %s" % TEST_CONFIG["CHANGELOG_ENTRY_FILE"], ""))
811 expectations += [ 810 expectations += [
812 Cmd("git fetch", ""), 811 Cmd("git fetch", ""),
813 Cmd("git checkout -f origin/master", ""), 812 Cmd("git checkout -f origin/master", ""),
814 Cmd("git diff origin/candidates push_hash", "patch content\n"), 813 Cmd("git diff origin/candidates push_hash", "patch content\n"),
815 Cmd(("git new-branch %s --upstream origin/candidates" % 814 Cmd(("git new-branch %s --upstream origin/candidates" %
816 TEST_CONFIG["TRUNKBRANCH"]), "", cb=ResetToTrunk), 815 TEST_CONFIG["CANDIDATESBRANCH"]), "", cb=ResetToCandidates),
817 Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG["PATCH_FILE"], ""), 816 Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG["PATCH_FILE"], ""),
818 Cmd("git checkout -f origin/candidates -- ChangeLog", "", 817 Cmd("git checkout -f origin/candidates -- ChangeLog", "",
819 cb=ResetChangeLog), 818 cb=ResetChangeLog),
820 Cmd("git checkout -f origin/candidates -- src/version.cc", "", 819 Cmd("git checkout -f origin/candidates -- src/version.cc", "",
821 cb=self.WriteFakeVersionFile), 820 cb=self.WriteFakeVersionFile),
822 Cmd("git commit -am \"%s\"" % commit_msg_squashed, ""), 821 Cmd("git commit -am \"%s\"" % commit_msg_squashed, ""),
823 ] 822 ]
824 if manual: 823 if manual:
825 expectations.append(RL("Y")) # Sanity check. 824 expectations.append(RL("Y")) # Sanity check.
826 expectations += [ 825 expectations += [
827 Cmd("git cl land -f --bypass-hooks", ""), 826 Cmd("git cl land -f --bypass-hooks", ""),
828 Cmd("git checkout -f master", ""), 827 Cmd("git checkout -f master", ""),
829 Cmd("git fetch", ""), 828 Cmd("git fetch", ""),
830 Cmd("git branch -D %s" % TEST_CONFIG["TRUNKBRANCH"], ""), 829 Cmd("git branch -D %s" % TEST_CONFIG["CANDIDATESBRANCH"], ""),
831 Cmd(("git new-branch %s --upstream origin/candidates" % 830 Cmd(("git new-branch %s --upstream origin/candidates" %
832 TEST_CONFIG["TRUNKBRANCH"]), "", cb=ResetToTrunk), 831 TEST_CONFIG["CANDIDATESBRANCH"]), "", cb=ResetToCandidates),
833 Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], "", 832 Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], "",
834 cb=CheckVersionCommit), 833 cb=CheckVersionCommit),
835 Cmd("git cl land -f --bypass-hooks", ""), 834 Cmd("git cl land -f --bypass-hooks", ""),
836 Cmd("git fetch", ""), 835 Cmd("git fetch", ""),
837 Cmd("git log -1 --format=%H --grep=" 836 Cmd("git log -1 --format=%H --grep="
838 "\"Version 3.22.5 (based on push_hash)\"" 837 "\"Version 3.22.5 (based on push_hash)\""
839 " origin/candidates", "hsh_to_tag"), 838 " origin/candidates", "hsh_to_tag"),
840 Cmd("git tag 3.22.5 hsh_to_tag", ""), 839 Cmd("git tag 3.22.5 hsh_to_tag", ""),
841 Cmd("git push origin 3.22.5", ""), 840 Cmd("git push origin 3.22.5", ""),
842 Cmd("git checkout -f some_branch", ""), 841 Cmd("git checkout -f some_branch", ""),
843 Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""), 842 Cmd("git branch -D %s" % TEST_CONFIG["BRANCHNAME"], ""),
844 Cmd("git branch -D %s" % TEST_CONFIG["TRUNKBRANCH"], ""), 843 Cmd("git branch -D %s" % TEST_CONFIG["CANDIDATESBRANCH"], ""),
845 ] 844 ]
846 self.Expect(expectations) 845 self.Expect(expectations)
847 846
848 args = ["-a", "author@chromium.org", "--revision", "push_hash"] 847 args = ["-a", "author@chromium.org", "--revision", "push_hash"]
849 if force: args.append("-f") 848 if force: args.append("-f")
850 if manual: args.append("-m") 849 if manual: args.append("-m")
851 else: args += ["-r", "reviewer@chromium.org"] 850 else: args += ["-r", "reviewer@chromium.org"]
852 PushToTrunk(TEST_CONFIG, self).Run(args) 851 PushToCandidates(TEST_CONFIG, self).Run(args)
853 852
854 cl = FileToText(os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE)) 853 cl = FileToText(os.path.join(TEST_CONFIG["DEFAULT_CWD"], CHANGELOG_FILE))
855 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) 854 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl))
856 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) 855 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl))
857 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) 856 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl))
858 857
859 # Note: The version file is on build number 5 again in the end of this test 858 # Note: The version file is on build number 5 again in the end of this test
860 # since the git command that merges to the bleeding edge branch is mocked 859 # since the git command that merges to master is mocked out.
861 # out.
862 860
863 def testPushToTrunkManual(self): 861 def testPushToCandidatesManual(self):
864 self._PushToTrunk(manual=True) 862 self._PushToCandidates(manual=True)
865 863
866 def testPushToTrunkSemiAutomatic(self): 864 def testPushToCandidatesSemiAutomatic(self):
867 self._PushToTrunk() 865 self._PushToCandidates()
868 866
869 def testPushToTrunkForced(self): 867 def testPushToCandidatesForced(self):
870 self._PushToTrunk(force=True) 868 self._PushToCandidates(force=True)
871 869
872 C_V8_22624_LOG = """V8 CL. 870 C_V8_22624_LOG = """V8 CL.
873 871
874 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123 872 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@22624 123
875 873
876 """ 874 """
877 875
878 C_V8_123455_LOG = """V8 CL. 876 C_V8_123455_LOG = """V8 CL.
879 877
880 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@123455 123 878 git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@123455 123
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
952 Cmd("git log -1 --format=%s hash2", 950 Cmd("git log -1 --format=%s hash2",
953 "Version 3.4.5 (based on abc123)\n"), 951 "Version 3.4.5 (based on abc123)\n"),
954 ]) 952 ])
955 953
956 self._state["candidate"] = "abc123" 954 self._state["candidate"] = "abc123"
957 self.assertEquals(0, self.RunStep( 955 self.assertEquals(0, self.RunStep(
958 auto_push.AutoPush, CheckLastPush, AUTO_PUSH_ARGS)) 956 auto_push.AutoPush, CheckLastPush, AUTO_PUSH_ARGS))
959 957
960 def testAutoPush(self): 958 def testAutoPush(self):
961 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git")) 959 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
962 TEST_CONFIG["SETTINGS_LOCATION"] = "~/.doesnotexist"
963 960
964 self.Expect([ 961 self.Expect([
965 Cmd("git status -s -uno", ""), 962 Cmd("git status -s -uno", ""),
966 Cmd("git status -s -b -uno", "## some_branch\n"), 963 Cmd("git status -s -b -uno", "## some_branch\n"),
967 Cmd("git fetch", ""), 964 Cmd("git fetch", ""),
968 URL("https://v8-status.appspot.com/current?format=json",
969 "{\"message\": \"Tree is throttled\"}"),
970 Cmd("git fetch origin +refs/heads/candidate:refs/heads/candidate", ""), 965 Cmd("git fetch origin +refs/heads/candidate:refs/heads/candidate", ""),
971 Cmd("git show-ref -s refs/heads/candidate", "abc123\n"), 966 Cmd("git show-ref -s refs/heads/candidate", "abc123\n"),
972 Cmd(("git log -1 --format=%H --grep=\"" 967 Cmd(("git log -1 --format=%H --grep=\""
973 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" 968 "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\""
974 " origin/candidates"), "push_hash\n"), 969 " origin/candidates"), "push_hash\n"),
975 Cmd("git log -1 --format=%s push_hash", 970 Cmd("git log -1 --format=%s push_hash",
976 "Version 3.4.5 (based on abc101)\n"), 971 "Version 3.4.5 (based on abc101)\n"),
977 ]) 972 ])
978 973
979 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS + ["--push"]) 974 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS + ["--push"])
980 975
981 state = json.loads(FileToText("%s-state.json" 976 state = json.loads(FileToText("%s-state.json"
982 % TEST_CONFIG["PERSISTFILE_BASENAME"])) 977 % TEST_CONFIG["PERSISTFILE_BASENAME"]))
983 978
984 self.assertEquals("abc123", state["candidate"]) 979 self.assertEquals("abc123", state["candidate"])
985 980
986 def testAutoPushStoppedBySettings(self):
987 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
988 TEST_CONFIG["SETTINGS_LOCATION"] = self.MakeEmptyTempFile()
989 TextToFile("{\"enable_auto_push\": false}",
990 TEST_CONFIG["SETTINGS_LOCATION"])
991
992 self.Expect([
993 Cmd("git status -s -uno", ""),
994 Cmd("git status -s -b -uno", "## some_branch\n"),
995 Cmd("git fetch", ""),
996 ])
997
998 def RunAutoPush():
999 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS)
1000 self.assertRaises(Exception, RunAutoPush)
1001
1002 def testAutoPushStoppedByTreeStatus(self):
1003 TextToFile("", os.path.join(TEST_CONFIG["DEFAULT_CWD"], ".git"))
1004 TEST_CONFIG["SETTINGS_LOCATION"] = "~/.doesnotexist"
1005
1006 self.Expect([
1007 Cmd("git status -s -uno", ""),
1008 Cmd("git status -s -b -uno", "## some_branch\n"),
1009 Cmd("git fetch", ""),
1010 URL("https://v8-status.appspot.com/current?format=json",
1011 "{\"message\": \"Tree is throttled (no push)\"}"),
1012 ])
1013
1014 def RunAutoPush():
1015 auto_push.AutoPush(TEST_CONFIG, self).Run(AUTO_PUSH_ARGS)
1016 self.assertRaises(Exception, RunAutoPush)
1017
1018 def testAutoRollExistingRoll(self): 981 def testAutoRollExistingRoll(self):
1019 self.Expect([ 982 self.Expect([
1020 URL("https://codereview.chromium.org/search", 983 URL("https://codereview.chromium.org/search",
1021 "owner=author%40chromium.org&limit=30&closed=3&format=json", 984 "owner=author%40chromium.org&limit=30&closed=3&format=json",
1022 ("{\"results\": [{\"subject\": \"different\"}," 985 ("{\"results\": [{\"subject\": \"different\"},"
1023 "{\"subject\": \"Update V8 to Version...\"}]}")), 986 "{\"subject\": \"Update V8 to Version...\"}]}")),
1024 ]) 987 ])
1025 988
1026 result = auto_roll.AutoRoll(TEST_CONFIG, self).Run( 989 result = auto_roll.AutoRoll(TEST_CONFIG, self).Run(
1027 AUTO_PUSH_ARGS + ["-c", TEST_CONFIG["CHROMIUM"]]) 990 AUTO_PUSH_ARGS + ["-c", TEST_CONFIG["CHROMIUM"]])
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
1106 Title3 1069 Title3
1107 1070
1108 Title1 1071 Title1
1109 1072
1110 Revert "Something" 1073 Revert "Something"
1111 1074
1112 BUG=123,234,345,456,567,v8:123 1075 BUG=123,234,345,456,567,v8:123
1113 LOG=N 1076 LOG=N
1114 """ 1077 """
1115 1078
1116 def VerifySVNCommit(): 1079 def VerifyLand():
1117 commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"]) 1080 commit = FileToText(TEST_CONFIG["COMMITMSG_FILE"])
1118 self.assertEquals(msg, commit) 1081 self.assertEquals(msg, commit)
1119 version = FileToText( 1082 version = FileToText(
1120 os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE)) 1083 os.path.join(TEST_CONFIG["DEFAULT_CWD"], VERSION_FILE))
1121 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) 1084 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version))
1122 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) 1085 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version))
1123 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version)) 1086 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+1", version))
1124 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) 1087 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
1125 1088
1126 self.Expect([ 1089 self.Expect([
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
1179 Cmd("git apply --index --reject \"%s\"" % extra_patch, ""), 1142 Cmd("git apply --index --reject \"%s\"" % extra_patch, ""),
1180 RL("Y"), # Automatically increment patch level? 1143 RL("Y"), # Automatically increment patch level?
1181 Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], ""), 1144 Cmd("git commit -aF \"%s\"" % TEST_CONFIG["COMMITMSG_FILE"], ""),
1182 RL("reviewer@chromium.org"), # V8 reviewer. 1145 RL("reviewer@chromium.org"), # V8 reviewer.
1183 Cmd("git cl upload --send-mail -r \"reviewer@chromium.org\" " 1146 Cmd("git cl upload --send-mail -r \"reviewer@chromium.org\" "
1184 "--bypass-hooks --cc \"ulan@chromium.org\"", ""), 1147 "--bypass-hooks --cc \"ulan@chromium.org\"", ""),
1185 Cmd("git checkout -f %s" % TEST_CONFIG["BRANCHNAME"], ""), 1148 Cmd("git checkout -f %s" % TEST_CONFIG["BRANCHNAME"], ""),
1186 RL("LGTM"), # Enter LGTM for V8 CL. 1149 RL("LGTM"), # Enter LGTM for V8 CL.
1187 Cmd("git cl presubmit", "Presubmit successfull\n"), 1150 Cmd("git cl presubmit", "Presubmit successfull\n"),
1188 Cmd("git cl land -f --bypass-hooks", "Closing issue\n", 1151 Cmd("git cl land -f --bypass-hooks", "Closing issue\n",
1189 cb=VerifySVNCommit), 1152 cb=VerifyLand),
1190 Cmd("git fetch", ""), 1153 Cmd("git fetch", ""),
1191 Cmd("git log -1 --format=%H --grep=\"" 1154 Cmd("git log -1 --format=%H --grep=\""
1192 "Version 3.22.5.1 (cherry-pick)" 1155 "Version 3.22.5.1 (cherry-pick)"
1193 "\" origin/candidates", 1156 "\" origin/candidates",
1194 ""), 1157 ""),
1195 Cmd("git fetch", ""), 1158 Cmd("git fetch", ""),
1196 Cmd("git log -1 --format=%H --grep=\"" 1159 Cmd("git log -1 --format=%H --grep=\""
1197 "Version 3.22.5.1 (cherry-pick)" 1160 "Version 3.22.5.1 (cherry-pick)"
1198 "\" origin/candidates", 1161 "\" origin/candidates",
1199 "hsh_to_tag"), 1162 "hsh_to_tag"),
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after
1404 "branch": "3.3", 1367 "branch": "3.3",
1405 "review_link": "fake.com", 1368 "review_link": "fake.com",
1406 "date": "18:15", 1369 "date": "18:15",
1407 "chromium_branch": "", 1370 "chromium_branch": "",
1408 "revision_link": "https://code.google.com/p/v8/source/detail?r=234", 1371 "revision_link": "https://code.google.com/p/v8/source/detail?r=234",
1409 }, 1372 },
1410 ] 1373 ]
1411 self.assertEquals(expected_json, json.loads(FileToText(json_output))) 1374 self.assertEquals(expected_json, json.loads(FileToText(json_output)))
1412 1375
1413 1376
1414 def _bumpUpVersion(self):
1415 self.WriteFakeVersionFile()
1416
1417 def ResetVersion(minor, build, patch=0):
1418 return lambda: self.WriteFakeVersionFile(minor=minor,
1419 build=build,
1420 patch=patch)
1421
1422 return [
1423 Cmd("git status -s -uno", ""),
1424 Cmd("git checkout -f master", "", cb=ResetVersion(11, 4)),
1425 Cmd("git pull", ""),
1426 Cmd("git branch", ""),
1427 Cmd("git checkout -f master", ""),
1428 Cmd("git log -1 --format=%H", "latest_hash"),
1429 Cmd("git diff --name-only latest_hash latest_hash^", ""),
1430 URL("https://v8-status.appspot.com/lkgr", "12345"),
1431 Cmd("git checkout -f master", ""),
1432 Cmd(("git log --format=%H --grep="
1433 "\"^git-svn-id: [^@]*@12345 [A-Za-z0-9-]*$\""),
1434 "lkgr_hash"),
1435 Cmd("git new-branch auto-bump-up-version --upstream lkgr_hash", ""),
1436 Cmd("git checkout -f master", ""),
1437 Cmd("git branch", "auto-bump-up-version\n* master"),
1438 Cmd("git branch -D auto-bump-up-version", ""),
1439 Cmd("git diff --name-only lkgr_hash lkgr_hash^", ""),
1440 Cmd("git checkout -f candidates", "", cb=ResetVersion(11, 5)),
1441 Cmd("git pull", ""),
1442 URL("https://v8-status.appspot.com/current?format=json",
1443 "{\"message\": \"Tree is open\"}"),
1444 Cmd("git new-branch auto-bump-up-version --upstream master", "",
1445 cb=ResetVersion(11, 4)),
1446 Cmd("git commit -am \"[Auto-roll] Bump up version to 3.11.6.0\n\n"
1447 "TBR=author@chromium.org\" "
1448 "--author \"author@chromium.org <author@chromium.org>\"", ""),
1449 ]
1450
1451 def testBumpUpVersionGit(self):
1452 expectations = self._bumpUpVersion()
1453 expectations += [
1454 Cmd("git cl upload --send-mail --email \"author@chromium.org\" -f "
1455 "--bypass-hooks", ""),
1456 Cmd("git cl land -f --bypass-hooks", ""),
1457 Cmd("git checkout -f master", ""),
1458 Cmd("git branch", "auto-bump-up-version\n* master"),
1459 Cmd("git branch -D auto-bump-up-version", ""),
1460 ]
1461 self.Expect(expectations)
1462
1463 BumpUpVersion(TEST_CONFIG, self).Run(["-a", "author@chromium.org"])
1464
1465
1466 # Test that we bail out if the last change was a version change.
1467 def testBumpUpVersionBailout1(self):
1468 self._state["latest"] = "latest_hash"
1469
1470 self.Expect([
1471 Cmd("git diff --name-only latest_hash latest_hash^", VERSION_FILE),
1472 ])
1473
1474 self.assertEquals(0,
1475 self.RunStep(BumpUpVersion, LastChangeBailout, ["--dry_run"]))
1476
1477 # Test that we bail out if the lkgr was a version change.
1478 def testBumpUpVersionBailout2(self):
1479 self._state["lkgr"] = "lkgr_hash"
1480
1481 self.Expect([
1482 Cmd("git diff --name-only lkgr_hash lkgr_hash^", VERSION_FILE),
1483 ])
1484
1485 self.assertEquals(0,
1486 self.RunStep(BumpUpVersion, LKGRVersionUpToDateBailout, ["--dry_run"]))
1487
1488 # Test that we bail out if the last version is already newer than the lkgr's
1489 # version.
1490 def testBumpUpVersionBailout3(self):
1491 self._state["lkgr"] = "lkgr_hash"
1492 self._state["lkgr_version"] = "3.22.4.0"
1493 self._state["latest_version"] = "3.22.5.0"
1494
1495 self.Expect([
1496 Cmd("git diff --name-only lkgr_hash lkgr_hash^", ""),
1497 ])
1498
1499 self.assertEquals(0,
1500 self.RunStep(BumpUpVersion, LKGRVersionUpToDateBailout, ["--dry_run"]))
1501
1502
1503 class SystemTest(unittest.TestCase): 1377 class SystemTest(unittest.TestCase):
1504 def testReload(self): 1378 def testReload(self):
1505 options = ScriptsBase( 1379 options = ScriptsBase(
1506 TEST_CONFIG, DEFAULT_SIDE_EFFECT_HANDLER, {}).MakeOptions([]) 1380 TEST_CONFIG, DEFAULT_SIDE_EFFECT_HANDLER, {}).MakeOptions([])
1507 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, 1381 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={},
1508 options=options, 1382 options=options,
1509 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) 1383 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER)
1510 body = step.Reload( 1384 body = step.Reload(
1511 """------------------------------------------------------------------------ 1385 """------------------------------------------------------------------------
1512 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines 1386 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines
1513 1387
1514 Prepare push to trunk. Now working on version 3.23.11. 1388 Prepare push to trunk. Now working on version 3.23.11.
1515 1389
1516 R=danno@chromium.org 1390 R=danno@chromium.org
1517 1391
1518 Review URL: https://codereview.chromium.org/83173002 1392 Review URL: https://codereview.chromium.org/83173002
1519 1393
1520 ------------------------------------------------------------------------""") 1394 ------------------------------------------------------------------------""")
1521 self.assertEquals( 1395 self.assertEquals(
1522 """Prepare push to trunk. Now working on version 3.23.11. 1396 """Prepare push to trunk. Now working on version 3.23.11.
1523 1397
1524 R=danno@chromium.org 1398 R=danno@chromium.org
1525 1399
1526 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) 1400 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body)
OLDNEW
« tools/push-to-trunk/releases.py ('K') | « tools/push-to-trunk/releases.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698