| 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 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 46 VERSION_FILE: None, | 46 VERSION_FILE: None, |
| 47 CHANGELOG_FILE: None, | 47 CHANGELOG_FILE: None, |
| 48 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", | 48 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", |
| 49 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", | 49 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", |
| 50 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", | 50 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", |
| 51 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", | 51 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", |
| 52 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", | 52 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", |
| 53 } | 53 } |
| 54 | 54 |
| 55 | 55 |
| 56 def MakeOptions(s=0, l=None, f=False, m=True, r=None, c=None): |
| 57 """Convenience wrapper.""" |
| 58 class Options(object): |
| 59 pass |
| 60 options = Options() |
| 61 options.s = s |
| 62 options.l = l |
| 63 options.f = f |
| 64 options.m = m |
| 65 options.r = r |
| 66 options.c = c |
| 67 return options |
| 68 |
| 69 |
| 56 class ToplevelTest(unittest.TestCase): | 70 class ToplevelTest(unittest.TestCase): |
| 57 def testMakeComment(self): | 71 def testMakeComment(self): |
| 58 self.assertEquals("# Line 1\n# Line 2\n#", | 72 self.assertEquals("# Line 1\n# Line 2\n#", |
| 59 MakeComment(" Line 1\n Line 2\n")) | 73 MakeComment(" Line 1\n Line 2\n")) |
| 60 self.assertEquals("#Line 1\n#Line 2", | 74 self.assertEquals("#Line 1\n#Line 2", |
| 61 MakeComment("Line 1\n Line 2")) | 75 MakeComment("Line 1\n Line 2")) |
| 62 | 76 |
| 63 def testStripComments(self): | 77 def testStripComments(self): |
| 64 self.assertEquals(" Line 1\n Line 3\n", | 78 self.assertEquals(" Line 1\n Line 3\n", |
| 65 StripComments(" Line 1\n# Line 2\n Line 3\n#\n")) | 79 StripComments(" Line 1\n# Line 2\n Line 3\n#\n")) |
| (...skipping 30 matching lines...) Expand all Loading... |
| 96 "Title text 3\n\nBUG=1234\nLOG = Yes\n", | 110 "Title text 3\n\nBUG=1234\nLOG = Yes\n", |
| 97 "author3@chromium.org"], | 111 "author3@chromium.org"], |
| 98 ["Title text 3", | 112 ["Title text 3", |
| 99 "Title text 4\n\nBUG=1234\nLOG=\n", | 113 "Title text 4\n\nBUG=1234\nLOG=\n", |
| 100 "author4@chromium.org"], | 114 "author4@chromium.org"], |
| 101 ] | 115 ] |
| 102 self.assertEquals(" Title text 1.\n\n" | 116 self.assertEquals(" Title text 1.\n\n" |
| 103 " Title text 3 (Chromium issue 1234).\n\n", | 117 " Title text 3 (Chromium issue 1234).\n\n", |
| 104 MakeChangeLogBody(commits, True)) | 118 MakeChangeLogBody(commits, True)) |
| 105 | 119 |
| 120 def testRegressWrongLogEntryOnTrue(self): |
| 121 body = """ |
| 122 Check elimination: Learn from if(CompareMap(x)) on true branch. |
| 123 |
| 124 BUG= |
| 125 R=verwaest@chromium.org |
| 126 |
| 127 Committed: https://code.google.com/p/v8/source/detail?r=18210 |
| 128 """ |
| 129 self.assertEquals("", MakeChangeLogBody([["title", body, "author"]], True)) |
| 130 |
| 106 def testMakeChangeLogBugReferenceEmpty(self): | 131 def testMakeChangeLogBugReferenceEmpty(self): |
| 107 self.assertEquals("", MakeChangeLogBugReference("")) | 132 self.assertEquals("", MakeChangeLogBugReference("")) |
| 108 self.assertEquals("", MakeChangeLogBugReference("LOG=")) | 133 self.assertEquals("", MakeChangeLogBugReference("LOG=")) |
| 109 self.assertEquals("", MakeChangeLogBugReference(" BUG =")) | 134 self.assertEquals("", MakeChangeLogBugReference(" BUG =")) |
| 110 self.assertEquals("", MakeChangeLogBugReference("BUG=none\t")) | 135 self.assertEquals("", MakeChangeLogBugReference("BUG=none\t")) |
| 111 | 136 |
| 112 def testMakeChangeLogBugReferenceSimple(self): | 137 def testMakeChangeLogBugReferenceSimple(self): |
| 113 self.assertEquals("(issue 987654)", | 138 self.assertEquals("(issue 987654)", |
| 114 MakeChangeLogBugReference("BUG = v8:987654")) | 139 MakeChangeLogBugReference("BUG = v8:987654")) |
| 115 self.assertEquals("(Chromium issue 987654)", | 140 self.assertEquals("(Chromium issue 987654)", |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 209 # Compare expected and actual arguments. | 234 # Compare expected and actual arguments. |
| 210 for (expected_arg, actual_arg) in zip(expected_call, args): | 235 for (expected_arg, actual_arg) in zip(expected_call, args): |
| 211 if expected_arg != actual_arg: | 236 if expected_arg != actual_arg: |
| 212 raise Exception("Expected: %s - Actual: %s" | 237 raise Exception("Expected: %s - Actual: %s" |
| 213 % (expected_arg, actual_arg)) | 238 % (expected_arg, actual_arg)) |
| 214 | 239 |
| 215 # The expectation list contains a mandatory return value and an optional | 240 # The expectation list contains a mandatory return value and an optional |
| 216 # callback for checking the context at the time of the call. | 241 # callback for checking the context at the time of the call. |
| 217 if len(expected_call) == len(args) + 2: | 242 if len(expected_call) == len(args) + 2: |
| 218 expected_call[len(args) + 1]() | 243 expected_call[len(args) + 1]() |
| 219 return expected_call[len(args)] | 244 return_value = expected_call[len(args)] |
| 245 |
| 246 # If the return value is an exception, raise it instead of returning. |
| 247 if isinstance(return_value, Exception): |
| 248 raise return_value |
| 249 return return_value |
| 220 | 250 |
| 221 def AssertFinished(self): | 251 def AssertFinished(self): |
| 222 if self._index < len(self._recipe) -1: | 252 if self._index < len(self._recipe) -1: |
| 223 raise Exception("Called %s too seldom: %d vs. %d" | 253 raise Exception("Called %s too seldom: %d vs. %d" |
| 224 % (self._name, self._index, len(self._recipe))) | 254 % (self._name, self._index, len(self._recipe))) |
| 225 | 255 |
| 226 | 256 |
| 227 class ScriptTest(unittest.TestCase): | 257 class ScriptTest(unittest.TestCase): |
| 228 def MakeEmptyTempFile(self): | 258 def MakeEmptyTempFile(self): |
| 229 handle, name = tempfile.mkstemp() | 259 handle, name = tempfile.mkstemp() |
| 230 os.close(handle) | 260 os.close(handle) |
| 231 self._tmp_files.append(name) | 261 self._tmp_files.append(name) |
| 232 return name | 262 return name |
| 233 | 263 |
| 234 def MakeTempVersionFile(self): | 264 def MakeTempVersionFile(self): |
| 235 name = self.MakeEmptyTempFile() | 265 name = self.MakeEmptyTempFile() |
| 236 with open(name, "w") as f: | 266 with open(name, "w") as f: |
| 237 f.write(" // Some line...\n") | 267 f.write(" // Some line...\n") |
| 238 f.write("\n") | 268 f.write("\n") |
| 239 f.write("#define MAJOR_VERSION 3\n") | 269 f.write("#define MAJOR_VERSION 3\n") |
| 240 f.write("#define MINOR_VERSION 22\n") | 270 f.write("#define MINOR_VERSION 22\n") |
| 241 f.write("#define BUILD_NUMBER 5\n") | 271 f.write("#define BUILD_NUMBER 5\n") |
| 242 f.write("#define PATCH_LEVEL 0\n") | 272 f.write("#define PATCH_LEVEL 0\n") |
| 243 f.write(" // Some line...\n") | 273 f.write(" // Some line...\n") |
| 244 f.write("#define IS_CANDIDATE_VERSION 0\n") | 274 f.write("#define IS_CANDIDATE_VERSION 0\n") |
| 245 return name | 275 return name |
| 246 | 276 |
| 247 def MakeStep(self, step_class=Step, state=None): | 277 def MakeStep(self, step_class=Step, state=None, options=None): |
| 248 """Convenience wrapper.""" | 278 """Convenience wrapper.""" |
| 279 options = options or MakeOptions() |
| 249 return MakeStep(step_class=step_class, number=0, state=state, | 280 return MakeStep(step_class=step_class, number=0, state=state, |
| 250 config=TEST_CONFIG, options=None, side_effect_handler=self) | 281 config=TEST_CONFIG, options=options, |
| 282 side_effect_handler=self) |
| 251 | 283 |
| 252 def GitMock(self, cmd, args="", pipe=True): | 284 def GitMock(self, cmd, args="", pipe=True): |
| 285 print "%s %s" % (cmd, args) |
| 253 return self._git_mock.Call(args) | 286 return self._git_mock.Call(args) |
| 254 | 287 |
| 255 def LogMock(self, cmd, args=""): | 288 def LogMock(self, cmd, args=""): |
| 256 print "Log: %s %s" % (cmd, args) | 289 print "Log: %s %s" % (cmd, args) |
| 257 | 290 |
| 258 MOCKS = { | 291 MOCKS = { |
| 259 "git": GitMock, | 292 "git": GitMock, |
| 260 "vi": LogMock, | 293 "vi": LogMock, |
| 261 } | 294 } |
| 262 | 295 |
| 263 def Command(self, cmd, args="", prefix="", pipe=True): | 296 def Command(self, cmd, args="", prefix="", pipe=True): |
| 264 return ScriptTest.MOCKS[cmd](self, cmd, args) | 297 return ScriptTest.MOCKS[cmd](self, cmd, args) |
| 265 | 298 |
| 266 def ReadLine(self): | 299 def ReadLine(self): |
| 267 return self._rl_mock.Call() | 300 return self._rl_mock.Call() |
| 268 | 301 |
| 269 def ReadURL(self, url): | 302 def ReadURL(self, url): |
| 270 return self._url_mock.Call(url) | 303 return self._url_mock.Call(url) |
| 271 | 304 |
| 305 def Sleep(self, seconds): |
| 306 pass |
| 307 |
| 308 def GetDate(self): |
| 309 return "1999-07-31" |
| 310 |
| 272 def ExpectGit(self, *args): | 311 def ExpectGit(self, *args): |
| 273 """Convenience wrapper.""" | 312 """Convenience wrapper.""" |
| 274 self._git_mock.Expect(*args) | 313 self._git_mock.Expect(*args) |
| 275 | 314 |
| 276 def ExpectReadline(self, *args): | 315 def ExpectReadline(self, *args): |
| 277 """Convenience wrapper.""" | 316 """Convenience wrapper.""" |
| 278 self._rl_mock.Expect(*args) | 317 self._rl_mock.Expect(*args) |
| 279 | 318 |
| 280 def ExpectReadURL(self, *args): | 319 def ExpectReadURL(self, *args): |
| 281 """Convenience wrapper.""" | 320 """Convenience wrapper.""" |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 418 self.ExpectReadURL([ | 457 self.ExpectReadURL([ |
| 419 ["https://codereview.chromium.org/9876543210/description", | 458 ["https://codereview.chromium.org/9876543210/description", |
| 420 "Title\n\nBUG=456\nLOG=N\n\n"], | 459 "Title\n\nBUG=456\nLOG=N\n\n"], |
| 421 ]) | 460 ]) |
| 422 | 461 |
| 423 self.MakeStep().Persist("last_push", "1234") | 462 self.MakeStep().Persist("last_push", "1234") |
| 424 self.MakeStep(PrepareChangeLog).Run() | 463 self.MakeStep(PrepareChangeLog).Run() |
| 425 | 464 |
| 426 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 465 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| 427 | 466 |
| 428 # TODO(machenbach): Mock out call to date() in order to make a fixed | 467 expected_cl = """1999-07-31: Version 3.22.5 |
| 429 # comparison here instead of a regexp match. | |
| 430 expected_cl = """\\d+\\-\\d+\\-\\d+: Version 3\\.22\\.5 | |
| 431 | 468 |
| 432 Title text 1. | 469 Title text 1. |
| 433 | 470 |
| 434 Title text 3 \\(Chromium issue 321\\). | 471 Title text 3 (Chromium issue 321). |
| 435 | 472 |
| 436 Performance and stability improvements on all platforms\\. | 473 Performance and stability improvements on all platforms. |
| 437 # | 474 # |
| 438 # The change log above is auto-generated\\. Please review if all relevant | 475 # The change log above is auto-generated. Please review if all relevant |
| 439 # commit messages from the list below are included\\. | 476 # commit messages from the list below are included. |
| 440 # All lines starting with # will be stripped\\. | 477 # All lines starting with # will be stripped. |
| 441 # | 478 # |
| 442 # Title text 1. | 479 # Title text 1. |
| 443 # \\(author1@chromium\\.org\\) | 480 # (author1@chromium.org) |
| 444 # | 481 # |
| 445 # Title text 2 \\(Chromium issue 123\\). | 482 # Title text 2 (Chromium issue 123). |
| 446 # \\(author2@chromium\\.org\\) | 483 # (author2@chromium.org) |
| 447 # | 484 # |
| 448 # Title text 3 \\(Chromium issue 321\\). | 485 # Title text 3 (Chromium issue 321). |
| 449 # \\(author3@chromium\\.org\\) | 486 # (author3@chromium.org) |
| 450 # | 487 # |
| 451 # Title text 4 \\(Chromium issue 456\\). | 488 # Title text 4 (Chromium issue 456). |
| 452 # \\(author4@chromium\\.org\\) | 489 # (author4@chromium.org) |
| 453 # | 490 # |
| 454 #""" | 491 #""" |
| 455 | 492 |
| 456 self.assertTrue(re.match(expected_cl, actual_cl)) | 493 self.assertEquals(expected_cl, actual_cl) |
| 457 self.assertEquals("3", self.MakeStep().Restore("major")) | 494 self.assertEquals("3", self.MakeStep().Restore("major")) |
| 458 self.assertEquals("22", self.MakeStep().Restore("minor")) | 495 self.assertEquals("22", self.MakeStep().Restore("minor")) |
| 459 self.assertEquals("5", self.MakeStep().Restore("build")) | 496 self.assertEquals("5", self.MakeStep().Restore("build")) |
| 460 self.assertEquals("0", self.MakeStep().Restore("patch")) | 497 self.assertEquals("0", self.MakeStep().Restore("patch")) |
| 461 | 498 |
| 462 def testEditChangeLog(self): | 499 def testEditChangeLog(self): |
| 463 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 500 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 464 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | 501 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
| 465 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) | 502 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) |
| 466 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 503 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 528 | 565 |
| 529 msg = FileToText(TEST_CONFIG[COMMITMSG_FILE]) | 566 msg = FileToText(TEST_CONFIG[COMMITMSG_FILE]) |
| 530 self.assertTrue(re.search(r"Version 3\.22\.5", msg)) | 567 self.assertTrue(re.search(r"Version 3\.22\.5", msg)) |
| 531 self.assertTrue(re.search(r"Performance and stability", msg)) | 568 self.assertTrue(re.search(r"Performance and stability", msg)) |
| 532 self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg)) | 569 self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg)) |
| 533 self.assertFalse(re.search(r"\d+\-\d+\-\d+", msg)) | 570 self.assertFalse(re.search(r"\d+\-\d+\-\d+", msg)) |
| 534 | 571 |
| 535 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) | 572 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) |
| 536 self.assertTrue(re.search(r"patch content", patch)) | 573 self.assertTrue(re.search(r"patch content", patch)) |
| 537 | 574 |
| 538 def _PushToTrunk(self, force=False): | 575 def _PushToTrunk(self, force=False, manual=False): |
| 539 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 576 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 540 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 577 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
| 541 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 578 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
| 542 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | 579 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
| 543 if not os.path.exists(TEST_CONFIG[CHROMIUM]): | 580 if not os.path.exists(TEST_CONFIG[CHROMIUM]): |
| 544 os.makedirs(TEST_CONFIG[CHROMIUM]) | 581 os.makedirs(TEST_CONFIG[CHROMIUM]) |
| 545 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE]) | 582 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE]) |
| 546 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", | 583 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", |
| 547 TEST_CONFIG[DEPS_FILE]) | 584 TEST_CONFIG[DEPS_FILE]) |
| 548 os.environ["EDITOR"] = "vi" | 585 os.environ["EDITOR"] = "vi" |
| (...skipping 17 matching lines...) Expand all Loading... |
| 566 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) | 603 commit = FileToText(TEST_CONFIG[COMMITMSG_FILE]) |
| 567 self.assertTrue(re.search(r"Version 3.22.5", commit)) | 604 self.assertTrue(re.search(r"Version 3.22.5", commit)) |
| 568 self.assertTrue(re.search(r"Log text 1 \(issue 321\).", commit)) | 605 self.assertTrue(re.search(r"Log text 1 \(issue 321\).", commit)) |
| 569 version = FileToText(TEST_CONFIG[VERSION_FILE]) | 606 version = FileToText(TEST_CONFIG[VERSION_FILE]) |
| 570 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) | 607 self.assertTrue(re.search(r"#define MINOR_VERSION\s+22", version)) |
| 571 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) | 608 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+5", version)) |
| 572 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) | 609 self.assertFalse(re.search(r"#define BUILD_NUMBER\s+6", version)) |
| 573 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) | 610 self.assertTrue(re.search(r"#define PATCH_LEVEL\s+0", version)) |
| 574 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) | 611 self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) |
| 575 | 612 |
| 576 force_flag = " -f" if force else "" | 613 force_flag = " -f" if not manual else "" |
| 614 review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else "" |
| 577 self.ExpectGit([ | 615 self.ExpectGit([ |
| 578 ["status -s -uno", ""], | 616 ["status -s -uno", ""], |
| 579 ["status -s -b -uno", "## some_branch\n"], | 617 ["status -s -b -uno", "## some_branch\n"], |
| 580 ["svn fetch", ""], | 618 ["svn fetch", ""], |
| 581 ["branch", " branch1\n* branch2\n"], | 619 ["branch", " branch1\n* branch2\n"], |
| 582 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 620 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 583 ["branch", " branch1\n* branch2\n"], | 621 ["branch", " branch1\n* branch2\n"], |
| 584 ["branch", " branch1\n* branch2\n"], | 622 ["branch", " branch1\n* branch2\n"], |
| 585 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], | 623 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], |
| 586 ["log -1 --format=%H ChangeLog", "1234\n"], | 624 ["log -1 --format=%H ChangeLog", "1234\n"], |
| 587 ["log -1 1234", "Last push ouput\n"], | 625 ["log -1 1234", "Last push ouput\n"], |
| 588 ["log 1234..HEAD --format=%H", "rev1\n"], | 626 ["log 1234..HEAD --format=%H", "rev1\n"], |
| 589 ["log -1 rev1 --format=\"%s\"", "Log text 1.\n"], | 627 ["log -1 rev1 --format=\"%s\"", "Log text 1.\n"], |
| 590 ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"], | 628 ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"], |
| 591 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org\n"], | 629 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org\n"], |
| 592 [("commit -a -m \"Prepare push to trunk. " | 630 [("commit -a -m \"Prepare push to trunk. " |
| 593 "Now working on version 3.22.6.\""), | 631 "Now working on version 3.22.6.%s\"" % review_suffix), |
| 594 " 2 files changed\n", | 632 " 2 files changed\n", |
| 595 CheckPreparePush], | 633 CheckPreparePush], |
| 596 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag, | 634 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag, |
| 597 "done\n"], | 635 "done\n"], |
| 598 ["cl dcommit -f", "Closing issue\n"], | 636 ["cl dcommit -f", "Closing issue\n"], |
| 599 ["svn fetch", "fetch result\n"], | 637 ["svn fetch", "fetch result\n"], |
| 600 ["checkout svn/bleeding_edge", ""], | 638 ["checkout svn/bleeding_edge", ""], |
| 601 [("log -1 --format=%H --grep=\"Prepare push to trunk. " | 639 [("log -1 --format=%H --grep=\"Prepare push to trunk. " |
| 602 "Now working on version 3.22.6.\""), | 640 "Now working on version 3.22.6.\""), |
| 603 "hash1\n"], | 641 "hash1\n"], |
| (...skipping 10 matching lines...) Expand all Loading... |
| 614 ["checkout -b v8-roll-123456", ""], | 652 ["checkout -b v8-roll-123456", ""], |
| 615 [("commit -am \"Update V8 to version 3.22.5.\n\n" | 653 [("commit -am \"Update V8 to version 3.22.5.\n\n" |
| 616 "TBR=reviewer@chromium.org\""), | 654 "TBR=reviewer@chromium.org\""), |
| 617 ""], | 655 ""], |
| 618 ["cl upload --send-mail%s" % force_flag, ""], | 656 ["cl upload --send-mail%s" % force_flag, ""], |
| 619 ["checkout -f some_branch", ""], | 657 ["checkout -f some_branch", ""], |
| 620 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], | 658 ["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], |
| 621 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], | 659 ["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], |
| 622 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], | 660 ["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], |
| 623 ]) | 661 ]) |
| 624 self.ExpectReadline([ | 662 |
| 625 "Y", # Confirm last push. | 663 # Expected keyboard input in manual mode: |
| 626 "", # Open editor. | 664 if manual: |
| 627 "Y", # Increment build number. | 665 self.ExpectReadline([ |
| 628 "reviewer@chromium.org", # V8 reviewer. | 666 "Y", # Confirm last push. |
| 629 "LGTX", # Enter LGTM for V8 CL (wrong). | 667 "", # Open editor. |
| 630 "LGTM", # Enter LGTM for V8 CL. | 668 "Y", # Increment build number. |
| 631 "Y", # Sanity check. | 669 "reviewer@chromium.org", # V8 reviewer. |
| 632 "reviewer@chromium.org", # Chromium reviewer. | 670 "LGTX", # Enter LGTM for V8 CL (wrong). |
| 633 ]) | 671 "LGTM", # Enter LGTM for V8 CL. |
| 634 if force: | 672 "Y", # Sanity check. |
| 635 # TODO(machenbach): The lgtm for the prepare push is just temporary. | 673 "reviewer@chromium.org", # Chromium reviewer. |
| 636 # There should be no user input in "force" mode. | 674 ]) |
| 675 |
| 676 # Expected keyboard input in semi-automatic mode: |
| 677 if not manual and not force: |
| 637 self.ExpectReadline([ | 678 self.ExpectReadline([ |
| 638 "LGTM", # Enter LGTM for V8 CL. | 679 "LGTM", # Enter LGTM for V8 CL. |
| 639 ]) | 680 ]) |
| 640 | 681 |
| 641 class Options( object ): | 682 # No keyboard input in forced mode: |
| 642 pass | 683 if force: |
| 684 self.ExpectReadline([]) |
| 643 | 685 |
| 644 options = Options() | 686 options = MakeOptions(f=force, m=manual, |
| 645 options.s = 0 | 687 r="reviewer@chromium.org" if not manual else None, |
| 646 options.l = None | 688 c = TEST_CONFIG[CHROMIUM]) |
| 647 options.f = force | |
| 648 options.r = "reviewer@chromium.org" if force else None | |
| 649 options.c = TEST_CONFIG[CHROMIUM] | |
| 650 RunPushToTrunk(TEST_CONFIG, options, self) | 689 RunPushToTrunk(TEST_CONFIG, options, self) |
| 651 | 690 |
| 652 deps = FileToText(TEST_CONFIG[DEPS_FILE]) | 691 deps = FileToText(TEST_CONFIG[DEPS_FILE]) |
| 653 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) | 692 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) |
| 654 | 693 |
| 655 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) | 694 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) |
| 656 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) | 695 self.assertTrue(re.search(r"^\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) |
| 657 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) | 696 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) |
| 658 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) | 697 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) |
| 659 | 698 |
| 660 # Note: The version file is on build number 5 again in the end of this test | 699 # Note: The version file is on build number 5 again in the end of this test |
| 661 # since the git command that merges to the bleeding edge branch is mocked | 700 # since the git command that merges to the bleeding edge branch is mocked |
| 662 # out. | 701 # out. |
| 663 | 702 |
| 664 def testPushToTrunk(self): | 703 def testPushToTrunkManual(self): |
| 704 self._PushToTrunk(manual=True) |
| 705 |
| 706 def testPushToTrunkSemiAutomatic(self): |
| 665 self._PushToTrunk() | 707 self._PushToTrunk() |
| 666 | 708 |
| 667 def testPushToTrunkForced(self): | 709 def testPushToTrunkForced(self): |
| 668 self._PushToTrunk(force=True) | 710 self._PushToTrunk(force=True) |
| 669 | 711 |
| 670 def testAutoRoll(self): | 712 def testAutoRoll(self): |
| 671 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 713 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
| 672 | 714 |
| 673 # TODO(machenbach): Get rid of the editor check in automatic mode. | |
| 674 os.environ["EDITOR"] = "vi" | |
| 675 | |
| 676 self.ExpectReadURL([ | 715 self.ExpectReadURL([ |
| 716 ["https://v8-status.appspot.com/lkgr", Exception("Network problem")], |
| 677 ["https://v8-status.appspot.com/lkgr", "100"], | 717 ["https://v8-status.appspot.com/lkgr", "100"], |
| 678 ]) | 718 ]) |
| 679 | 719 |
| 680 self.ExpectGit([ | 720 self.ExpectGit([ |
| 681 ["status -s -uno", ""], | 721 ["status -s -uno", ""], |
| 682 ["status -s -b -uno", "## some_branch\n"], | 722 ["status -s -b -uno", "## some_branch\n"], |
| 683 ["svn fetch", ""], | 723 ["svn fetch", ""], |
| 684 ["svn log -1 --oneline", "r101 | Text"], | 724 ["svn log -1 --oneline", "r101 | Text"], |
| 685 ]) | 725 ]) |
| 686 | 726 |
| 687 # TODO(machenbach): Make a convenience wrapper for this. | 727 auto_roll.RunAutoRoll(TEST_CONFIG, MakeOptions(m=False, f=True), self) |
| 688 class Options( object ): | |
| 689 pass | |
| 690 | |
| 691 options = Options() | |
| 692 options.s = 0 | |
| 693 | |
| 694 auto_roll.RunAutoRoll(TEST_CONFIG, options, self) | |
| 695 | 728 |
| 696 self.assertEquals("100", self.MakeStep().Restore("lkgr")) | 729 self.assertEquals("100", self.MakeStep().Restore("lkgr")) |
| 697 self.assertEquals("101", self.MakeStep().Restore("latest")) | 730 self.assertEquals("101", self.MakeStep().Restore("latest")) |
| 698 | 731 |
| 699 | 732 |
| 700 class SystemTest(unittest.TestCase): | 733 class SystemTest(unittest.TestCase): |
| 701 def testReload(self): | 734 def testReload(self): |
| 702 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, | 735 step = MakeStep(step_class=PrepareChangeLog, number=0, state={}, config={}, |
| 703 options=None, | 736 options=None, |
| 704 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) | 737 side_effect_handler=DEFAULT_SIDE_EFFECT_HANDLER) |
| 705 body = step.Reload( | 738 body = step.Reload( |
| 706 """------------------------------------------------------------------------ | 739 """------------------------------------------------------------------------ |
| 707 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines | 740 r17997 | machenbach@chromium.org | 2013-11-22 11:04:04 +0100 (...) | 6 lines |
| 708 | 741 |
| 709 Prepare push to trunk. Now working on version 3.23.11. | 742 Prepare push to trunk. Now working on version 3.23.11. |
| 710 | 743 |
| 711 R=danno@chromium.org | 744 R=danno@chromium.org |
| 712 | 745 |
| 713 Review URL: https://codereview.chromium.org/83173002 | 746 Review URL: https://codereview.chromium.org/83173002 |
| 714 | 747 |
| 715 ------------------------------------------------------------------------""") | 748 ------------------------------------------------------------------------""") |
| 716 self.assertEquals( | 749 self.assertEquals( |
| 717 """Prepare push to trunk. Now working on version 3.23.11. | 750 """Prepare push to trunk. Now working on version 3.23.11. |
| 718 | 751 |
| 719 R=danno@chromium.org | 752 R=danno@chromium.org |
| 720 | 753 |
| 721 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 754 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
| OLD | NEW |