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 VERSION_FILE: None, | 45 VERSION_FILE: None, |
46 CHANGELOG_FILE: None, | 46 CHANGELOG_FILE: None, |
47 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", | 47 CHANGELOG_ENTRY_FILE: "/tmp/test-v8-push-to-trunk-tempfile-changelog-entry", |
48 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", | 48 PATCH_FILE: "/tmp/test-v8-push-to-trunk-tempfile-patch", |
49 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", | 49 COMMITMSG_FILE: "/tmp/test-v8-push-to-trunk-tempfile-commitmsg", |
50 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", | 50 CHROMIUM: "/tmp/test-v8-push-to-trunk-tempfile-chromium", |
51 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", | 51 DEPS_FILE: "/tmp/test-v8-push-to-trunk-tempfile-chromium/DEPS", |
52 } | 52 } |
53 | 53 |
54 | 54 |
| 55 class ToplevelTest(unittest.TestCase): |
| 56 def testMakeChangeLogBodySimple(self): |
| 57 commits = lambda: [ |
| 58 [" Title text 1", |
| 59 "Title text 1\n\nBUG=\n", |
| 60 " author1@chromium.org"], |
| 61 [" Title text 2", |
| 62 "Title text 2\n\nBUG=1234\n", |
| 63 " author2@chromium.org"], |
| 64 ] |
| 65 self.assertEquals(" Title text 1\n" |
| 66 " author1@chromium.org\n\n" |
| 67 " Title text 2\n" |
| 68 " (Chromium issue 1234)\n" |
| 69 " author2@chromium.org\n\n", |
| 70 MakeChangeLogBody(commits)) |
| 71 |
| 72 def testMakeChangeLogBodyEmpty(self): |
| 73 commits = lambda: [] |
| 74 self.assertEquals("", MakeChangeLogBody(commits)) |
| 75 |
| 76 def testMakeChangeLogBugReferenceEmpty(self): |
| 77 self.assertEquals("", MakeChangeLogBugReference("")) |
| 78 self.assertEquals("", MakeChangeLogBugReference("LOG=")) |
| 79 self.assertEquals("", MakeChangeLogBugReference(" BUG =")) |
| 80 self.assertEquals("", MakeChangeLogBugReference("BUG=none\t")) |
| 81 |
| 82 def testMakeChangeLogBugReferenceSimple(self): |
| 83 self.assertEquals(" (issue 987654)\n", |
| 84 MakeChangeLogBugReference("BUG = v8:987654")) |
| 85 self.assertEquals(" (Chromium issue 987654)\n", |
| 86 MakeChangeLogBugReference("BUG=987654 ")) |
| 87 |
| 88 def testMakeChangeLogBugReferenceFromBody(self): |
| 89 self.assertEquals(" (Chromium issue 1234567)\n", |
| 90 MakeChangeLogBugReference("Title\n\nTBR=\nBUG=\n" |
| 91 " BUG=\tchromium:1234567\t\n" |
| 92 "R=somebody\n")) |
| 93 |
| 94 def testMakeChangeLogBugReferenceMultiple(self): |
| 95 # All issues should be sorted and grouped. Multiple references to the same |
| 96 # issue should be filtered. |
| 97 self.assertEquals(" (Chromium issues 123, 234, issue 345)\n", |
| 98 MakeChangeLogBugReference("Title\n\n" |
| 99 "BUG=234\n" |
| 100 " BUG\t= v8:345, \t234,\n" |
| 101 "BUG=chromium:123\n" |
| 102 "R=somebody\n")) |
| 103 self.assertEquals(" (Chromium issues 123, 234)\n", |
| 104 MakeChangeLogBugReference("Title\n\n" |
| 105 "BUG=234,,chromium:123 \n" |
| 106 "R=somebody\n")) |
| 107 self.assertEquals(" (Chromium issues 123, 234)\n", |
| 108 MakeChangeLogBugReference("Title\n\n" |
| 109 "BUG=chromium:234, , 123\n" |
| 110 "R=somebody\n")) |
| 111 self.assertEquals(" (issues 345, 456)\n", |
| 112 MakeChangeLogBugReference("Title\n\n" |
| 113 "\t\tBUG=v8:345,v8:456\n" |
| 114 "R=somebody\n")) |
| 115 self.assertEquals(" (Chromium issue 123, issues 345, 456)\n", |
| 116 MakeChangeLogBugReference("Title\n\n" |
| 117 "BUG=v8:456\n" |
| 118 "BUG = none\n" |
| 119 "R=somebody\n" |
| 120 "BUG=v8:456,123, v8:345")) |
| 121 |
| 122 def testMakeChangeLogBugReferenceLong(self): |
| 123 # -----------------00--------10--------20--------30-------- |
| 124 self.assertEquals(" (Chromium issues 234, 1234567890" |
| 125 ", 12345678901234567890, issues 12345678,\n" |
| 126 " 123456789)\n", |
| 127 MakeChangeLogBugReference("BUG=234\n" |
| 128 "BUG=1234567890\n" |
| 129 "BUG=12345678901234567890\n" |
| 130 "BUG=v8:123456789\n" |
| 131 "BUG=v8:12345678\n")) |
| 132 # -----------------00--------10--------20--------30-------- |
| 133 self.assertEquals(" (Chromium issues 234, 1234567890" |
| 134 ", 12345678901234567890, issues\n" |
| 135 " 123456789, 1234567890)\n", |
| 136 MakeChangeLogBugReference("BUG=234\n" |
| 137 "BUG=12345678901234567890\n" |
| 138 "BUG=1234567890\n" |
| 139 "BUG=v8:123456789\n" |
| 140 "BUG=v8:1234567890\n")) |
| 141 # -----------------00--------10--------20--------30-------- |
| 142 self.assertEquals(" (Chromium issues 234, 1234567890" |
| 143 ", 12345678901234567,\n" |
| 144 " 1234567890123456789)\n", |
| 145 MakeChangeLogBugReference("BUG=234\n" |
| 146 "BUG=12345678901234567\n" |
| 147 "BUG=1234567890123456789\n" |
| 148 "BUG=1234567890\n")) |
| 149 |
55 class ScriptTest(unittest.TestCase): | 150 class ScriptTest(unittest.TestCase): |
56 def MakeEmptyTempFile(self): | 151 def MakeEmptyTempFile(self): |
57 handle, name = tempfile.mkstemp() | 152 handle, name = tempfile.mkstemp() |
58 os.close(handle) | 153 os.close(handle) |
59 self._tmp_files.append(name) | 154 self._tmp_files.append(name) |
60 return name | 155 return name |
61 | 156 |
62 def MakeTempVersionFile(self): | 157 def MakeTempVersionFile(self): |
63 name = self.MakeEmptyTempFile() | 158 name = self.MakeEmptyTempFile() |
64 with open(name, "w") as f: | 159 with open(name, "w") as f: |
(...skipping 373 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
438 | 533 |
439 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) | 534 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) |
440 self.assertTrue(re.search(r"\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) | 535 self.assertTrue(re.search(r"\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) |
441 self.assertTrue(re.search(r" Log text 1", cl)) | 536 self.assertTrue(re.search(r" Log text 1", cl)) |
442 self.assertTrue(re.search(r" \(issue 321\)", cl)) | 537 self.assertTrue(re.search(r" \(issue 321\)", cl)) |
443 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) | 538 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) |
444 | 539 |
445 # Note: The version file is on build number 5 again in the end of this test | 540 # Note: The version file is on build number 5 again in the end of this test |
446 # since the git command that merges to the bleeding edge branch is mocked | 541 # since the git command that merges to the bleeding edge branch is mocked |
447 # out. | 542 # out. |
OLD | NEW |