| OLD | NEW |
| 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 20 matching lines...) Expand all Loading... |
| 31 import unittest | 31 import unittest |
| 32 | 32 |
| 33 import common_includes | 33 import common_includes |
| 34 from common_includes import * | 34 from common_includes import * |
| 35 import push_to_trunk | 35 import push_to_trunk |
| 36 from push_to_trunk import * | 36 from push_to_trunk import * |
| 37 import auto_roll | 37 import auto_roll |
| 38 from auto_roll import AutoRollOptions | 38 from auto_roll import AutoRollOptions |
| 39 from auto_roll import CheckLastPush | 39 from auto_roll import CheckLastPush |
| 40 from auto_roll import FetchLatestRevision | 40 from auto_roll import FetchLatestRevision |
| 41 from auto_roll import SETTINGS_LOCATION |
| 41 | 42 |
| 42 | 43 |
| 43 TEST_CONFIG = { | 44 TEST_CONFIG = { |
| 44 BRANCHNAME: "test-prepare-push", | 45 BRANCHNAME: "test-prepare-push", |
| 45 TRUNKBRANCH: "test-trunk-push", | 46 TRUNKBRANCH: "test-trunk-push", |
| 46 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", | 47 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", |
| 47 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", | 48 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", |
| 48 DOT_GIT_LOCATION: None, | 49 DOT_GIT_LOCATION: None, |
| 49 VERSION_FILE: None, | 50 VERSION_FILE: None, |
| 50 CHANGELOG_FILE: None, | 51 CHANGELOG_FILE: None, |
| 51 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", | 52 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", |
| 52 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", | 53 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", |
| 53 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", | 54 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", |
| 54 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", | 55 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", |
| 55 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", | 56 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", |
| 57 SETTINGS_LOCATION: None, |
| 56 } | 58 } |
| 57 | 59 |
| 58 | 60 |
| 59 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None): | 61 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None): |
| 60 """Convenience wrapper.""" | 62 """Convenience wrapper.""" |
| 61 class Options(object): | 63 class Options(object): |
| 62 pass | 64 pass |
| 63 options = Options() | 65 options = Options() |
| 64 options.s = s | 66 options.s = s |
| 65 options.l = l | 67 options.l = l |
| (...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 651 ["log 1234..HEAD --format=%H", "rev1\n"], | 653 ["log 1234..HEAD --format=%H", "rev1\n"], |
| 652 ["log -1 rev1 --format=\"%s\"", "Log text 1.\n"], | 654 ["log -1 rev1 --format=\"%s\"", "Log text 1.\n"], |
| 653 ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"], | 655 ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"], |
| 654 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org\n"], | 656 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org\n"], |
| 655 [("commit -a -m \"Prepare push to trunk. " | 657 [("commit -a -m \"Prepare push to trunk. " |
| 656 "Now working on version 3.22.6.%s\"" % review_suffix), | 658 "Now working on version 3.22.6.%s\"" % review_suffix), |
| 657 " 2 files changed\n", | 659 " 2 files changed\n", |
| 658 CheckPreparePush], | 660 CheckPreparePush], |
| 659 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag, | 661 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag, |
| 660 "done\n"], | 662 "done\n"], |
| 661 ["cl dcommit -f", "Closing issue\n"], | 663 ["cl presubmit", "Presubmit successfull\n"], |
| 664 ["cl dcommit -f --bypass-hooks", "Closing issue\n"], |
| 662 ["svn fetch", "fetch result\n"], | 665 ["svn fetch", "fetch result\n"], |
| 663 ["checkout svn/bleeding_edge", ""], | 666 ["checkout svn/bleeding_edge", ""], |
| 664 [("log -1 --format=%H --grep=\"Prepare push to trunk. " | 667 [("log -1 --format=%H --grep=\"Prepare push to trunk. " |
| 665 "Now working on version 3.22.6.\""), | 668 "Now working on version 3.22.6.\""), |
| 666 "hash1\n"], | 669 "hash1\n"], |
| 667 ["diff svn/trunk hash1", "patch content\n"], | 670 ["diff svn/trunk hash1", "patch content\n"], |
| 668 ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""], | 671 ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""], |
| 669 ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""], | 672 ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""], |
| 670 ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""], | 673 ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""], |
| 671 ["commit -F \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit], | 674 ["commit -F \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit], |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 739 ["svn log -1 --oneline", "r101 | Text"], | 742 ["svn log -1 --oneline", "r101 | Text"], |
| 740 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], | 743 ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], |
| 741 ]) | 744 ]) |
| 742 | 745 |
| 743 state = {} | 746 state = {} |
| 744 self.MakeStep(FetchLatestRevision, state=state).Run() | 747 self.MakeStep(FetchLatestRevision, state=state).Run() |
| 745 self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run) | 748 self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run) |
| 746 | 749 |
| 747 def testAutoRoll(self): | 750 def testAutoRoll(self): |
| 748 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 751 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 752 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
| 749 | 753 |
| 750 self.ExpectReadURL([ | 754 self.ExpectReadURL([ |
| 755 ["https://v8-status.appspot.com/current?format=json", |
| 756 "{\"message\": \"Tree is throttled\"}"], |
| 751 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], | 757 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], |
| 752 ["https://v8-status.appspot.com/lkgr", "100"], | 758 ["https://v8-status.appspot.com/lkgr", "100"], |
| 753 ]) | 759 ]) |
| 754 | 760 |
| 755 self.ExpectGit([ | 761 self.ExpectGit([ |
| 756 ["status -s -uno", ""], | 762 ["status -s -uno", ""], |
| 757 ["status -s -b -uno", "## some_branch\n"], | 763 ["status -s -b -uno", "## some_branch\n"], |
| 758 ["svn fetch", ""], | 764 ["svn fetch", ""], |
| 759 ["svn log -1 --oneline", "r101 | Text"], | 765 ["svn log -1 --oneline", "r101 | Text"], |
| 760 ["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."], | 766 ["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."], |
| 761 ]) | 767 ]) |
| 762 | 768 |
| 763 auto_roll.RunAutoRoll(TEST_CONFIG, | 769 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) |
| 764 AutoRollOptions(MakeOptions(m=False, f=True)), | |
| 765 self) | |
| 766 | 770 |
| 767 self.assertEquals("100", self.MakeStep().Restore("lkgr")) | 771 self.assertEquals("100", self.MakeStep().Restore("lkgr")) |
| 768 self.assertEquals("101", self.MakeStep().Restore("latest")) | 772 self.assertEquals("101", self.MakeStep().Restore("latest")) |
| 769 | 773 |
| 774 def testAutoRollStoppedBySettings(self): |
| 775 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 776 TEST_CONFIG[SETTINGS_LOCATION] = self.MakeEmptyTempFile() |
| 777 TextToFile("{\"enable_auto_roll\": false}", TEST_CONFIG[SETTINGS_LOCATION]) |
| 778 |
| 779 self.ExpectReadURL([]) |
| 780 |
| 781 self.ExpectGit([ |
| 782 ["status -s -uno", ""], |
| 783 ["status -s -b -uno", "## some_branch\n"], |
| 784 ["svn fetch", ""], |
| 785 ]) |
| 786 |
| 787 def RunAutoRoll(): |
| 788 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) |
| 789 self.assertRaises(Exception, RunAutoRoll) |
| 790 |
| 791 def testAutoRollStoppedByTreeStatus(self): |
| 792 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 793 TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" |
| 794 |
| 795 self.ExpectReadURL([ |
| 796 ["https://v8-status.appspot.com/current?format=json", |
| 797 "{\"message\": \"Tree is throttled (no push)\"}"], |
| 798 ]) |
| 799 |
| 800 self.ExpectGit([ |
| 801 ["status -s -uno", ""], |
| 802 ["status -s -b -uno", "## some_branch\n"], |
| 803 ["svn fetch", ""], |
| 804 ]) |
| 805 |
| 806 def RunAutoRoll(): |
| 807 auto_roll.RunAutoRoll(TEST_CONFIG, AutoRollOptions(MakeOptions()), self) |
| 808 self.assertRaises(Exception, RunAutoRoll) |
| 770 | 809 |
| 771 class SystemTest(unittest.TestCase): | 810 class SystemTest(unittest.TestCase): |
| 772 def testReload(self): | 811 def testReload(self): |
| 773 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, | 812 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, |
| 774 options=CommonOptions(MakeOptions()), | 813 options=CommonOptions(MakeOptions()), |
| 775 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) | 814 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) |
| 776 body = step.Reload( | 815 body = step.Reload( |
| 777 """------------------------------------------------------------------------ | 816 """------------------------------------------------------------------------ |
| 778 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines | 817 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines |
| 779 | 818 |
| 780 Prepare push to trunk. Now working on version 3.23.11. | 819 Prepare push to trunk. Now working on version 3.23.11. |
| 781 | 820 |
| 782 R=danno@chromium.org | 821 R=danno@chromium.org |
| 783 | 822 |
| 784 Review URL: https://codereview.chromium.org/83173002 | 823 Review URL: https://codereview.chromium.org/83173002 |
| 785 | 824 |
| 786 ------------------------------------------------------------------------""") | 825 ------------------------------------------------------------------------""") |
| 787 self.assertEquals( | 826 self.assertEquals( |
| 788 """Prepare push to trunk. Now working on version 3.23.11. | 827 """Prepare push to trunk. Now working on version 3.23.11. |
| 789 | 828 |
| 790 R=danno@chromium.org | 829 R=danno@chromium.org |
| 791 | 830 |
| 792 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 831 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
| OLD | NEW |