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 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
45 | 45 |
46 TEST_CONFIG = { | 46 TEST_CONFIG = { |
47 BRANCHNAME: "test-prepare-push", | 47 BRANCHNAME: "test-prepare-push", |
48 TRUNKBRANCH: "test-trunk-push", | 48 TRUNKBRANCH: "test-trunk-push", |
49 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", | 49 PERSISTFILE_BASENAME: "/tmp/test-v8-push-to-trunk-tempfile", |
50 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", | 50 TEMP_BRANCH: "test-prepare-push-temporary-branch-created-by-script", |
51 DOT_GIT_LOCATION: None, | 51 DOT_GIT_LOCATION: None, |
52 VERSION_FILE: None, | 52 VERSION_FILE: None, |
53 CHANGELOG_FILE: None, | 53 CHANGELOG_FILE: None, |
54 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", | 54 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", |
55 NEW_CHANGELOG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-new-changelog", | |
56 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", | 55 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", |
57 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", | 56 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", |
58 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", | 57 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", |
59 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", | 58 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", |
60 SETTINGS_LOCATION: None, | 59 SETTINGS_LOCATION: None, |
61 ALREADY_MERGING_SENTINEL_FILE: | 60 ALREADY_MERGING_SENTINEL_FILE: |
62 "/tmp/test-merge-to-branch-tempfile-already-merging", | 61 "/tmp/test-merge-to-branch-tempfile-already-merging", |
63 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", | 62 COMMIT_HASHES_FILE: "/tmp/test-merge-to-branch-tempfile-PATCH_COMMIT_HASHES", |
64 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch", | 63 TEMPORARY_PATCH_FILE: "/tmp/test-merge-to-branch-tempfile-temporary-patch", |
65 } | 64 } |
(...skipping 465 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
531 #""" | 530 #""" |
532 | 531 |
533 self.assertEquals(expected_cl, actual_cl) | 532 self.assertEquals(expected_cl, actual_cl) |
534 self.assertEquals("3", self._state["major"]) | 533 self.assertEquals("3", self._state["major"]) |
535 self.assertEquals("22", self._state["minor"]) | 534 self.assertEquals("22", self._state["minor"]) |
536 self.assertEquals("5", self._state["build"]) | 535 self.assertEquals("5", self._state["build"]) |
537 self.assertEquals("0", self._state["patch"]) | 536 self.assertEquals("0", self._state["patch"]) |
538 | 537 |
539 def testEditChangeLog(self): | 538 def testEditChangeLog(self): |
540 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 539 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
541 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | |
542 TextToFile(" Original CL", TEST_CONFIG[CHANGELOG_FILE]) | |
543 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) | 540 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) |
544 os.environ["EDITOR"] = "vi" | 541 os.environ["EDITOR"] = "vi" |
545 | 542 |
546 self.ExpectReadline([ | 543 self.ExpectReadline([ |
547 RL(""), # Open editor. | 544 RL(""), # Open editor. |
548 ]) | 545 ]) |
549 | 546 |
550 self.RunStep(PushToTrunk, EditChangeLog) | 547 self.RunStep(PushToTrunk, EditChangeLog) |
551 | 548 |
552 self.assertEquals("New\n Lines\n\n\n Original CL", | 549 self.assertEquals("New\n Lines", |
553 FileToText(TEST_CONFIG[CHANGELOG_FILE])) | 550 FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])) |
554 | 551 |
555 def testIncrementVersion(self): | 552 def testIncrementVersion(self): |
556 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 553 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
557 self._state["build"] = "5" | 554 self._state["build"] = "5" |
558 | 555 |
559 self.ExpectReadline([ | 556 self.ExpectReadline([ |
560 RL("Y"), # Increment build number. | 557 RL("Y"), # Increment build number. |
561 ]) | 558 ]) |
562 | 559 |
563 self.RunStep(PushToTrunk, IncrementVersion) | 560 self.RunStep(PushToTrunk, IncrementVersion) |
564 | 561 |
565 self.assertEquals("3", self._state["new_major"]) | 562 self.assertEquals("3", self._state["new_major"]) |
566 self.assertEquals("22", self._state["new_minor"]) | 563 self.assertEquals("22", self._state["new_minor"]) |
567 self.assertEquals("6", self._state["new_build"]) | 564 self.assertEquals("6", self._state["new_build"]) |
568 self.assertEquals("0", self._state["new_patch"]) | 565 self.assertEquals("0", self._state["new_patch"]) |
569 | 566 |
570 def testLastChangeLogEntries(self): | |
571 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | |
572 l = """ | |
573 Fixed something. | |
574 (issue 1234)\n""" | |
575 for _ in xrange(10): l = l + l | |
576 | |
577 cl_chunk = """2013-11-12: Version 3.23.2\n%s | |
578 Performance and stability improvements on all platforms.\n\n\n""" % l | |
579 | |
580 cl_chunk_full = cl_chunk + cl_chunk + cl_chunk | |
581 TextToFile(cl_chunk_full, TEST_CONFIG[CHANGELOG_FILE]) | |
582 | |
583 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE]) | |
584 self.assertEquals(cl_chunk, cl) | |
585 | |
586 def _TestSquashCommits(self, change_log, expected_msg): | 567 def _TestSquashCommits(self, change_log, expected_msg): |
587 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 568 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
588 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: | 569 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: |
589 f.write(change_log) | 570 f.write(change_log) |
590 | 571 |
591 self.ExpectGit([ | 572 self.ExpectGit([ |
592 Git("diff svn/trunk hash1", "patch content"), | 573 Git("diff svn/trunk hash1", "patch content"), |
593 Git("svn find-rev hash1", "123455\n"), | 574 Git("svn find-rev hash1", "123455\n"), |
594 ]) | 575 ]) |
595 | 576 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
635 commit_msg = """Line with "quotation marks".""" | 616 commit_msg = """Line with "quotation marks".""" |
636 self._TestSquashCommits(change_log, commit_msg) | 617 self._TestSquashCommits(change_log, commit_msg) |
637 | 618 |
638 def _PushToTrunk(self, force=False, manual=False): | 619 def _PushToTrunk(self, force=False, manual=False): |
639 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 620 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
640 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 621 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
641 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 622 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
642 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | 623 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
643 if not os.path.exists(TEST_CONFIG[CHROMIUM]): | 624 if not os.path.exists(TEST_CONFIG[CHROMIUM]): |
644 os.makedirs(TEST_CONFIG[CHROMIUM]) | 625 os.makedirs(TEST_CONFIG[CHROMIUM]) |
645 bleeding_edge_change_log = """1999-02-03: Version 3.12.2 | 626 bleeding_edge_change_log = "2014-03-17: Sentinel\n" |
646 | |
647 Performance and stability improvements on all platforms.\n""" | |
648 TextToFile(bleeding_edge_change_log, TEST_CONFIG[CHANGELOG_FILE]) | 627 TextToFile(bleeding_edge_change_log, TEST_CONFIG[CHANGELOG_FILE]) |
649 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", | 628 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", |
650 TEST_CONFIG[DEPS_FILE]) | 629 TEST_CONFIG[DEPS_FILE]) |
651 os.environ["EDITOR"] = "vi" | 630 os.environ["EDITOR"] = "vi" |
652 | 631 |
653 def CheckPreparePush(): | 632 def CheckPreparePush(): |
654 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) | 633 self.assertEquals(bleeding_edge_change_log, |
655 self.assertTrue(re.search(r"Version 3.22.5", cl)) | 634 FileToText(TEST_CONFIG[CHANGELOG_FILE])) |
656 self.assertTrue(re.search(r" Log text 1 \(issue 321\).", cl)) | |
657 self.assertFalse(re.search(r" \(author1@chromium\.org\)", cl)) | |
658 | |
659 # Make sure all comments got stripped. | |
660 self.assertFalse(re.search(r"^#", cl, flags=re.M)) | |
661 | 635 |
662 version = FileToText(TEST_CONFIG[VERSION_FILE]) | 636 version = FileToText(TEST_CONFIG[VERSION_FILE]) |
663 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version)) | 637 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version)) |
664 | 638 |
665 def ResetChangeLog(): | 639 def ResetChangeLog(): |
666 """On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog', | 640 """On 'git co -b new_branch svn/trunk', and 'git checkout -- ChangeLog', |
667 the ChangLog will be reset to its content on trunk.""" | 641 the ChangLog will be reset to its content on trunk.""" |
668 trunk_change_log = """1999-04-05: Version 3.22.4 | 642 trunk_change_log = """1999-04-05: Version 3.22.4 |
669 | 643 |
670 Performance and stability improvements on all platforms.\n""" | 644 Performance and stability improvements on all platforms.\n""" |
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1042 | 1016 |
1043 Review URL: https://codereview.chromium.org/83173002 | 1017 Review URL: https://codereview.chromium.org/83173002 |
1044 | 1018 |
1045 ------------------------------------------------------------------------""") | 1019 ------------------------------------------------------------------------""") |
1046 self.assertEquals( | 1020 self.assertEquals( |
1047 """Prepare push to trunk. Now working on version 3.23.11. | 1021 """Prepare push to trunk. Now working on version 3.23.11. |
1048 | 1022 |
1049 R=danno@chromium.org | 1023 R=danno@chromium.org |
1050 | 1024 |
1051 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 1025 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
OLD | NEW |