| 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 17 matching lines...) Expand all Loading... |
| 28 | 28 |
| 29 import os | 29 import os |
| 30 import tempfile | 30 import tempfile |
| 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 |
| 39 from auto_roll import CheckLastPush |
| 38 from auto_roll import FetchLatestRevision | 40 from auto_roll import FetchLatestRevision |
| 39 from auto_roll import CheckLastPush | |
| 40 | 41 |
| 41 | 42 |
| 42 TEST_CONFIG = { | 43 TEST_CONFIG = { |
| 43 BRANCHNAME: "test-prepare-push", | 44 BRANCHNAME: "test-prepare-push", |
| 44 TRUNKBRANCH: "test-trunk-push", | 45 TRUNKBRANCH: "test-trunk-push", |
| 45 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", | 46 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", |
| 46 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", | 47 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", |
| 47 DOT_GIT_LOCATION: None, | 48 DOT_GIT_LOCATION: None, |
| 48 VERSION_FILE: None, | 49 VERSION_FILE: None, |
| 49 CHANGELOG_FILE: None, | 50 CHANGELOG_FILE: None, |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 223 except IndexError: | 224 except IndexError: |
| 224 raise Exception("Calling %s %s" % (self._name, " ".join(args))) | 225 raise Exception("Calling %s %s" % (self._name, " ".join(args))) |
| 225 | 226 |
| 226 # Pack expectations without arguments into a list. | 227 # Pack expectations without arguments into a list. |
| 227 if not isinstance(expected_call, list): | 228 if not isinstance(expected_call, list): |
| 228 expected_call = [expected_call] | 229 expected_call = [expected_call] |
| 229 | 230 |
| 230 # The number of arguments in the expectation must match the actual | 231 # The number of arguments in the expectation must match the actual |
| 231 # arguments. | 232 # arguments. |
| 232 if len(args) > len(expected_call): | 233 if len(args) > len(expected_call): |
| 233 raise Exception("When calling %s with arguments, the expectations " | 234 raise NoRetryException("When calling %s with arguments, the " |
| 234 "must consist of at least as many arguments.") | 235 "expectations must consist of at least as many arguments.") |
| 235 | 236 |
| 236 # Compare expected and actual arguments. | 237 # Compare expected and actual arguments. |
| 237 for (expected_arg, actual_arg) in zip(expected_call, args): | 238 for (expected_arg, actual_arg) in zip(expected_call, args): |
| 238 if expected_arg != actual_arg: | 239 if expected_arg != actual_arg: |
| 239 raise Exception("Expected: %s - Actual: %s" | 240 raise NoRetryException("Expected: %s - Actual: %s" |
| 240 % (expected_arg, actual_arg)) | 241 % (expected_arg, actual_arg)) |
| 241 | 242 |
| 242 # The expectation list contains a mandatory return value and an optional | 243 # The expectation list contains a mandatory return value and an optional |
| 243 # callback for checking the context at the time of the call. | 244 # callback for checking the context at the time of the call. |
| 244 if len(expected_call) == len(args) + 2: | 245 if len(expected_call) == len(args) + 2: |
| 245 expected_call[len(args) + 1]() | 246 expected_call[len(args) + 1]() |
| 246 return_value = expected_call[len(args)] | 247 return_value = expected_call[len(args)] |
| 247 | 248 |
| 248 # If the return value is an exception, raise it instead of returning. | 249 # If the return value is an exception, raise it instead of returning. |
| 249 if isinstance(return_value, Exception): | 250 if isinstance(return_value, Exception): |
| 250 raise return_value | 251 raise return_value |
| 251 return return_value | 252 return return_value |
| 252 | 253 |
| 253 def AssertFinished(self): | 254 def AssertFinished(self): |
| 254 if self._index < len(self._recipe) -1: | 255 if self._index < len(self._recipe) -1: |
| 255 raise Exception("Called %s too seldom: %d vs. %d" | 256 raise NoRetryException("Called %s too seldom: %d vs. %d" |
| 256 % (self._name, self._index, len(self._recipe))) | 257 % (self._name, self._index, len(self._recipe))) |
| 257 | 258 |
| 258 | 259 |
| 259 class ScriptTest(unittest.TestCase): | 260 class ScriptTest(unittest.TestCase): |
| 260 def MakeEmptyTempFile(self): | 261 def MakeEmptyTempFile(self): |
| 261 handle, name = tempfile.mkstemp() | 262 handle, name = tempfile.mkstemp() |
| 262 os.close(handle) | 263 os.close(handle) |
| 263 self._tmp_files.append(name) | 264 self._tmp_files.append(name) |
| 264 return name | 265 return name |
| 265 | 266 |
| 266 def MakeTempVersionFile(self): | 267 def MakeTempVersionFile(self): |
| 267 name = self.MakeEmptyTempFile() | 268 name = self.MakeEmptyTempFile() |
| 268 with open(name, "w") as f: | 269 with open(name, "w") as f: |
| 269 f.write(" // Some line...\n") | 270 f.write(" // Some line...\n") |
| 270 f.write("\n") | 271 f.write("\n") |
| 271 f.write("#define MAJOR_VERSION 3\n") | 272 f.write("#define MAJOR_VERSION 3\n") |
| 272 f.write("#define MINOR_VERSION 22\n") | 273 f.write("#define MINOR_VERSION 22\n") |
| 273 f.write("#define BUILD_NUMBER 5\n") | 274 f.write("#define BUILD_NUMBER 5\n") |
| 274 f.write("#define PATCH_LEVEL 0\n") | 275 f.write("#define PATCH_LEVEL 0\n") |
| 275 f.write(" // Some line...\n") | 276 f.write(" // Some line...\n") |
| 276 f.write("#define IS_CANDIDATE_VERSION 0\n") | 277 f.write("#define IS_CANDIDATE_VERSION 0\n") |
| 277 return name | 278 return name |
| 278 | 279 |
| 279 def MakeStep(self, step_class=Step, state=None, options=None): | 280 def MakeStep(self, step_class=Step, state=None, options=None): |
| 280 """Convenience wrapper.""" | 281 """Convenience wrapper.""" |
| 281 options = options or MakeOptions() | 282 options = options or CommonOptions(MakeOptions()) |
| 282 return MakeStep(step_class=step_class, number=0, state=state, | 283 return MakeStep(step_class=step_class, number=0, state=state, |
| 283 config=TEST_CONFIG, options=options, | 284 config=TEST_CONFIG, options=options, |
| 284 side_effect_handler=self) | 285 side_effect_handler=self) |
| 285 | 286 |
| 286 def GitMock(self, cmd, args="", pipe=True): | 287 def GitMock(self, cmd, args="", pipe=True): |
| 287 print "%s %s" % (cmd, args) | 288 print "%s %s" % (cmd, args) |
| 288 return self._git_mock.Call(args) | 289 return self._git_mock.Call(args) |
| 289 | 290 |
| 290 def LogMock(self, cmd, args=""): | 291 def LogMock(self, cmd, args=""): |
| 291 print "Log: %s %s" % (cmd, args) | 292 print "Log: %s %s" % (cmd, args) |
| (...skipping 411 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 "LGTM", # Enter LGTM for V8 CL. | 704 "LGTM", # Enter LGTM for V8 CL. |
| 704 ]) | 705 ]) |
| 705 | 706 |
| 706 # No keyboard input in forced mode: | 707 # No keyboard input in forced mode: |
| 707 if force: | 708 if force: |
| 708 self.ExpectReadline([]) | 709 self.ExpectReadline([]) |
| 709 | 710 |
| 710 options = MakeOptions(f=force, m=manual, | 711 options = MakeOptions(f=force, m=manual, |
| 711 r="reviewer@chromium.org" if not manual else None, | 712 r="reviewer@chromium.org" if not manual else None, |
| 712 c = TEST_CONFIG[CHROMIUM]) | 713 c = TEST_CONFIG[CHROMIUM]) |
| 713 RunPushToTrunk(TEST_CONFIG, options, self) | 714 RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self) |
| 714 | 715 |
| 715 deps = FileToText(TEST_CONFIG[DEPS_FILE]) | 716 deps = FileToText(TEST_CONFIG[DEPS_FILE]) |
| 716 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) | 717 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) |
| 717 | 718 |
| 718 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) | 719 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) |
| 719 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) | 720 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) |
| 720 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) | 721 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) |
| 721 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) | 722 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) |
| 722 | 723 |
| 723 # Note: The version file is on build number 5 again in the end of this test | 724 # Note: The version file is on build number 5 again in the end of this test |
| (...skipping 28 matching lines...) Expand all Loading... |
| 752 ]) | 753 ]) |
| 753 | 754 |
| 754 self.ExpectGit([ | 755 self.ExpectGit([ |
| 755 ["status -s -uno", ""], | 756 ["status -s -uno", ""], |
| 756 ["status -s -b -uno", "## some_branch\n"], | 757 ["status -s -b -uno", "## some_branch\n"], |
| 757 ["svn fetch", ""], | 758 ["svn fetch", ""], |
| 758 ["svn log -1 --oneline", "r101 | Text"], | 759 ["svn log -1 --oneline", "r101 | Text"], |
| 759 ["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."], | 760 ["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."], |
| 760 ]) | 761 ]) |
| 761 | 762 |
| 762 auto_roll.RunAutoRoll(TEST_CONFIG, MakeOptions(m=False, f=True), self) | 763 auto_roll.RunAutoRoll(TEST_CONFIG, |
| 764 AutoRollOptions(MakeOptions(m=False, f=True)), |
| 765 self) |
| 763 | 766 |
| 764 self.assertEquals("100", self.MakeStep().Restore("lkgr")) | 767 self.assertEquals("100", self.MakeStep().Restore("lkgr")) |
| 765 self.assertEquals("101", self.MakeStep().Restore("latest")) | 768 self.assertEquals("101", self.MakeStep().Restore("latest")) |
| 766 | 769 |
| 767 | 770 |
| 768 class SystemTest(unittest.TestCase): | 771 class SystemTest(unittest.TestCase): |
| 769 def testReload(self): | 772 def testReload(self): |
| 770 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, | 773 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, |
| 771 options=None, | 774 options=CommonOptions(MakeOptions()), |
| 772 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) | 775 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) |
| 773 body = step.Reload( | 776 body = step.Reload( |
| 774 """------------------------------------------------------------------------ | 777 """------------------------------------------------------------------------ |
| 775 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines | 778 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines |
| 776 | 779 |
| 777 Prepare push to trunk. Now working on version 3.23.11. | 780 Prepare push to trunk. Now working on version 3.23.11. |
| 778 | 781 |
| 779 R=danno@chromium.org | 782 R=danno@chromium.org |
| 780 | 783 |
| 781 Review URL: https://codereview.chromium.org/83173002 | 784 Review URL: https://codereview.chromium.org/83173002 |
| 782 | 785 |
| 783 ------------------------------------------------------------------------""") | 786 ------------------------------------------------------------------------""") |
| 784 self.assertEquals( | 787 self.assertEquals( |
| 785 """Prepare push to trunk. Now working on version 3.23.11. | 788 """Prepare push to trunk. Now working on version 3.23.11. |
| 786 | 789 |
| 787 R=danno@chromium.org | 790 R=danno@chromium.org |
| 788 | 791 |
| 789 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 792 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
| OLD | NEW |