Revision: 23615
Author:   [email protected]
Date:     Tue Sep  2 13:20:37 2014 UTC
Log:      Refactoring: Unify mocks of different commands in auto roll tests.

[email protected]

Review URL: https://codereview.chromium.org/527953002
https://code.google.com/p/v8/source/detail?r=23615

Modified:
 /branches/bleeding_edge/tools/push-to-trunk/test_scripts.py

=======================================
--- /branches/bleeding_edge/tools/push-to-trunk/test_scripts.py Tue Sep 2 12:56:07 2014 UTC +++ /branches/bleeding_edge/tools/push-to-trunk/test_scripts.py Tue Sep 2 13:20:37 2014 UTC
@@ -364,23 +364,12 @@
   def CmdMock(self, cmd, args="", pipe=True):
     print "%s %s" % (cmd, args)
     return self._cmd_mock.Call(cmd + " " + args)
-
-  def LogMock(self, cmd, args=""):
-    print "Log: %s %s" % (cmd, args)
-
-  MOCKS = {
-    "gclient": CmdMock,
-    "git": CmdMock,
-    "roll-dep": CmdMock,
-    "svn": CmdMock,
-    "vi": LogMock,
-  }

   def Call(self, fun, *args, **kwargs):
     print "Calling %s with %s and %s" % (str(fun), str(args), str(kwargs))

   def Command(self, cmd, args="", prefix="", pipe=True):
-    return ScriptTest.MOCKS[cmd](self, cmd, args)
+    return self.CmdMock(cmd, args)

   def ReadLine(self):
     return self._rl_mock.Call()
@@ -596,7 +585,9 @@
     TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
     TextToFile("  New  \n\tLines  \n", TEST_CONFIG[CHANGELOG_ENTRY_FILE])
     os.environ["EDITOR"] = "vi"
-
+    self.ExpectCmd([
+      Cmd("vi %s" % TEST_CONFIG[CHANGELOG_ENTRY_FILE], ""),
+    ])
     self.ExpectReadline([
       RL(""),  # Open editor.
     ])
@@ -742,7 +733,7 @@
           change_log)

     force_flag = " -f" if not manual else ""
-    self.ExpectCmd([
+    expectations = [
       Cmd("git status -s -uno", ""),
       Cmd("git status -s -b -uno", "## some_branch\n"),
       Cmd("git svn fetch", ""),
@@ -767,6 +758,10 @@
       Cmd("git log -1 --format=%s rev1", "Log text 1.\n"),
Cmd("git log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
       Cmd("git log -1 --format=%an rev1", "[email protected]\n"),
+    ]
+    if not force:
+ expectations.append(Cmd("vi %s" % TEST_CONFIG[CHANGELOG_ENTRY_FILE], ""))
+    expectations += [
       Cmd("git svn fetch", "fetch result\n"),
       Cmd("git checkout -f svn/bleeding_edge", ""),
       Cmd("git diff svn/trunk push_hash", "patch content\n"),
@@ -786,7 +781,8 @@
       Cmd("git checkout -f some_branch", ""),
       Cmd("git branch -D %s" % TEST_CONFIG[BRANCHNAME], ""),
       Cmd("git branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""),
-    ])
+    ]
+    self.ExpectCmd(expectations)

     # Expected keyboard input in manual mode:
     if manual:

--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
--- You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to