Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(127)

Side by Side Diff: tools/push-to-trunk/test_scripts.py

Issue 67763005: Add forced mode to push-to-trunk script. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Addressed review comments. Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
328 423
329 msg = FileToText(TEST_CONFIG[COMMITMSG_FILE]) 424 msg = FileToText(TEST_CONFIG[COMMITMSG_FILE])
330 self.assertTrue(re.search(r"Version 3\.22\.5", msg)) 425 self.assertTrue(re.search(r"Version 3\.22\.5", msg))
331 self.assertTrue(re.search(r"Performance and stability", msg)) 426 self.assertTrue(re.search(r"Performance and stability", msg))
332 self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg)) 427 self.assertTrue(re.search(r"Log text 1\. Chromium issue 12345", msg))
333 self.assertFalse(re.search(r"\d+\-\d+\-\d+", msg)) 428 self.assertFalse(re.search(r"\d+\-\d+\-\d+", msg))
334 429
335 patch = FileToText(TEST_CONFIG[ PATCH_FILE]) 430 patch = FileToText(TEST_CONFIG[ PATCH_FILE])
336 self.assertTrue(re.search(r"patch content", patch)) 431 self.assertTrue(re.search(r"patch content", patch))
337 432
338 def testPushToTrunk(self): 433 def _PushToTrunk(self, force=False):
339 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile() 434 TEST_CONFIG[DOT_GIT_LOCATION] = self.MakeEmptyTempFile()
340 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 435 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
341 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 436 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
342 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile() 437 TEST_CONFIG[CHANGELOG_FILE] = self.MakeEmptyTempFile()
343 if not os.path.exists(TEST_CONFIG[CHROMIUM]): 438 if not os.path.exists(TEST_CONFIG[CHROMIUM]):
344 os.makedirs(TEST_CONFIG[CHROMIUM]) 439 os.makedirs(TEST_CONFIG[CHROMIUM])
345 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE]) 440 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE])
346 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", 441 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line",
347 TEST_CONFIG[DEPS_FILE]) 442 TEST_CONFIG[DEPS_FILE])
348 os.environ["EDITOR"] = "vi" 443 os.environ["EDITOR"] = "vi"
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 self._rl_recipe = [ 511 self._rl_recipe = [
417 "Y", # Confirm last push. 512 "Y", # Confirm last push.
418 "", # Open editor. 513 "", # Open editor.
419 "Y", # Increment build number. 514 "Y", # Increment build number.
420 "reviewer@chromium.org", # V8 reviewer. 515 "reviewer@chromium.org", # V8 reviewer.
421 "LGTX", # Enter LGTM for V8 CL (wrong). 516 "LGTX", # Enter LGTM for V8 CL (wrong).
422 "LGTM", # Enter LGTM for V8 CL. 517 "LGTM", # Enter LGTM for V8 CL.
423 "Y", # Sanity check. 518 "Y", # Sanity check.
424 "reviewer@chromium.org", # Chromium reviewer. 519 "reviewer@chromium.org", # Chromium reviewer.
425 ] 520 ]
521 if force:
522 # TODO(machenbach): The lgtm for the prepare push is just temporary.
523 # There should be no user input in "force" mode.
524 self._rl_recipe = [
525 "LGTM", # Enter LGTM for V8 CL.
526 ]
426 527
427 class Options( object ): 528 class Options( object ):
428 pass 529 pass
429 530
430 options = Options() 531 options = Options()
431 options.s = 0 532 options.s = 0
432 options.l = None 533 options.l = None
534 options.f = force
535 options.r = "reviewer@chromium.org" if force else None
433 options.c = TEST_CONFIG[CHROMIUM] 536 options.c = TEST_CONFIG[CHROMIUM]
434 RunPushToTrunk(TEST_CONFIG, options, self) 537 RunPushToTrunk(TEST_CONFIG, options, self)
435 538
436 deps = FileToText(TEST_CONFIG[DEPS_FILE]) 539 deps = FileToText(TEST_CONFIG[DEPS_FILE])
437 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps)) 540 self.assertTrue(re.search("\"v8_revision\": \"123456\"", deps))
438 541
439 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) 542 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
440 self.assertTrue(re.search(r"\d\d\d\d\-\d+\-\d+: Version 3\.22\.5", cl)) 543 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)) 544 self.assertTrue(re.search(r" Log text 1", cl))
442 self.assertTrue(re.search(r" \(issue 321\)", cl)) 545 self.assertTrue(re.search(r" \(issue 321\)", cl))
443 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl)) 546 self.assertTrue(re.search(r"1999\-04\-05: Version 3\.22\.4", cl))
444 547
445 # Note: The version file is on build number 5 again in the end of this test 548 # 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 549 # since the git command that merges to the bleeding edge branch is mocked
447 # out. 550 # out.
551
552 def testPushToTrunk(self):
553 self._PushToTrunk()
554
555 def testPushToTrunkForced(self):
556 self._PushToTrunk(force=True)
OLDNEW
« tools/push-to-trunk/push_to_trunk.py ('K') | « tools/push-to-trunk/push_to_trunk.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698