| Index: tools/push-to-trunk/test_scripts.py
|
| diff --git a/tools/push-to-trunk/test_scripts.py b/tools/push-to-trunk/test_scripts.py
|
| index ce90192dc19ac5fd572e6b826b9c0c4dae59f70e..cd65a2bdbbb65f3efe9b0aefc36f1ed3d953b546 100644
|
| --- a/tools/push-to-trunk/test_scripts.py
|
| +++ b/tools/push-to-trunk/test_scripts.py
|
| @@ -35,6 +35,9 @@ from common_includes import *
|
| import push_to_trunk
|
| from push_to_trunk import *
|
| import auto_roll
|
| +from auto_roll import AutoRollOptions
|
| +from auto_roll import CheckLastPush
|
| +from auto_roll import FetchLatestRevision
|
|
|
|
|
| TEST_CONFIG = {
|
| @@ -228,14 +231,14 @@ class SimpleMock(object):
|
| # The number of arguments in the expectation must match the actual
|
| # arguments.
|
| if len(args) > len(expected_call):
|
| - raise Exception("When calling %s with arguments, the expectations "
|
| - "must consist of at least as many arguments.")
|
| + raise NoRetryException("When calling %s with arguments, the "
|
| + "expectations must consist of at least as many arguments.")
|
|
|
| # Compare expected and actual arguments.
|
| for (expected_arg, actual_arg) in zip(expected_call, args):
|
| if expected_arg != actual_arg:
|
| - raise Exception("Expected: %s - Actual: %s"
|
| - % (expected_arg, actual_arg))
|
| + raise NoRetryException("Expected: %s - Actual: %s"
|
| + % (expected_arg, actual_arg))
|
|
|
| # The expectation list contains a mandatory return value and an optional
|
| # callback for checking the context at the time of the call.
|
| @@ -250,8 +253,8 @@ class SimpleMock(object):
|
|
|
| def AssertFinished(self):
|
| if self._index < len(self._recipe) -1:
|
| - raise Exception("Called %s too seldom: %d vs. %d"
|
| - % (self._name, self._index, len(self._recipe)))
|
| + raise NoRetryException("Called %s too seldom: %d vs. %d"
|
| + % (self._name, self._index, len(self._recipe)))
|
|
|
|
|
| class ScriptTest(unittest.TestCase):
|
| @@ -276,7 +279,7 @@ class ScriptTest(unittest.TestCase):
|
|
|
| def MakeStep(self, step_class=Step, state=None, options=None):
|
| """Convenience wrapper."""
|
| - options = options or MakeOptions()
|
| + options = options or CommonOptions(MakeOptions())
|
| return MakeStep(step_class=step_class, number=0, state=state,
|
| config=TEST_CONFIG, options=options,
|
| side_effect_handler=self)
|
| @@ -543,16 +546,10 @@ class ScriptTest(unittest.TestCase):
|
| cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE])
|
| self.assertEquals(cl_chunk, cl)
|
|
|
| - def testSquashCommits(self):
|
| + def _TestSquashCommits(self, change_log, expected_msg):
|
| TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
|
| with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f:
|
| - f.write("1999-11-11: Version 3.22.5\n")
|
| - f.write("\n")
|
| - f.write(" Log text 1.\n")
|
| - f.write(" Chromium issue 12345\n")
|
| - f.write("\n")
|
| - f.write(" Performance and stability improvements on all "
|
| - "platforms.\n")
|
| + f.write(change_log)
|
|
|
| self.ExpectGit([
|
| ["diff svn/trunk hash1", "patch content"],
|
| @@ -562,16 +559,44 @@ class ScriptTest(unittest.TestCase):
|
| self.MakeStep().Persist("date", "1999-11-11")
|
|
|
| self.MakeStep(SquashCommits).Run()
|
| -
|
| - msg = FileToText(TEST_CONFIG[COMMITMSG_FILE])
|
| - self.assertTrue(re.search(r"Version 3\.22\.5", msg))
|
| - self.assertTrue(re.search(r"Performance and stability", msg))
|
| - self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg))
|
| - self.assertFalse(re.search(r"\d+\-\d+\-\d+", msg))
|
| + self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg)
|
|
|
| patch = FileToText(TEST_CONFIG[ PATCH_FILE])
|
| self.assertTrue(re.search(r"patch content", patch))
|
|
|
| + def testSquashCommitsUnformatted(self):
|
| + change_log = """1999-11-11: Version 3.22.5
|
| +
|
| + Log text 1.
|
| + Chromium issue 12345
|
| +
|
| + Performance and stability improvements on all platforms.\n"""
|
| + commit_msg = """Version 3.22.5
|
| +
|
| +Log text 1. Chromium issue 12345
|
| +
|
| +Performance and stability improvements on all platforms."""
|
| + self._TestSquashCommits(change_log, commit_msg)
|
| +
|
| + def testSquashCommitsFormatted(self):
|
| + change_log = """1999-11-11: Version 3.22.5
|
| +
|
| + Long commit message that fills more than 80 characters (Chromium issue
|
| + 12345).
|
| +
|
| + Performance and stability improvements on all platforms.\n"""
|
| + commit_msg = """Version 3.22.5
|
| +
|
| +Long commit message that fills more than 80 characters (Chromium issue 12345).
|
| +
|
| +Performance and stability improvements on all platforms."""
|
| + self._TestSquashCommits(change_log, commit_msg)
|
| +
|
| + def testSquashCommitsQuotationMarks(self):
|
| + change_log = """Line with "quotation marks".\n"""
|
| + commit_msg = """Line with "quotation marks"."""
|
| + self._TestSquashCommits(change_log, commit_msg)
|
| +
|
| def _PushToTrunk(self, force=False, manual=False):
|
| TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
|
| TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
|
| @@ -686,7 +711,7 @@ class ScriptTest(unittest.TestCase):
|
| options = MakeOptions(f=force, m=manual,
|
| r="reviewer@chromium.org" if not manual else None,
|
| c = TEST_CONFIG[CHROMIUM])
|
| - RunPushToTrunk(TEST_CONFIG, options, self)
|
| + RunPushToTrunk(TEST_CONFIG, PushToTrunkOptions(options), self)
|
|
|
| deps = FileToText(TEST_CONFIG[DEPS_FILE])
|
| self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps))
|
| @@ -709,6 +734,16 @@ class ScriptTest(unittest.TestCase):
|
| def testPushToTrunkForced(self):
|
| self._PushToTrunk(force=True)
|
|
|
| + def testCheckLastPushRecently(self):
|
| + self.ExpectGit([
|
| + ["svn log -1 --oneline", "r101 | Text"],
|
| + ["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."],
|
| + ])
|
| +
|
| + state = {}
|
| + self.MakeStep(FetchLatestRevision, state=state).Run()
|
| + self.assertRaises(Exception, self.MakeStep(CheckLastPush, state=state).Run)
|
| +
|
| def testAutoRoll(self):
|
| TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
|
|
|
| @@ -722,9 +757,12 @@ class ScriptTest(unittest.TestCase):
|
| ["status -s -b -uno", "## some_branch\n"],
|
| ["svn fetch", ""],
|
| ["svn log -1 --oneline", "r101 | Text"],
|
| + ["svn log -1 --oneline ChangeLog", "r65 | Prepare push to trunk..."],
|
| ])
|
|
|
| - auto_roll.RunAutoRoll(TEST_CONFIG, MakeOptions(m=False, f=True), self)
|
| + auto_roll.RunAutoRoll(TEST_CONFIG,
|
| + AutoRollOptions(MakeOptions(m=False, f=True)),
|
| + self)
|
|
|
| self.assertEquals("100", self.MakeStep().Restore("lkgr"))
|
| self.assertEquals("101", self.MakeStep().Restore("latest"))
|
| @@ -733,7 +771,7 @@ class ScriptTest(unittest.TestCase):
|
| class SystemTest(unittest.TestCase):
|
| def testReload(self):
|
| step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={},
|
| - options=None,
|
| + options=CommonOptions(MakeOptions()),
|
| side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER)
|
| body = step.Reload(
|
| """------------------------------------------------------------------------
|
|
|