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 525 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
536 | 536 |
537 cl_chunk = """2013-11-12: Version 3.23.2\n%s | 537 cl_chunk = """2013-11-12: Version 3.23.2\n%s |
538 Performance and stability improvements on all platforms.\n\n\n""" % l | 538 Performance and stability improvements on all platforms.\n\n\n""" % l |
539 | 539 |
540 cl_chunk_full = cl_chunk + cl_chunk + cl_chunk | 540 cl_chunk_full = cl_chunk + cl_chunk + cl_chunk |
541 TextToFile(cl_chunk_full, TEST_CONFIG[CHANGELOG_FILE]) | 541 TextToFile(cl_chunk_full, TEST_CONFIG[CHANGELOG_FILE]) |
542 | 542 |
543 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE]) | 543 cl = GetLastChangeLogEntries(TEST_CONFIG[CHANGELOG_FILE]) |
544 self.assertEquals(cl_chunk, cl) | 544 self.assertEquals(cl_chunk, cl) |
545 | 545 |
546 def testSquashCommits(self): | 546 def _TestSquashCommits(self, change_log, expected_msg): |
547 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 547 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
548 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: | 548 with open(TEST_CONFIG[CHANGELOG_ENTRY_FILE], "w") as f: |
549 f.write("1999-11-11: Version 3.22.5\n") | 549 f.write(change_log) |
550 f.write("\n") | |
551 f.write(" Log text 1.\n") | |
552 f.write(" Chromium issue 12345\n") | |
553 f.write("\n") | |
554 f.write(" Performance and stability improvements on all " | |
555 "platforms.\n") | |
556 | 550 |
557 self.ExpectGit([ | 551 self.ExpectGit([ |
558 ["diff svn/trunk hash1", "patch content"], | 552 ["diff svn/trunk hash1", "patch content"], |
559 ]) | 553 ]) |
560 | 554 |
561 self.MakeStep().Persist("prepare_commit_hash", "hash1") | 555 self.MakeStep().Persist("prepare_commit_hash", "hash1") |
562 self.MakeStep().Persist("date", "1999-11-11") | 556 self.MakeStep().Persist("date", "1999-11-11") |
563 | 557 |
564 self.MakeStep(SquashCommits).Run() | 558 self.MakeStep(SquashCommits).Run() |
565 | 559 self.assertEquals(FileToText(TEST_CONFIG[COMMITMSG_FILE]), expected_msg) |
566 msg = FileToText(TEST_CONFIG[COMMITMSG_FILE]) | |
567 self.assertTrue(re.search(r"Version 3\.22\.5", msg)) | |
568 self.assertTrue(re.search(r"Performance and stability", msg)) | |
569 self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg)) | |
570 self.assertFalse(re.search(r"\d+\-\d+\-\d+", msg)) | |
571 | 560 |
572 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) | 561 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) |
573 self.assertTrue(re.search(r"patch content", patch)) | 562 self.assertTrue(re.search(r"patch content", patch)) |
574 | 563 |
| 564 def testSquashCommitsUnformatted(self): |
| 565 change_log = """1999-11-11: Version 3.22.5 |
| 566 |
| 567 Log text 1. |
| 568 Chromium issue 12345 |
| 569 |
| 570 Performance and stability improvements on all platforms.\n""" |
| 571 commit_msg = """Version 3.22.5 |
| 572 |
| 573 Log text 1. Chromium issue 12345 |
| 574 |
| 575 Performance and stability improvements on all platforms.""" |
| 576 self._TestSquashCommits(change_log, commit_msg) |
| 577 |
| 578 def testSquashCommitsFormatted(self): |
| 579 change_log = """1999-11-11: Version 3.22.5 |
| 580 |
| 581 Long commit message that fills more than 80 characters (Chromium issue |
| 582 12345). |
| 583 |
| 584 Performance and stability improvements on all platforms.\n""" |
| 585 commit_msg = """Version 3.22.5 |
| 586 |
| 587 Long commit message that fills more than 80 characters (Chromium issue 12345). |
| 588 |
| 589 Performance and stability improvements on all platforms.""" |
| 590 self._TestSquashCommits(change_log, commit_msg) |
| 591 |
| 592 def testSquashCommitsQuotationMarks(self): |
| 593 change_log = """Line with "quotation marks".\n""" |
| 594 commit_msg = """Line with "quotation marks".""" |
| 595 self._TestSquashCommits(change_log, commit_msg) |
| 596 |
575 def _PushToTrunk(self, force=False, manual=False): | 597 def _PushToTrunk(self, force=False, manual=False): |
576 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() | 598 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() |
577 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() | 599 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() |
578 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() | 600 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() |
579 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() | 601 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() |
580 if not os.path.exists(TEST_CONFIG[CHROMIUM]): | 602 if not os.path.exists(TEST_CONFIG[CHROMIUM]): |
581 os.makedirs(TEST_CONFIG[CHROMIUM]) | 603 os.makedirs(TEST_CONFIG[CHROMIUM]) |
582 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE]) | 604 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE]) |
583 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", | 605 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", |
584 TEST_CONFIG[DEPS_FILE]) | 606 TEST_CONFIG[DEPS_FILE]) |
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 | 767 |
746 Review URL: https://codereview.chromium.org/83173002 | 768 Review URL: https://codereview.chromium.org/83173002 |
747 | 769 |
748 ------------------------------------------------------------------------""") | 770 ------------------------------------------------------------------------""") |
749 self.assertEquals( | 771 self.assertEquals( |
750 """Prepare push to trunk. Now working on version 3.23.11. | 772 """Prepare push to trunk. Now working on version 3.23.11. |
751 | 773 |
752 R=danno@chromium.org | 774 R=danno@chromium.org |
753 | 775 |
754 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) | 776 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) |
OLD | NEW |