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

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

Issue 527953002: Refactoring: Unify mocks of different commands in auto roll tests. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 3 months 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 | « no previous file | 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 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
358 358
359 def RunStep(self, script=PushToTrunk, step_class=Step, args=None): 359 def RunStep(self, script=PushToTrunk, step_class=Step, args=None):
360 """Convenience wrapper.""" 360 """Convenience wrapper."""
361 args = args if args is not None else ["-m"] 361 args = args if args is not None else ["-m"]
362 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args) 362 return script(TEST_CONFIG, self, self._state).RunSteps([step_class], args)
363 363
364 def CmdMock(self, cmd, args="", pipe=True): 364 def CmdMock(self, cmd, args="", pipe=True):
365 print "%s %s" % (cmd, args) 365 print "%s %s" % (cmd, args)
366 return self._cmd_mock.Call(cmd + " " + args) 366 return self._cmd_mock.Call(cmd + " " + args)
367 367
368 def LogMock(self, cmd, args=""):
369 print "Log: %s %s" % (cmd, args)
370
371 MOCKS = {
372 "gclient": CmdMock,
373 "git": CmdMock,
374 "roll-dep": CmdMock,
375 "svn": CmdMock,
376 "vi": LogMock,
377 }
378
379 def Call(self, fun, *args, **kwargs): 368 def Call(self, fun, *args, **kwargs):
380 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs)) 369 print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs))
381 370
382 def Command(self, cmd, args="", prefix="", pipe=True): 371 def Command(self, cmd, args="", prefix="", pipe=True):
383 return ScriptTest.MOCKS[cmd](self, cmd, args) 372 return self.CmdMock(cmd, args)
384 373
385 def ReadLine(self): 374 def ReadLine(self):
386 return self._rl_mock.Call() 375 return self._rl_mock.Call()
387 376
388 def ReadURL(self, url, params): 377 def ReadURL(self, url, params):
389 if params is not None: 378 if params is not None:
390 return self._url_mock.Call(url, params) 379 return self._url_mock.Call(url, params)
391 else: 380 else:
392 return self._url_mock.Call(url) 381 return self._url_mock.Call(url)
393 382
(...skipping 195 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 # (author4@chromium.org) 578 # (author4@chromium.org)
590 # 579 #
591 #""" 580 #"""
592 581
593 self.assertEquals(expected_cl, actual_cl) 582 self.assertEquals(expected_cl, actual_cl)
594 583
595 def testEditChangeLog(self): 584 def testEditChangeLog(self):
596 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() 585 TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
597 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE]) 586 TextToFile(" New \n\tLines \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE])
598 os.environ["EDITOR"] = "vi" 587 os.environ["EDITOR"] = "vi"
599 588 self.ExpectCmd([
589 Cmd("vi %s" % TEST_CONFIG[CHANGELOG_ENTRY_FILE], ""),
590 ])
600 self.ExpectReadline([ 591 self.ExpectReadline([
601 RL(""), # Open editor. 592 RL(""), # Open editor.
602 ]) 593 ])
603 594
604 self.RunStep(PushToTrunk, EditChangeLog) 595 self.RunStep(PushToTrunk, EditChangeLog)
605 596
606 self.assertEquals("New\n Lines", 597 self.assertEquals("New\n Lines",
607 FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE])) 598 FileToText(TEST_CONFIG[CHANGELOG_ENTRY_FILE]))
608 599
609 # Version on trunk: 3.22.4.0. Version on master (bleeding_edge): 3.22.6. 600 # Version on trunk: 3.22.4.0. Version on master (bleeding_edge): 3.22.6.
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
735 726
736 Performance and stability improvements on all platforms. 727 Performance and stability improvements on all platforms.
737 728
738 729
739 1999-04-05: Version 3.22.4 730 1999-04-05: Version 3.22.4
740 731
741 Performance and stability improvements on all platforms.\n""", 732 Performance and stability improvements on all platforms.\n""",
742 change_log) 733 change_log)
743 734
744 force_flag = " -f" if not manual else "" 735 force_flag = " -f" if not manual else ""
745 self.ExpectCmd([ 736 expectations = [
746 Cmd("git status -s -uno", ""), 737 Cmd("git status -s -uno", ""),
747 Cmd("git status -s -b -uno", "## some_branch\n"), 738 Cmd("git status -s -b -uno", "## some_branch\n"),
748 Cmd("git svn fetch", ""), 739 Cmd("git svn fetch", ""),
749 Cmd("git branch", " branch1\n* branch2\n"), 740 Cmd("git branch", " branch1\n* branch2\n"),
750 Cmd("git branch", " branch1\n* branch2\n"), 741 Cmd("git branch", " branch1\n* branch2\n"),
751 Cmd("git checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], 742 Cmd("git checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME],
752 ""), 743 ""),
753 Cmd("git svn find-rev r123455", "push_hash\n"), 744 Cmd("git svn find-rev r123455", "push_hash\n"),
754 Cmd(("git log -1 --format=%H --grep=" 745 Cmd(("git log -1 --format=%H --grep="
755 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " 746 "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
756 "svn/trunk"), "hash2\n"), 747 "svn/trunk"), "hash2\n"),
757 Cmd("git log -1 hash2", "Log message\n"), 748 Cmd("git log -1 hash2", "Log message\n"),
758 Cmd("git log -1 --format=%s hash2", 749 Cmd("git log -1 --format=%s hash2",
759 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"), 750 "Version 3.4.5 (based on bleeding_edge revision r1234)\n"),
760 Cmd("git svn find-rev r1234", "hash3\n"), 751 Cmd("git svn find-rev r1234", "hash3\n"),
761 Cmd(("git checkout -f svn/bleeding_edge -- %s" % 752 Cmd(("git checkout -f svn/bleeding_edge -- %s" %
762 TEST_CONFIG[VERSION_FILE]), 753 TEST_CONFIG[VERSION_FILE]),
763 "", cb=self.WriteFakeVersionFile), 754 "", cb=self.WriteFakeVersionFile),
764 Cmd("git checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "", 755 Cmd("git checkout -f hash2 -- %s" % TEST_CONFIG[VERSION_FILE], "",
765 cb=self.WriteFakeVersionFile), 756 cb=self.WriteFakeVersionFile),
766 Cmd("git log --format=%H hash3..push_hash", "rev1\n"), 757 Cmd("git log --format=%H hash3..push_hash", "rev1\n"),
767 Cmd("git log -1 --format=%s rev1", "Log text 1.\n"), 758 Cmd("git log -1 --format=%s rev1", "Log text 1.\n"),
768 Cmd("git log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"), 759 Cmd("git log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
769 Cmd("git log -1 --format=%an rev1", "author1@chromium.org\n"), 760 Cmd("git log -1 --format=%an rev1", "author1@chromium.org\n"),
761 ]
762 if not force:
763 expectations.append(Cmd("vi %s" % TEST_CONFIG[CHANGELOG_ENTRY_FILE], ""))
764 expectations += [
770 Cmd("git svn fetch", "fetch result\n"), 765 Cmd("git svn fetch", "fetch result\n"),
771 Cmd("git checkout -f svn/bleeding_edge", ""), 766 Cmd("git checkout -f svn/bleeding_edge", ""),
772 Cmd("git diff svn/trunk push_hash", "patch content\n"), 767 Cmd("git diff svn/trunk push_hash", "patch content\n"),
773 Cmd("git svn find-rev push_hash", "123455\n"), 768 Cmd("git svn find-rev push_hash", "123455\n"),
774 Cmd("git checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], "", 769 Cmd("git checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], "",
775 cb=ResetToTrunk), 770 cb=ResetToTrunk),
776 Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""), 771 Cmd("git apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""),
777 Cmd("git checkout -f svn/trunk -- %s" % TEST_CONFIG[CHANGELOG_FILE], "", 772 Cmd("git checkout -f svn/trunk -- %s" % TEST_CONFIG[CHANGELOG_FILE], "",
778 cb=ResetChangeLog), 773 cb=ResetChangeLog),
779 Cmd("git checkout -f svn/trunk -- %s" % TEST_CONFIG[VERSION_FILE], "", 774 Cmd("git checkout -f svn/trunk -- %s" % TEST_CONFIG[VERSION_FILE], "",
780 cb=self.WriteFakeVersionFile), 775 cb=self.WriteFakeVersionFile),
781 Cmd("git commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", 776 Cmd("git commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "",
782 cb=CheckSVNCommit), 777 cb=CheckSVNCommit),
783 Cmd("git svn dcommit 2>&1", 778 Cmd("git svn dcommit 2>&1",
784 "Some output\nCommitted r123456\nSome output\n"), 779 "Some output\nCommitted r123456\nSome output\n"),
785 Cmd("git svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""), 780 Cmd("git svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""),
786 Cmd("git checkout -f some_branch", ""), 781 Cmd("git checkout -f some_branch", ""),
787 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""), 782 Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""),
788 Cmd("git branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""), 783 Cmd("git branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""),
789 ]) 784 ]
785 self.ExpectCmd(expectations)
790 786
791 # Expected keyboard input in manual mode: 787 # Expected keyboard input in manual mode:
792 if manual: 788 if manual:
793 self.ExpectReadline([ 789 self.ExpectReadline([
794 RL("Y"), # Confirm last push. 790 RL("Y"), # Confirm last push.
795 RL(""), # Open editor. 791 RL(""), # Open editor.
796 RL("Y"), # Increment build number. 792 RL("Y"), # Increment build number.
797 RL("Y"), # Sanity check. 793 RL("Y"), # Sanity check.
798 ]) 794 ])
799 795
(...skipping 744 matching lines...) Expand 10 before | Expand all | Expand 10 after
1544 1540
1545 Review URL: https://codereview.chromium.org/83173002 1541 Review URL: https://codereview.chromium.org/83173002
1546 1542
1547 ------------------------------------------------------------------------""") 1543 ------------------------------------------------------------------------""")
1548 self.assertEquals( 1544 self.assertEquals(
1549 """Prepare push to trunk. Now working on version 3.23.11. 1545 """Prepare push to trunk. Now working on version 3.23.11.
1550 1546
1551 R=danno@chromium.org 1547 R=danno@chromium.org
1552 1548
1553 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body) 1549 Committed: https://code.google.com/p/v8/source/detail?r=17997""", body)
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698