machenbach@chromium.org | 935a779 | 2013-11-12 09:05:18 +0000 | [diff] [blame] | 1 | #!/usr/bin/env python |
| 2 | # Copyright 2013 the V8 project authors. All rights reserved. |
| 3 | # Redistribution and use in source and binary forms, with or without |
| 4 | # modification, are permitted provided that the following conditions are |
| 5 | # met: |
| 6 | # |
| 7 | # * Redistributions of source code must retain the above copyright |
| 8 | # notice, this list of conditions and the following disclaimer. |
| 9 | # * Redistributions in binary form must reproduce the above |
| 10 | # copyright notice, this list of conditions and the following |
| 11 | # disclaimer in the documentation and/or other materials provided |
| 12 | # with the distribution. |
| 13 | # * Neither the name of Google Inc. nor the names of its |
| 14 | # contributors may be used to endorse or promote products derived |
| 15 | # from this software without specific prior written permission. |
| 16 | # |
| 17 | # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 18 | # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 19 | # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR |
| 20 | # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 21 | # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 22 | # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 23 | # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 24 | # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 25 | # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 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. |
| 28 | |
| 29 | import os |
| 30 | import tempfile |
| 31 | import unittest |
| 32 | |
| 33 | import common_includes |
| 34 | from common_includes import * |
| 35 | import push_to_trunk |
| 36 | from push_to_trunk import * |
| 37 | |
| 38 | |
| 39 | TEST_CONFIG = { |
| 40 | BRANCHNAME: "test-prepare-push", |
| 41 | TRUNKBRANCH: "test-trunk-push", |
| 42 | PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", |
| 43 | TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", |
| 44 | DOT_GIT_LOCATION: None, |
| 45 | VERSION_FILE: None, |
| 46 | CHANGELOG_FILE: None, |
| 47 | CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", |
| 48 | PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", |
| 49 | COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", |
| 50 | CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", |
| 51 | DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", |
| 52 | } |
| 53 | |
| 54 | |
| 55 | class ScriptTest(unittest.TestCase): |
| 56 | def MakeEmptyTempFile(self): |
| 57 | handle, name = tempfile.mkstemp() |
| 58 | os.close(handle) |
| 59 | self._tmp_files.append(name) |
| 60 | return name |
| 61 | |
| 62 | def MakeTempVersionFile(self): |
| 63 | name = self.MakeEmptyTempFile() |
| 64 | with open(name, "w") as f: |
| 65 | f.write(" // Some line...\n") |
| 66 | f.write("\n") |
| 67 | f.write("#define MAJOR_VERSION 3\n") |
| 68 | f.write("#define MINOR_VERSION 22\n") |
| 69 | f.write("#define BUILD_NUMBER 5\n") |
| 70 | f.write("#define PATCH_LEVEL 0\n") |
| 71 | f.write(" // Some line...\n") |
| 72 | f.write("#define IS_CANDIDATE_VERSION 0\n") |
| 73 | return name |
| 74 | |
| 75 | def MakeStep(self, step_class=Step, state=None): |
| 76 | state = state or {} |
| 77 | step = step_class() |
| 78 | step.SetConfig(TEST_CONFIG) |
| 79 | step.SetState(state) |
| 80 | step.SetNumber(0) |
| 81 | step.SetSideEffectHandler(self) |
| 82 | return step |
| 83 | |
| 84 | def GitMock(self, cmd, args="", pipe=True): |
| 85 | self._git_index += 1 |
| 86 | try: |
| 87 | git_invocation = self._git_recipe[self._git_index] |
| 88 | except IndexError: |
| 89 | raise Exception("Calling git %s" % args) |
| 90 | if git_invocation[0] != args: |
| 91 | raise Exception("Expected: %s - Actual: %s" % (git_invocation[0], args)) |
| 92 | if len(git_invocation) == 3: |
| 93 | # Run optional function checking the context during this git command. |
| 94 | git_invocation[2]() |
| 95 | return git_invocation[1] |
| 96 | |
| 97 | def LogMock(self, cmd, args=""): |
| 98 | print "Log: %s %s" % (cmd, args) |
| 99 | |
| 100 | MOCKS = { |
| 101 | "git": GitMock, |
| 102 | "vi": LogMock, |
| 103 | } |
| 104 | |
| 105 | def Command(self, cmd, args="", prefix="", pipe=True): |
| 106 | return ScriptTest.MOCKS[cmd](self, cmd, args) |
| 107 | |
| 108 | def ReadLine(self): |
| 109 | self._rl_index += 1 |
| 110 | try: |
| 111 | return self._rl_recipe[self._rl_index] |
| 112 | except IndexError: |
| 113 | raise Exception("Calling readline too often") |
| 114 | |
| 115 | def setUp(self): |
| 116 | self._git_recipe = [] |
| 117 | self._git_index = -1 |
| 118 | self._rl_recipe = [] |
| 119 | self._rl_index = -1 |
| 120 | self._tmp_files = [] |
| 121 | |
| 122 | def tearDown(self): |
| 123 | Command("rm", "-rf %s*" % TEST_CONFIG[PERSISTFILE_BASENAME]) |
| 124 | |
| 125 | # Clean up temps. Doesn't work automatically. |
| 126 | for name in self._tmp_files: |
| 127 | if os.path.exists(name): |
| 128 | os.remove(name) |
| 129 | |
| 130 | if self._git_index < len(self._git_recipe) -1: |
| 131 | raise Exception("Called git too seldom: %d vs. %d" % |
| 132 | (self._git_index, len(self._git_recipe))) |
| 133 | if self._rl_index < len(self._rl_recipe) -1: |
| 134 | raise Exception("Too little input: %d vs. %d" % |
| 135 | (self._rl_index, len(self._rl_recipe))) |
| 136 | |
| 137 | def testPersistRestore(self): |
| 138 | self.MakeStep().Persist("test1", "") |
| 139 | self.assertEquals("", self.MakeStep().Restore("test1")) |
| 140 | self.MakeStep().Persist("test2", "AB123") |
| 141 | self.assertEquals("AB123", self.MakeStep().Restore("test2")) |
| 142 | |
| 143 | def testGitOrig(self): |
| 144 | self.assertTrue(Command("git", "--version").startswith("git version")) |
| 145 | |
| 146 | def testGitMock(self): |
| 147 | self._git_recipe = [["--version", "git version 1.2.3"], ["dummy", ""]] |
| 148 | self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) |
| 149 | self.assertEquals("", self.MakeStep().Git("dummy")) |
| 150 | |
| 151 | def testCommonPrepareDefault(self): |
| 152 | self._git_recipe = [ |
| 153 | ["status -s -uno", ""], |
| 154 | ["status -s -b -uno", "## some_branch"], |
| 155 | ["svn fetch", ""], |
| 156 | ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], |
| 157 | ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 158 | ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 159 | ["branch", ""], |
| 160 | ] |
| 161 | self._rl_recipe = ["Y"] |
| 162 | self.MakeStep().CommonPrepare() |
| 163 | self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) |
| 164 | |
| 165 | def testCommonPrepareNoConfirm(self): |
| 166 | self._git_recipe = [ |
| 167 | ["status -s -uno", ""], |
| 168 | ["status -s -b -uno", "## some_branch"], |
| 169 | ["svn fetch", ""], |
| 170 | ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], |
| 171 | ] |
| 172 | self._rl_recipe = ["n"] |
| 173 | self.assertRaises(Exception, self.MakeStep().CommonPrepare) |
| 174 | self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) |
| 175 | |
| 176 | def testCommonPrepareDeleteBranchFailure(self): |
| 177 | self._git_recipe = [ |
| 178 | ["status -s -uno", ""], |
| 179 | ["status -s -b -uno", "## some_branch"], |
| 180 | ["svn fetch", ""], |
| 181 | ["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], |
| 182 | ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None], |
| 183 | ] |
| 184 | self._rl_recipe = ["Y"] |
| 185 | self.assertRaises(Exception, self.MakeStep().CommonPrepare) |
| 186 | self.assertEquals("some_branch", self.MakeStep().Restore("current_branch")) |
| 187 | |
| 188 | def testInitialEnvironmentChecks(self): |
| 189 | TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 190 | os.environ["EDITOR"] = "vi" |
| 191 | self.MakeStep().InitialEnvironmentChecks() |
| 192 | |
| 193 | def testReadAndPersistVersion(self): |
| 194 | TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 195 | step = self.MakeStep() |
| 196 | step.ReadAndPersistVersion() |
| 197 | self.assertEquals("3", self.MakeStep().Restore("major")) |
| 198 | self.assertEquals("22", self.MakeStep().Restore("minor")) |
| 199 | self.assertEquals("5", self.MakeStep().Restore("build")) |
| 200 | self.assertEquals("0", self.MakeStep().Restore("patch")) |
| 201 | self.assertEquals("3", step._state["major"]) |
| 202 | self.assertEquals("22", step._state["minor"]) |
| 203 | self.assertEquals("5", step._state["build"]) |
| 204 | self.assertEquals("0", step._state["patch"]) |
| 205 | |
| 206 | def testRegex(self): |
| 207 | self.assertEqual("(issue 321)", |
| 208 | re.sub(r"BUG=v8:(.*)$", r"(issue \1)", "BUG=v8:321")) |
| 209 | self.assertEqual("(Chromium issue 321)", |
| 210 | re.sub(r"BUG=(.*)$", r"(Chromium issue \1)", "BUG=321")) |
| 211 | |
| 212 | cl = " too little\n\ttab\ttab\n too much\n trailing " |
| 213 | cl = MSub(r"\t", r" ", cl) |
| 214 | cl = MSub(r"^ {1,7}([^ ])", r" \1", cl) |
| 215 | cl = MSub(r"^ {9,80}([^ ])", r" \1", cl) |
| 216 | cl = MSub(r" +$", r"", cl) |
| 217 | self.assertEqual(" too little\n" |
| 218 | " tab tab\n" |
| 219 | " too much\n" |
| 220 | " trailing", cl) |
| 221 | |
| 222 | self.assertEqual("//\n#define BUILD_NUMBER 3\n", |
| 223 | MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", |
| 224 | r"\g<space>3", |
| 225 | "//\n#define BUILD_NUMBER 321\n")) |
| 226 | |
| 227 | def testPrepareChangeLog(self): |
| 228 | TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 229 | TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 230 | |
| 231 | self._git_recipe = [ |
| 232 | ["log 1234..HEAD --format=%H", "rev1\nrev2"], |
| 233 | ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Title text 1"], |
| 234 | ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\n"], |
| 235 | ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", |
| 236 | " author1@chromium.org"], |
| 237 | ["log -1 rev2 --format=\"%w(80,8,8)%s\"", " Title text 2"], |
| 238 | ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=321\n"], |
| 239 | ["log -1 rev2 --format=\"%w(80,8,8)(%an)\"", |
| 240 | " author2@chromium.org"], |
| 241 | ] |
| 242 | |
| 243 | self.MakeStep().Persist("last_push", "1234") |
| 244 | self.MakeStep(PrepareChangeLog).Run() |
| 245 | |
| 246 | cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| 247 | self.assertTrue(re.search(r"\d+\-\d+\-\d+: Version 3\.22\.5", cl)) |
| 248 | self.assertTrue(re.search(r" Title text 1", cl)) |
| 249 | self.assertTrue(re.search(r" Title text 2", cl)) |
| 250 | self.assertTrue(re.search(r" author1@chromium.org", cl)) |
| 251 | self.assertTrue(re.search(r" author2@chromium.org", cl)) |
| 252 | self.assertTrue(re.search(r" \(Chromium issue 321\)", cl)) |
| 253 | self.assertFalse(re.search(r"BUG=", cl)) |
| 254 | self.assertEquals("3", self.MakeStep().Restore("major")) |
| 255 | self.assertEquals("22", self.MakeStep().Restore("minor")) |
| 256 | self.assertEquals("5", self.MakeStep().Restore("build")) |
| 257 | self.assertEquals("0", self.MakeStep().Restore("patch")) |
| 258 | |
| 259 | def testEditChangeLog(self): |
| 260 | TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 261 | TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
| 262 | TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) |
| 263 | TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| 264 | os.environ["EDITOR"] = "vi" |
| 265 | |
| 266 | self._rl_recipe = [ |
| 267 | "", # Open editor. |
| 268 | ] |
| 269 | |
| 270 | self.MakeStep(EditChangeLog).Run() |
| 271 | |
| 272 | self.assertEquals(" New\n Lines\n\n\n Original CL", |
| 273 | FileToText(TEST_CONFIG[CHANGELOG_FILE])) |
| 274 | |
| 275 | def testIncrementVersion(self): |
| 276 | TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 277 | self.MakeStep().Persist("build", "5") |
| 278 | |
| 279 | self._rl_recipe = [ |
| 280 | "Y", # Increment build number. |
| 281 | ] |
| 282 | |
| 283 | self.MakeStep(IncrementVersion).Run() |
| 284 | |
| 285 | self.assertEquals("3", self.MakeStep().Restore("new_major")) |
| 286 | self.assertEquals("22", self.MakeStep().Restore("new_minor")) |
| 287 | self.assertEquals("6", self.MakeStep().Restore("new_build")) |
| 288 | self.assertEquals("0", self.MakeStep().Restore("new_patch")) |
| 289 | |
machenbach@chromium.org | 0cc0950 | 2013-11-13 12:20:55 +0000 | [diff] [blame] | 290 | def testLastChangeLogEntries(self): |
| 291 | TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
| 292 | l = """ |
| 293 | Fixed something. |
| 294 | (issue 1234)\n""" |
| 295 | for _ in xrange(10): l = l + l |
| 296 | |
| 297 | cl_chunk = """2013-11-12: Version 3.23.2\n%s |
| 298 | Performance and stability improvements on all platforms.\n\n\n""" % l |
| 299 | |
| 300 | cl_chunk_full = cl_chunk + cl_chunk + cl_chunk |
| 301 | TextToFile(cl_chunk_full, TEST_CONFIG[CHANGELOG_FILE]) |
| 302 | |
| 303 | cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE]) |
| 304 | self.assertEquals(cl_chunk, cl) |
| 305 | |
machenbach@chromium.org | 935a779 | 2013-11-12 09:05:18 +0000 | [diff] [blame] | 306 | def testSquashCommits(self): |
| 307 | TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 308 | with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: |
| 309 | f.write("1999-11-11: Version 3.22.5\n") |
| 310 | f.write("\n") |
| 311 | f.write(" Log text 1.\n") |
| 312 | f.write(" Chromium issue 12345\n") |
| 313 | f.write("\n") |
| 314 | f.write(" Performance and stability improvements on all " |
| 315 | "platforms.\n") |
| 316 | |
| 317 | self._git_recipe = [ |
| 318 | ["diff svn/trunk hash1", "patch content"], |
| 319 | ] |
| 320 | |
| 321 | self.MakeStep().Persist("prepare_commit_hash", "hash1") |
| 322 | self.MakeStep().Persist("date", "1999-11-11") |
| 323 | |
| 324 | self.MakeStep(SquashCommits).Run() |
| 325 | |
| 326 | msg = FileToText(TEST_CONFIG[COMMITMSG_FILE]) |
| 327 | self.assertTrue(re.search(r"Version 3\.22\.5", msg)) |
| 328 | self.assertTrue(re.search(r"Performance and stability", msg)) |
| 329 | self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg)) |
| 330 | self.assertFalse(re.search(r"\d+\-\d+\-\d+", msg)) |
| 331 | |
| 332 | patch = FileToText(TEST_CONFIG[ PATCH_FILE]) |
| 333 | self.assertTrue(re.search(r"patch content", patch)) |
| 334 | |
| 335 | def testPushToTrunk(self): |
| 336 | TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 337 | TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 338 | TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 339 | TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
| 340 | if not os.path.exists(TEST_CONFIG[CHROMIUM]): |
| 341 | os.makedirs(TEST_CONFIG[CHROMIUM]) |
| 342 | TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE]) |
| 343 | TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", |
| 344 | TEST_CONFIG[DEPS_FILE]) |
| 345 | os.environ["EDITOR"] = "vi" |
| 346 | |
| 347 | def CheckPreparePush(): |
| 348 | cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) |
| 349 | self.assertTrue(re.search(r"Version 3.22.5", cl)) |
| 350 | self.assertTrue(re.search(r" Log text 1", cl)) |
| 351 | self.assertTrue(re.search(r" \(issue 321\)", cl)) |
| 352 | version = FileToText(TEST_CONFIG[VERSION_FILE]) |
| 353 | self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version)) |
| 354 | |
| 355 | def CheckSVNCommit(): |
| 356 | commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) |
| 357 | self.assertTrue(re.search(r"Version 3.22.5", commit)) |
| 358 | self.assertTrue(re.search(r"Log text 1. \(issue 321\)", commit)) |
| 359 | version = FileToText(TEST_CONFIG[VERSION_FILE]) |
| 360 | self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) |
| 361 | self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) |
| 362 | self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) |
| 363 | self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) |
| 364 | self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) |
| 365 | |
| 366 | self._git_recipe = [ |
| 367 | ["status -s -uno", ""], |
| 368 | ["status -s -b -uno", "## some_branch\n"], |
| 369 | ["svn fetch", ""], |
| 370 | ["branch", " branch1\n* branch2\n"], |
| 371 | ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 372 | ["branch", " branch1\n* branch2\n"], |
| 373 | ["branch", " branch1\n* branch2\n"], |
| 374 | ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], |
| 375 | ["log -1 --format=%H ChangeLog", "1234\n"], |
| 376 | ["log -1 1234", "Last push ouput\n"], |
| 377 | ["log 1234..HEAD --format=%H", "rev1\n"], |
| 378 | ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Log text 1.\n"], |
| 379 | ["log -1 rev1 --format=\"%B\"", "Text\nBUG=v8:321\nText\n"], |
| 380 | ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", |
| 381 | " author1@chromium.org\n"], |
| 382 | [("commit -a -m \"Prepare push to trunk. " |
| 383 | "Now working on version 3.22.6.\""), |
| 384 | " 2 files changed\n", |
| 385 | CheckPreparePush], |
| 386 | ["cl upload -r \"reviewer@chromium.org\" --send-mail", "done\n"], |
machenbach@chromium.org | b5be0a9 | 2013-11-15 10:32:41 +0000 | [diff] [blame] | 387 | ["cl dcommit -f", "Closing issue\n"], |
machenbach@chromium.org | 935a779 | 2013-11-12 09:05:18 +0000 | [diff] [blame] | 388 | ["svn fetch", "fetch result\n"], |
| 389 | ["checkout svn/bleeding_edge", ""], |
| 390 | [("log -1 --format=%H --grep=\"Prepare push to trunk. " |
| 391 | "Now working on version 3.22.6.\""), |
| 392 | "hash1\n"], |
| 393 | ["diff svn/trunk hash1", "patch content\n"], |
| 394 | ["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""], |
| 395 | ["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""], |
| 396 | ["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""], |
| 397 | ["commit -F \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit], |
| 398 | ["svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"], |
| 399 | ["svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""], |
| 400 | ["status -s -uno", ""], |
| 401 | ["checkout master", ""], |
| 402 | ["pull", ""], |
| 403 | ["checkout -b v8-roll-123456", ""], |
| 404 | [("commit -am \"Update V8 to version 3.22.5.\n\n" |
| 405 | "TBR=reviewer@chromium.org\""), |
| 406 | ""], |
| 407 | ["cl upload --send-mail", ""], |
| 408 | ["checkout -f some_branch", ""], |
| 409 | ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 410 | ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], |
| 411 | ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], |
| 412 | ] |
| 413 | self._rl_recipe = [ |
| 414 | "Y", # Confirm last push. |
| 415 | "", # Open editor. |
| 416 | "Y", # Increment build number. |
| 417 | "reviewer@chromium.org", # V8 reviewer. |
| 418 | "LGTX", # Enter LGTM for V8 CL (wrong). |
| 419 | "LGTM", # Enter LGTM for V8 CL. |
| 420 | "Y", # Sanity check. |
| 421 | "reviewer@chromium.org", # Chromium reviewer. |
| 422 | ] |
| 423 | |
| 424 | class Options( object ): |
| 425 | pass |
| 426 | |
| 427 | options = Options() |
| 428 | options.s = 0 |
| 429 | options.l = None |
| 430 | options.c = TEST_CONFIG[CHROMIUM] |
| 431 | RunScript(TEST_CONFIG, options, self) |
| 432 | |
| 433 | deps = FileToText(TEST_CONFIG[DEPS_FILE]) |
| 434 | self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) |
| 435 | |
| 436 | cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) |
| 437 | self.assertTrue(re.search(r"\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) |
| 438 | self.assertTrue(re.search(r" Log text 1", cl)) |
| 439 | self.assertTrue(re.search(r" \(issue 321\)", cl)) |
| 440 | self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) |
| 441 | |
| 442 | # Note: The version file is on build number 5 again in the end of this test |
| 443 | # since the git command that merges to the bleeding edge branch is mocked |
| 444 | # out. |