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

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

Issue 81193002: Pythonification and refactoring of push-to-trunk. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Refactor step generation. 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
« no previous file with comments | « tools/push-to-trunk/push_to_trunk.py ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
61 MakeComment("Line 1\n Line 2")) 61 MakeComment("Line 1\n Line 2"))
62 62
63 def testStripComments(self): 63 def testStripComments(self):
64 self.assertEquals(" Line 1\n Line 3\n", 64 self.assertEquals(" Line 1\n Line 3\n",
65 StripComments(" Line 1\n# Line 2\n Line 3\n#\n")) 65 StripComments(" Line 1\n# Line 2\n Line 3\n#\n"))
66 self.assertEquals("\nLine 2 ### Test\n #", 66 self.assertEquals("\nLine 2 ### Test\n #",
67 StripComments("###\n# \n\n# Line 1\nLine 2 ### Test\n #")) 67 StripComments("###\n# \n\n# Line 1\nLine 2 ### Test\n #"))
68 68
69 def testMakeChangeLogBodySimple(self): 69 def testMakeChangeLogBodySimple(self):
70 commits = [ 70 commits = [
71 [" Title text 1", 71 ["Title text 1",
72 "Title text 1\n\nBUG=\n", 72 "Title text 1\n\nBUG=\n",
73 " author1@chromium.org"], 73 "author1@chromium.org"],
74 [" Title text 2", 74 ["Title text 2",
75 "Title text 2\n\nBUG=1234\n", 75 "Title text 2\n\nBUG=1234\n",
76 " author2@chromium.org"], 76 "author2@chromium.org"],
77 ] 77 ]
78 self.assertEquals(" Title text 1\n" 78 self.assertEquals(" Title text 1\n"
79 " author1@chromium.org\n\n" 79 " (author1@chromium.org)\n\n"
80 " Title text 2\n" 80 " Title text 2\n"
81 " (Chromium issue 1234)\n" 81 " (Chromium issue 1234)\n"
82 " author2@chromium.org\n\n", 82 " (author2@chromium.org)\n\n",
83 MakeChangeLogBody(commits)) 83 MakeChangeLogBody(commits))
84 84
85 def testMakeChangeLogBodyEmpty(self): 85 def testMakeChangeLogBodyEmpty(self):
86 self.assertEquals("", MakeChangeLogBody([])) 86 self.assertEquals("", MakeChangeLogBody([]))
87 87
88 def testMakeChangeLogBodyAutoFormat(self): 88 def testMakeChangeLogBodyAutoFormat(self):
89 commits = [ 89 commits = [
90 [" Title text 1", 90 ["Title text 1",
91 "Title text 1\nLOG=y\nBUG=\n", 91 "Title text 1\nLOG=y\nBUG=\n",
92 " author1@chromium.org"], 92 "author1@chromium.org"],
93 [" Title text 2", 93 ["Title text 2",
94 "Title text 2\n\nBUG=1234\n", 94 "Title text 2\n\nBUG=1234\n",
95 " author2@chromium.org"], 95 "author2@chromium.org"],
96 [" Title text 3", 96 ["Title text 3",
97 "Title text 3\n\nBUG=1234\nLOG = Yes\n", 97 "Title text 3\n\nBUG=1234\nLOG = Yes\n",
98 " author3@chromium.org"], 98 "author3@chromium.org"],
99 [" Title text 3", 99 ["Title text 3",
100 "Title text 4\n\nBUG=1234\nLOG=\n", 100 "Title text 4\n\nBUG=1234\nLOG=\n",
101 " author4@chromium.org"], 101 "author4@chromium.org"],
102 ] 102 ]
103 self.assertEquals(" Title text 1\n\n" 103 self.assertEquals(" Title text 1\n\n"
104 " Title text 3\n" 104 " Title text 3\n"
105 " (Chromium issue 1234)\n\n", 105 " (Chromium issue 1234)\n\n",
106 MakeChangeLogBody(commits, True)) 106 MakeChangeLogBody(commits, True))
107 107
108 def testMakeChangeLogBugReferenceEmpty(self): 108 def testMakeChangeLogBugReferenceEmpty(self):
109 self.assertEquals("", MakeChangeLogBugReference("")) 109 self.assertEquals("", MakeChangeLogBugReference(""))
110 self.assertEquals("", MakeChangeLogBugReference("LOG=")) 110 self.assertEquals("", MakeChangeLogBugReference("LOG="))
111 self.assertEquals("", MakeChangeLogBugReference(" BUG =")) 111 self.assertEquals("", MakeChangeLogBugReference(" BUG ="))
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
238 f.write("\n") 238 f.write("\n")
239 f.write("#define MAJOR_VERSION 3\n") 239 f.write("#define MAJOR_VERSION 3\n")
240 f.write("#define MINOR_VERSION 22\n") 240 f.write("#define MINOR_VERSION 22\n")
241 f.write("#define BUILD_NUMBER 5\n") 241 f.write("#define BUILD_NUMBER 5\n")
242 f.write("#define PATCH_LEVEL 0\n") 242 f.write("#define PATCH_LEVEL 0\n")
243 f.write(" // Some line...\n") 243 f.write(" // Some line...\n")
244 f.write("#define IS_CANDIDATE_VERSION 0\n") 244 f.write("#define IS_CANDIDATE_VERSION 0\n")
245 return name 245 return name
246 246
247 def MakeStep(self, step_class=Step, state=None): 247 def MakeStep(self, step_class=Step, state=None):
248 state = state or {} 248 """Convenience wrapper."""
249 step = step_class() 249 return MakeStep(step_class=step_class, number=0, state=state,
250 step.SetConfig(TEST_CONFIG) 250 config=TEST_CONFIG, options=None, side_effect_handler=self)
251 step.SetState(state)
252 step.SetNumber(0)
253 step.SetSideEffectHandler(self)
254 return step
255 251
256 def GitMock(self, cmd, args="", pipe=True): 252 def GitMock(self, cmd, args="", pipe=True):
257 return self._git_mock.Call(args) 253 return self._git_mock.Call(args)
258 254
259 def LogMock(self, cmd, args=""): 255 def LogMock(self, cmd, args=""):
260 print "Log: %s %s" % (cmd, args) 256 print "Log: %s %s" % (cmd, args)
261 257
262 MOCKS = { 258 MOCKS = {
263 "git": GitMock, 259 "git": GitMock,
264 "vi": LogMock, 260 "vi": LogMock,
(...skipping 130 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$", 391 MSub(r"(?<=#define BUILD_NUMBER)(?P<space>\s+)\d*$",
396 r"\g<space>3", 392 r"\g<space>3",
397 "//\n#define BUILD_NUMBER 321\n")) 393 "//\n#define BUILD_NUMBER 321\n"))
398 394
399 def testPrepareChangeLog(self): 395 def testPrepareChangeLog(self):
400 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile() 396 TEST_CONFIG[VERSION_FILE] = self.MakeTempVersionFile()
401 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 397 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
402 398
403 self.ExpectGit([ 399 self.ExpectGit([
404 ["log 1234..HEAD --format=%H", "rev1\nrev2\nrev3"], 400 ["log 1234..HEAD --format=%H", "rev1\nrev2\nrev3"],
405 ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Title text 1"], 401 ["log -1 rev1 --format=\"%s\"", "Title text 1"],
406 ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\nLOG=y\n"], 402 ["log -1 rev1 --format=\"%B\"", "Title\n\nBUG=\nLOG=y\n"],
407 ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", 403 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org"],
408 " author1@chromium.org"], 404 ["log -1 rev2 --format=\"%s\"", "Title text 2"],
409 ["log -1 rev2 --format=\"%w(80,8,8)%s\"", " Title text 2"],
410 ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=123\nLOG= \n"], 405 ["log -1 rev2 --format=\"%B\"", "Title\n\nBUG=123\nLOG= \n"],
411 ["log -1 rev2 --format=\"%w(80,8,8)(%an)\"", 406 ["log -1 rev2 --format=\"%an\"", "author2@chromium.org"],
412 " author2@chromium.org"], 407 ["log -1 rev3 --format=\"%s\"", "Title text 3"],
413 ["log -1 rev3 --format=\"%w(80,8,8)%s\"", " Title text 3"],
414 ["log -1 rev3 --format=\"%B\"", "Title\n\nBUG=321\nLOG=true\n"], 408 ["log -1 rev3 --format=\"%B\"", "Title\n\nBUG=321\nLOG=true\n"],
415 ["log -1 rev3 --format=\"%w(80,8,8)(%an)\"", 409 ["log -1 rev3 --format=\"%an\"", "author3@chromium.org"],
416 " author3@chromium.org"],
417 ]) 410 ])
418 411
419 self.MakeStep().Persist("last_push", "1234") 412 self.MakeStep().Persist("last_push", "1234")
420 self.MakeStep(PrepareChangeLog).Run() 413 self.MakeStep(PrepareChangeLog).Run()
421 414
422 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 415 actual_cl = FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])
423 416
424 # TODO(machenbach): Mock out call to date() in order to make a fixed 417 # TODO(machenbach): Mock out call to date() in order to make a fixed
425 # comparison here instead of a regexp match. 418 # comparison here instead of a regexp match.
426 expected_cl = """\\d+\\-\\d+\\-\\d+: Version 3\\.22\\.5 419 expected_cl = """\\d+\\-\\d+\\-\\d+: Version 3\\.22\\.5
427 420
428 Title text 1 421 Title text 1
429 422
430 Title text 3 423 Title text 3
431 \\(Chromium issue 321\\) 424 \\(Chromium issue 321\\)
432 425
433 Performance and stability improvements on all platforms\\. 426 Performance and stability improvements on all platforms\\.
434 # 427 #
435 # The change log above is auto-generated\\. Please review if all relevant 428 # The change log above is auto-generated\\. Please review if all relevant
436 # commit messages from the list below are included\\. 429 # commit messages from the list below are included\\.
437 # All lines starting with # will be stripped\\. 430 # All lines starting with # will be stripped\\.
438 # 431 #
439 # Title text 1 432 # Title text 1
440 # author1@chromium\\.org 433 # \\(author1@chromium\\.org\\)
441 # 434 #
442 # Title text 2 435 # Title text 2
443 # \\(Chromium issue 123\\) 436 # \\(Chromium issue 123\\)
444 # author2@chromium\\.org 437 # \\(author2@chromium\\.org\\)
445 # 438 #
446 # Title text 3 439 # Title text 3
447 # \\(Chromium issue 321\\) 440 # \\(Chromium issue 321\\)
448 # author3@chromium\\.org 441 # \\(author3@chromium\\.org\\)
449 # 442 #
450 #""" 443 #"""
451 444
452 self.assertTrue(re.match(expected_cl, actual_cl)) 445 self.assertTrue(re.match(expected_cl, actual_cl))
453 self.assertEquals("3", self.MakeStep().Restore("major")) 446 self.assertEquals("3", self.MakeStep().Restore("major"))
454 self.assertEquals("22", self.MakeStep().Restore("minor")) 447 self.assertEquals("22", self.MakeStep().Restore("minor"))
455 self.assertEquals("5", self.MakeStep().Restore("build")) 448 self.assertEquals("5", self.MakeStep().Restore("build"))
456 self.assertEquals("0", self.MakeStep().Restore("patch")) 449 self.assertEquals("0", self.MakeStep().Restore("patch"))
457 450
458 def testEditChangeLog(self): 451 def testEditChangeLog(self):
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
541 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE]) 534 TextToFile("1999-04-05: Version 3.22.4", TEST_CONFIG[CHANGELOG_FILE])
542 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line", 535 TextToFile("Some line\n \"v8_revision\": \"123444\",\n some line",
543 TEST_CONFIG[DEPS_FILE]) 536 TEST_CONFIG[DEPS_FILE])
544 os.environ["EDITOR"] = "vi" 537 os.environ["EDITOR"] = "vi"
545 538
546 def CheckPreparePush(): 539 def CheckPreparePush():
547 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) 540 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
548 self.assertTrue(re.search(r"Version 3.22.5", cl)) 541 self.assertTrue(re.search(r"Version 3.22.5", cl))
549 self.assertTrue(re.search(r" Log text 1", cl)) 542 self.assertTrue(re.search(r" Log text 1", cl))
550 self.assertTrue(re.search(r" \(issue 321\)", cl)) 543 self.assertTrue(re.search(r" \(issue 321\)", cl))
551 self.assertFalse(re.search(r" author1@chromium\.org", cl)) 544 self.assertFalse(re.search(r" \(author1@chromium\.org\)", cl))
552 545
553 # Make sure all comments got stripped. 546 # Make sure all comments got stripped.
554 self.assertFalse(re.search(r"^#", cl, flags=re.M)) 547 self.assertFalse(re.search(r"^#", cl, flags=re.M))
555 548
556 version = FileToText(TEST_CONFIG[VERSION_FILE]) 549 version = FileToText(TEST_CONFIG[VERSION_FILE])
557 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version)) 550 self.assertTrue(re.search(r"#define BUILD_NUMBER\s+6", version))
558 551
559 def CheckUpload(): 552 def CheckUpload():
560 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE]) 553 cl = FileToText(TEST_CONFIG[CHANGELOG_FILE])
561 554
(...skipping 14 matching lines...) Expand all
576 ["status -s -b -uno", "## some_branch\n"], 569 ["status -s -b -uno", "## some_branch\n"],
577 ["svn fetch", ""], 570 ["svn fetch", ""],
578 ["branch", " branch1\n* branch2\n"], 571 ["branch", " branch1\n* branch2\n"],
579 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], 572 ["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""],
580 ["branch", " branch1\n* branch2\n"], 573 ["branch", " branch1\n* branch2\n"],
581 ["branch", " branch1\n* branch2\n"], 574 ["branch", " branch1\n* branch2\n"],
582 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], 575 ["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""],
583 ["log -1 --format=%H ChangeLog", "1234\n"], 576 ["log -1 --format=%H ChangeLog", "1234\n"],
584 ["log -1 1234", "Last push ouput\n"], 577 ["log -1 1234", "Last push ouput\n"],
585 ["log 1234..HEAD --format=%H", "rev1\n"], 578 ["log 1234..HEAD --format=%H", "rev1\n"],
586 ["log -1 rev1 --format=\"%w(80,8,8)%s\"", " Log text 1.\n"], 579 ["log -1 rev1 --format=\"%s\"", "Log text 1.\n"],
587 ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"], 580 ["log -1 rev1 --format=\"%B\"", "Text\nLOG=YES\nBUG=v8:321\nText\n"],
588 ["log -1 rev1 --format=\"%w(80,8,8)(%an)\"", 581 ["log -1 rev1 --format=\"%an\"", "author1@chromium.org\n"],
589 " author1@chromium.org\n"],
590 [("commit -a -m \"Prepare push to trunk. " 582 [("commit -a -m \"Prepare push to trunk. "
591 "Now working on version 3.22.6.\""), 583 "Now working on version 3.22.6.\""),
592 " 2 files changed\n", 584 " 2 files changed\n",
593 CheckPreparePush], 585 CheckPreparePush],
594 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag, 586 ["cl upload -r \"reviewer@chromium.org\" --send-mail%s" % force_flag,
595 "done\n"], 587 "done\n"],
596 ["cl dcommit -f", "Closing issue\n"], 588 ["cl dcommit -f", "Closing issue\n"],
597 ["svn fetch", "fetch result\n"], 589 ["svn fetch", "fetch result\n"],
598 ["checkout svn/bleeding_edge", ""], 590 ["checkout svn/bleeding_edge", ""],
599 [("log -1 --format=%H --grep=\"Prepare push to trunk. " 591 [("log -1 --format=%H --grep=\"Prepare push to trunk. "
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 class Options( object ): 679 class Options( object ):
688 pass 680 pass
689 681
690 options = Options() 682 options = Options()
691 options.s = 0 683 options.s = 0
692 684
693 auto_roll.RunAutoRoll(TEST_CONFIG, options, self) 685 auto_roll.RunAutoRoll(TEST_CONFIG, options, self)
694 686
695 self.assertEquals("100", self.MakeStep().Restore("lkgr")) 687 self.assertEquals("100", self.MakeStep().Restore("lkgr"))
696 self.assertEquals("101", self.MakeStep().Restore("latest")) 688 self.assertEquals("101", self.MakeStep().Restore("latest"))
OLDNEW
« no previous file with comments | « 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