Refactoring: Use explicit mock expectations for testing push and merge scripts.

- Up to now, mock expectations were simple lists of arguments + return value
- These expectations are now modeled explicitly including the name of the mock (e.g. git or readline)
- The optional test callback function is now explicitly named
- This will allow merging all mock expectation types (e.g. git and readline) into a single list per test case (follow up CL)

TEST=tools/push-to-trunk/script_test.py
R=jarin@chromium.org

Review URL: https://codereview.chromium.org/197313002

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19853 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent be328fd4
...@@ -210,6 +210,31 @@ Committed: https://code.google.com/p/v8/source/detail?r=18210 ...@@ -210,6 +210,31 @@ Committed: https://code.google.com/p/v8/source/detail?r=18210
"BUG=1234567890\n")) "BUG=1234567890\n"))
def Git(*args, **kwargs):
"""Convenience function returning a git test expectation."""
return {
"name": "git",
"args": args[:-1],
"ret": args[-1],
"cb": kwargs.get("cb"),
}
def RL(text, cb=None):
"""Convenience function returning a readline test expectation."""
return {"name": "readline", "args": [], "ret": text, "cb": cb}
def URL(*args, **kwargs):
"""Convenience function returning a readurl test expectation."""
return {
"name": "readurl",
"args": args[:-1],
"ret": args[-1],
"cb": kwargs.get("cb"),
}
class SimpleMock(object): class SimpleMock(object):
def __init__(self, name): def __init__(self, name):
self._name = name self._name = name
...@@ -219,43 +244,43 @@ class SimpleMock(object): ...@@ -219,43 +244,43 @@ class SimpleMock(object):
def Expect(self, recipe): def Expect(self, recipe):
self._recipe = recipe self._recipe = recipe
def Call(self, *args): # pragma: no cover def Call(self, name, *args): # pragma: no cover
self._index += 1 self._index += 1
try: try:
expected_call = self._recipe[self._index] expected_call = self._recipe[self._index]
except IndexError: except IndexError:
raise NoRetryException("Calling %s %s" % (self._name, " ".join(args))) raise NoRetryException("Calling %s %s" % (name, " ".join(args)))
if not isinstance(expected_call, dict):
raise NoRetryException("Found wrong expectation type for %s %s"
% (name, " ".join(args)))
# Pack expectations without arguments into a list.
if not isinstance(expected_call, list):
expected_call = [expected_call]
# The number of arguments in the expectation must match the actual # The number of arguments in the expectation must match the actual
# arguments. # arguments.
if len(args) > len(expected_call): if len(args) > len(expected_call['args']):
raise NoRetryException("When calling %s with arguments, the " raise NoRetryException("When calling %s with arguments, the "
"expectations must consist of at least as many arguments.") "expectations must consist of at least as many arguments.")
# Compare expected and actual arguments. # Compare expected and actual arguments.
for (expected_arg, actual_arg) in zip(expected_call, args): for (expected_arg, actual_arg) in zip(expected_call['args'], args):
if expected_arg != actual_arg: if expected_arg != actual_arg:
raise NoRetryException("Expected: %s - Actual: %s" raise NoRetryException("Expected: %s - Actual: %s"
% (expected_arg, actual_arg)) % (expected_arg, actual_arg))
# The expectation list contains a mandatory return value and an optional # The expected call contains an optional callback for checking the context
# callback for checking the context at the time of the call. # at the time of the call.
if len(expected_call) == len(args) + 2: if expected_call['cb']:
try: try:
expected_call[len(args) + 1]() expected_call['cb']()
except: except:
tb = traceback.format_exc() tb = traceback.format_exc()
raise NoRetryException("Caught exception from callback: %s" % tb) raise NoRetryException("Caught exception from callback: %s" % tb)
return_value = expected_call[len(args)]
# If the return value is an exception, raise it instead of returning. # If the return value is an exception, raise it instead of returning.
if isinstance(return_value, Exception): if isinstance(expected_call['ret'], Exception):
raise return_value raise expected_call['ret']
return return_value return expected_call['ret']
def AssertFinished(self): # pragma: no cover def AssertFinished(self): # pragma: no cover
if self._index < len(self._recipe) -1: if self._index < len(self._recipe) -1:
...@@ -297,7 +322,7 @@ class ScriptTest(unittest.TestCase): ...@@ -297,7 +322,7 @@ class ScriptTest(unittest.TestCase):
def GitMock(self, cmd, args="", pipe=True): def GitMock(self, cmd, args="", pipe=True):
print "%s %s" % (cmd, args) print "%s %s" % (cmd, args)
return self._git_mock.Call(args) return self._git_mock.Call("git", args)
def LogMock(self, cmd, args=""): def LogMock(self, cmd, args=""):
print "Log: %s %s" % (cmd, args) print "Log: %s %s" % (cmd, args)
...@@ -318,13 +343,13 @@ class ScriptTest(unittest.TestCase): ...@@ -318,13 +343,13 @@ class ScriptTest(unittest.TestCase):
return ScriptTest.MOCKS[cmd](self, cmd, args) return ScriptTest.MOCKS[cmd](self, cmd, args)
def ReadLine(self): def ReadLine(self):
return self._rl_mock.Call() return self._rl_mock.Call("readline")
def ReadURL(self, url, params): def ReadURL(self, url, params):
if params is not None: if params is not None:
return self._url_mock.Call(url, params) return self._url_mock.Call("readurl", url, params)
else: else:
return self._url_mock.Call(url) return self._url_mock.Call("readurl", url)
def Sleep(self, seconds): def Sleep(self, seconds):
pass pass
...@@ -367,46 +392,46 @@ class ScriptTest(unittest.TestCase): ...@@ -367,46 +392,46 @@ class ScriptTest(unittest.TestCase):
self.assertTrue(Command("git", "--version").startswith("git version")) self.assertTrue(Command("git", "--version").startswith("git version"))
def testGitMock(self): def testGitMock(self):
self.ExpectGit([["--version", "git version 1.2.3"], ["dummy", ""]]) self.ExpectGit([Git("--version", "git version 1.2.3"), Git("dummy", "")])
self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version")) self.assertEquals("git version 1.2.3", self.MakeStep().Git("--version"))
self.assertEquals("", self.MakeStep().Git("dummy")) self.assertEquals("", self.MakeStep().Git("dummy"))
def testCommonPrepareDefault(self): def testCommonPrepareDefault(self):
self.ExpectGit([ self.ExpectGit([
["status -s -uno", ""], Git("status -s -uno", ""),
["status -s -b -uno", "## some_branch"], Git("status -s -b -uno", "## some_branch"),
["svn fetch", ""], Git("svn fetch", ""),
["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], Git("branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]),
["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""),
["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""),
["branch", ""], Git("branch", ""),
]) ])
self.ExpectReadline(["Y"]) self.ExpectReadline([RL("Y")])
self.MakeStep().CommonPrepare() self.MakeStep().CommonPrepare()
self.MakeStep().PrepareBranch() self.MakeStep().PrepareBranch()
self.assertEquals("some_branch", self._state["current_branch"]) self.assertEquals("some_branch", self._state["current_branch"])
def testCommonPrepareNoConfirm(self): def testCommonPrepareNoConfirm(self):
self.ExpectGit([ self.ExpectGit([
["status -s -uno", ""], Git("status -s -uno", ""),
["status -s -b -uno", "## some_branch"], Git("status -s -b -uno", "## some_branch"),
["svn fetch", ""], Git("svn fetch", ""),
["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], Git("branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]),
]) ])
self.ExpectReadline(["n"]) self.ExpectReadline([RL("n")])
self.MakeStep().CommonPrepare() self.MakeStep().CommonPrepare()
self.assertRaises(Exception, self.MakeStep().PrepareBranch) self.assertRaises(Exception, self.MakeStep().PrepareBranch)
self.assertEquals("some_branch", self._state["current_branch"]) self.assertEquals("some_branch", self._state["current_branch"])
def testCommonPrepareDeleteBranchFailure(self): def testCommonPrepareDeleteBranchFailure(self):
self.ExpectGit([ self.ExpectGit([
["status -s -uno", ""], Git("status -s -uno", ""),
["status -s -b -uno", "## some_branch"], Git("status -s -b -uno", "## some_branch"),
["svn fetch", ""], Git("svn fetch", ""),
["branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]], Git("branch", " branch1\n* %s" % TEST_CONFIG[TEMP_BRANCH]),
["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None], Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], None),
]) ])
self.ExpectReadline(["Y"]) self.ExpectReadline([RL("Y")])
self.MakeStep().CommonPrepare() self.MakeStep().CommonPrepare()
self.assertRaises(Exception, self.MakeStep().PrepareBranch) self.assertRaises(Exception, self.MakeStep().PrepareBranch)
self.assertEquals("some_branch", self._state["current_branch"]) self.assertEquals("some_branch", self._state["current_branch"])
...@@ -451,27 +476,27 @@ class ScriptTest(unittest.TestCase): ...@@ -451,27 +476,27 @@ class ScriptTest(unittest.TestCase):
TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile() TEST_CONFIG[CHANGELOG_ENTRY_FILE] = self.MakeEmptyTempFile()
self.ExpectGit([ self.ExpectGit([
["log --format=%H 1234..HEAD", "rev1\nrev2\nrev3\nrev4"], Git("log --format=%H 1234..HEAD", "rev1\nrev2\nrev3\nrev4"),
["log -1 --format=%s rev1", "Title text 1"], Git("log -1 --format=%s rev1", "Title text 1"),
["log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"], Git("log -1 --format=%B rev1", "Title\n\nBUG=\nLOG=y\n"),
["log -1 --format=%an rev1", "author1@chromium.org"], Git("log -1 --format=%an rev1", "author1@chromium.org"),
["log -1 --format=%s rev2", "Title text 2."], Git("log -1 --format=%s rev2", "Title text 2."),
["log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"], Git("log -1 --format=%B rev2", "Title\n\nBUG=123\nLOG= \n"),
["log -1 --format=%an rev2", "author2@chromium.org"], Git("log -1 --format=%an rev2", "author2@chromium.org"),
["log -1 --format=%s rev3", "Title text 3"], Git("log -1 --format=%s rev3", "Title text 3"),
["log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"], Git("log -1 --format=%B rev3", "Title\n\nBUG=321\nLOG=true\n"),
["log -1 --format=%an rev3", "author3@chromium.org"], Git("log -1 --format=%an rev3", "author3@chromium.org"),
["log -1 --format=%s rev4", "Title text 4"], Git("log -1 --format=%s rev4", "Title text 4"),
["log -1 --format=%B rev4", Git("log -1 --format=%B rev4",
("Title\n\nBUG=456\nLOG=Y\n\n" ("Title\n\nBUG=456\nLOG=Y\n\n"
"Review URL: https://codereview.chromium.org/9876543210\n")], "Review URL: https://codereview.chromium.org/9876543210\n")),
["log -1 --format=%an rev4", "author4@chromium.org"], Git("log -1 --format=%an rev4", "author4@chromium.org"),
]) ])
# The cl for rev4 on rietveld has an updated LOG flag. # The cl for rev4 on rietveld has an updated LOG flag.
self.ExpectReadURL([ self.ExpectReadURL([
["https://codereview.chromium.org/9876543210/description", URL("https://codereview.chromium.org/9876543210/description",
"Title\n\nBUG=456\nLOG=N\n\n"], "Title\n\nBUG=456\nLOG=N\n\n"),
]) ])
self._state["last_push_bleeding_edge"] = "1234" self._state["last_push_bleeding_edge"] = "1234"
...@@ -519,7 +544,7 @@ class ScriptTest(unittest.TestCase): ...@@ -519,7 +544,7 @@ class ScriptTest(unittest.TestCase):
os.environ["EDITOR"] = "vi" os.environ["EDITOR"] = "vi"
self.ExpectReadline([ self.ExpectReadline([
"", # Open editor. RL(""), # Open editor.
]) ])
self.RunStep(PushToTrunk, EditChangeLog) self.RunStep(PushToTrunk, EditChangeLog)
...@@ -532,7 +557,7 @@ class ScriptTest(unittest.TestCase): ...@@ -532,7 +557,7 @@ class ScriptTest(unittest.TestCase):
self._state["build"] = "5" self._state["build"] = "5"
self.ExpectReadline([ self.ExpectReadline([
"Y", # Increment build number. RL("Y"), # Increment build number.
]) ])
self.RunStep(PushToTrunk, IncrementVersion) self.RunStep(PushToTrunk, IncrementVersion)
...@@ -564,8 +589,8 @@ class ScriptTest(unittest.TestCase): ...@@ -564,8 +589,8 @@ class ScriptTest(unittest.TestCase):
f.write(change_log) f.write(change_log)
self.ExpectGit([ self.ExpectGit([
["diff svn/trunk hash1", "patch content"], Git("diff svn/trunk hash1", "patch content"),
["svn find-rev hash1", "123455\n"], Git("svn find-rev hash1", "123455\n"),
]) ])
self._state["prepare_commit_hash"] = "hash1" self._state["prepare_commit_hash"] = "hash1"
...@@ -652,80 +677,81 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -652,80 +677,81 @@ Performance and stability improvements on all platforms.""", commit)
force_flag = " -f" if not manual else "" force_flag = " -f" if not manual else ""
review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else "" review_suffix = "\n\nTBR=reviewer@chromium.org" if not manual else ""
self.ExpectGit([ self.ExpectGit([
["status -s -uno", ""], Git("status -s -uno", ""),
["status -s -b -uno", "## some_branch\n"], Git("status -s -b -uno", "## some_branch\n"),
["svn fetch", ""], Git("svn fetch", ""),
["branch", " branch1\n* branch2\n"], Git("branch", " branch1\n* branch2\n"),
["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""),
["branch", " branch1\n* branch2\n"], Git("branch", " branch1\n* branch2\n"),
["branch", " branch1\n* branch2\n"], Git("branch", " branch1\n* branch2\n"),
["checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""], Git("checkout -b %s svn/bleeding_edge" % TEST_CONFIG[BRANCHNAME], ""),
[("log -1 --format=%H --grep=" Git(("log -1 --format=%H --grep="
"\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" " "\"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\" "
"svn/trunk"), "hash2\n"], "svn/trunk"), "hash2\n"),
["log -1 hash2", "Log message\n"], Git("log -1 hash2", "Log message\n"),
["log -1 --format=%s hash2", Git("log -1 --format=%s hash2",
"Version 3.4.5 (based on bleeding_edge revision r1234)\n"], "Version 3.4.5 (based on bleeding_edge revision r1234)\n"),
["svn find-rev r1234", "hash3\n"], Git("svn find-rev r1234", "hash3\n"),
["log --format=%H hash3..HEAD", "rev1\n"], Git("log --format=%H hash3..HEAD", "rev1\n"),
["log -1 --format=%s rev1", "Log text 1.\n"], Git("log -1 --format=%s rev1", "Log text 1.\n"),
["log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"], Git("log -1 --format=%B rev1", "Text\nLOG=YES\nBUG=v8:321\nText\n"),
["log -1 --format=%an rev1", "author1@chromium.org\n"], Git("log -1 --format=%an rev1", "author1@chromium.org\n"),
[("commit -am \"Prepare push to trunk. " Git(("commit -am \"Prepare push to trunk. "
"Now working on version 3.22.6.%s\"" % review_suffix), "Now working on version 3.22.6.%s\"" % review_suffix),
" 2 files changed\n", " 2 files changed\n",
CheckPreparePush], cb=CheckPreparePush),
[("cl upload --send-mail --email \"author@chromium.org\" " Git(("cl upload --send-mail --email \"author@chromium.org\" "
"-r \"reviewer@chromium.org\"%s" % force_flag), "-r \"reviewer@chromium.org\"%s" % force_flag),
"done\n"], "done\n"),
["cl presubmit", "Presubmit successfull\n"], Git("cl presubmit", "Presubmit successfull\n"),
["cl dcommit -f --bypass-hooks", "Closing issue\n"], Git("cl dcommit -f --bypass-hooks", "Closing issue\n"),
["svn fetch", "fetch result\n"], Git("svn fetch", "fetch result\n"),
["checkout -f svn/bleeding_edge", ""], Git("checkout -f svn/bleeding_edge", ""),
[("log -1 --format=%H --grep=\"Prepare push to trunk. " Git(("log -1 --format=%H --grep=\"Prepare push to trunk. "
"Now working on version 3.22.6.\""), "Now working on version 3.22.6.\""),
"hash1\n"], "hash1\n"),
["diff svn/trunk hash1", "patch content\n"], Git("diff svn/trunk hash1", "patch content\n"),
["svn find-rev hash1", "123455\n"], Git("svn find-rev hash1", "123455\n"),
["checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""], Git("checkout -b %s svn/trunk" % TEST_CONFIG[TRUNKBRANCH], ""),
["apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""], Git("apply --index --reject \"%s\"" % TEST_CONFIG[PATCH_FILE], ""),
["add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""], Git("add \"%s\"" % TEST_CONFIG[VERSION_FILE], ""),
["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "", CheckSVNCommit], Git("commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], "",
["svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"], cb=CheckSVNCommit),
["svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""], Git("svn dcommit 2>&1", "Some output\nCommitted r123456\nSome output\n"),
["status -s -uno", ""], Git("svn tag 3.22.5 -m \"Tagging version 3.22.5\"", ""),
["checkout -f master", ""], Git("status -s -uno", ""),
["pull", ""], Git("checkout -f master", ""),
["checkout -b v8-roll-123456", ""], Git("pull", ""),
[("commit -am \"Update V8 to version 3.22.5 " Git("checkout -b v8-roll-123456", ""),
"(based on bleeding_edge revision r123455).\n\n" Git(("commit -am \"Update V8 to version 3.22.5 "
"TBR=reviewer@chromium.org\""), "(based on bleeding_edge revision r123455).\n\n"
""], "TBR=reviewer@chromium.org\""),
["cl upload --send-mail --email \"author@chromium.org\"%s" % force_flag, ""),
""], Git(("cl upload --send-mail --email \"author@chromium.org\"%s"
["checkout -f some_branch", ""], % force_flag), ""),
["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], Git("checkout -f some_branch", ""),
["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""),
["branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""], Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""),
Git("branch -D %s" % TEST_CONFIG[TRUNKBRANCH], ""),
]) ])
# Expected keyboard input in manual mode: # Expected keyboard input in manual mode:
if manual: if manual:
self.ExpectReadline([ self.ExpectReadline([
"Y", # Confirm last push. RL("Y"), # Confirm last push.
"", # Open editor. RL(""), # Open editor.
"Y", # Increment build number. RL("Y"), # Increment build number.
"reviewer@chromium.org", # V8 reviewer. RL("reviewer@chromium.org"), # V8 reviewer.
"LGTX", # Enter LGTM for V8 CL (wrong). RL("LGTX"), # Enter LGTM for V8 CL (wrong).
"LGTM", # Enter LGTM for V8 CL. RL("LGTM"), # Enter LGTM for V8 CL.
"Y", # Sanity check. RL("Y"), # Sanity check.
"reviewer@chromium.org", # Chromium reviewer. RL("reviewer@chromium.org"), # Chromium reviewer.
]) ])
# Expected keyboard input in semi-automatic mode: # Expected keyboard input in semi-automatic mode:
if not manual and not force: if not manual and not force:
self.ExpectReadline([ self.ExpectReadline([
"LGTM", # Enter LGTM for V8 CL. RL("LGTM"), # Enter LGTM for V8 CL.
]) ])
# No keyboard input in forced mode: # No keyboard input in forced mode:
...@@ -761,8 +787,8 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -761,8 +787,8 @@ Performance and stability improvements on all platforms.""", commit)
def testCheckLastPushRecently(self): def testCheckLastPushRecently(self):
self.ExpectGit([ self.ExpectGit([
["svn log -1 --oneline", "r101 | Text"], Git("svn log -1 --oneline", "r101 | Text"),
["svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."], Git("svn log -1 --oneline ChangeLog", "r99 | Prepare push to trunk..."),
]) ])
self.RunStep(auto_roll.AutoRoll, FetchLatestRevision, AUTO_ROLL_ARGS) self.RunStep(auto_roll.AutoRoll, FetchLatestRevision, AUTO_ROLL_ARGS)
...@@ -777,28 +803,27 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -777,28 +803,27 @@ Performance and stability improvements on all platforms.""", commit)
TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist"
self.ExpectReadURL([ self.ExpectReadURL([
["https://v8-status.appspot.com/current?format=json", URL("https://v8-status.appspot.com/current?format=json",
"{\"message\": \"Tree is throttled\"}"], "{\"message\": \"Tree is throttled\"}"),
["https://v8-status.appspot.com/lkgr", Exception("Network problem")], URL("https://v8-status.appspot.com/lkgr", Exception("Network problem")),
["https://v8-status.appspot.com/lkgr", "100"], URL("https://v8-status.appspot.com/lkgr", "100"),
["https://v8-status.appspot.com/status", URL("https://v8-status.appspot.com/status",
("username=v8-auto-roll%40chromium.org&" ("username=v8-auto-roll%40chromium.org&"
"message=Tree+is+closed+%28preparing+to+push%29&password=PW"), "message=Tree+is+closed+%28preparing+to+push%29&password=PW"), ""),
""], URL("https://v8-status.appspot.com/status",
["https://v8-status.appspot.com/status", ("username=v8-auto-roll%40chromium.org&"
("username=v8-auto-roll%40chromium.org&" "message=Tree+is+throttled&password=PW"), ""),
"message=Tree+is+throttled&password=PW"), ""],
]) ])
self.ExpectGit([ self.ExpectGit([
["status -s -uno", ""], Git("status -s -uno", ""),
["status -s -b -uno", "## some_branch\n"], Git("status -s -b -uno", "## some_branch\n"),
["svn fetch", ""], Git("svn fetch", ""),
["svn log -1 --oneline", "r100 | Text"], Git("svn log -1 --oneline", "r100 | Text"),
[("log -1 --format=%H --grep=\"" Git(("log -1 --format=%H --grep=\""
"^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\"" "^Version [[:digit:]]*\.[[:digit:]]*\.[[:digit:]]* (based\""
" svn/trunk"), "push_hash\n"], " svn/trunk"), "push_hash\n"),
["svn find-rev push_hash", "65"], Git("svn find-rev push_hash", "65"),
]) ])
auto_roll.AutoRoll(TEST_CONFIG, self).Run( auto_roll.AutoRoll(TEST_CONFIG, self).Run(
...@@ -818,9 +843,9 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -818,9 +843,9 @@ Performance and stability improvements on all platforms.""", commit)
self.ExpectReadURL([]) self.ExpectReadURL([])
self.ExpectGit([ self.ExpectGit([
["status -s -uno", ""], Git("status -s -uno", ""),
["status -s -b -uno", "## some_branch\n"], Git("status -s -b -uno", "## some_branch\n"),
["svn fetch", ""], Git("svn fetch", ""),
]) ])
def RunAutoRoll(): def RunAutoRoll():
...@@ -832,14 +857,14 @@ Performance and stability improvements on all platforms.""", commit) ...@@ -832,14 +857,14 @@ Performance and stability improvements on all platforms.""", commit)
TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist" TEST_CONFIG[SETTINGS_LOCATION] = "~/.doesnotexist"
self.ExpectReadURL([ self.ExpectReadURL([
["https://v8-status.appspot.com/current?format=json", URL("https://v8-status.appspot.com/current?format=json",
"{\"message\": \"Tree is throttled (no push)\"}"], "{\"message\": \"Tree is throttled (no push)\"}"),
]) ])
self.ExpectGit([ self.ExpectGit([
["status -s -uno", ""], Git("status -s -uno", ""),
["status -s -b -uno", "## some_branch\n"], Git("status -s -b -uno", "## some_branch\n"),
["svn fetch", ""], Git("svn fetch", ""),
]) ])
def RunAutoRoll(): def RunAutoRoll():
...@@ -883,81 +908,81 @@ LOG=N ...@@ -883,81 +908,81 @@ LOG=N
self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version)) self.assertTrue(re.search(r"#define IS_CANDIDATE_VERSION\s+0", version))
self.ExpectGit([ self.ExpectGit([
["status -s -uno", ""], Git("status -s -uno", ""),
["status -s -b -uno", "## some_branch\n"], Git("status -s -b -uno", "## some_branch\n"),
["svn fetch", ""], Git("svn fetch", ""),
["branch", " branch1\n* branch2\n"], Git("branch", " branch1\n* branch2\n"),
["checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""], Git("checkout -b %s" % TEST_CONFIG[TEMP_BRANCH], ""),
["branch", " branch1\n* branch2\n"], Git("branch", " branch1\n* branch2\n"),
["checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""], Git("checkout -b %s svn/trunk" % TEST_CONFIG[BRANCHNAME], ""),
["log --format=%H --grep=\"Port r12345\" --reverse svn/bleeding_edge", Git("log --format=%H --grep=\"Port r12345\" --reverse svn/bleeding_edge",
"hash1\nhash2"], "hash1\nhash2"),
["svn find-rev hash1 svn/bleeding_edge", "45678"], Git("svn find-rev hash1 svn/bleeding_edge", "45678"),
["log -1 --format=%s hash1", "Title1"], Git("log -1 --format=%s hash1", "Title1"),
["svn find-rev hash2 svn/bleeding_edge", "23456"], Git("svn find-rev hash2 svn/bleeding_edge", "23456"),
["log -1 --format=%s hash2", "Title2"], Git("log -1 --format=%s hash2", "Title2"),
["log --format=%H --grep=\"Port r23456\" --reverse svn/bleeding_edge", Git("log --format=%H --grep=\"Port r23456\" --reverse svn/bleeding_edge",
""], ""),
["log --format=%H --grep=\"Port r34567\" --reverse svn/bleeding_edge", Git("log --format=%H --grep=\"Port r34567\" --reverse svn/bleeding_edge",
"hash3"], "hash3"),
["svn find-rev hash3 svn/bleeding_edge", "56789"], Git("svn find-rev hash3 svn/bleeding_edge", "56789"),
["log -1 --format=%s hash3", "Title3"], Git("log -1 --format=%s hash3", "Title3"),
["svn find-rev r12345 svn/bleeding_edge", "hash4"], Git("svn find-rev r12345 svn/bleeding_edge", "hash4"),
# Simulate svn being down which stops the script. # Simulate svn being down which stops the script.
["svn find-rev r23456 svn/bleeding_edge", None], Git("svn find-rev r23456 svn/bleeding_edge", None),
# Restart script in the failing step. # Restart script in the failing step.
["svn find-rev r12345 svn/bleeding_edge", "hash4"], Git("svn find-rev r12345 svn/bleeding_edge", "hash4"),
["svn find-rev r23456 svn/bleeding_edge", "hash2"], Git("svn find-rev r23456 svn/bleeding_edge", "hash2"),
["svn find-rev r34567 svn/bleeding_edge", "hash3"], Git("svn find-rev r34567 svn/bleeding_edge", "hash3"),
["svn find-rev r45678 svn/bleeding_edge", "hash1"], Git("svn find-rev r45678 svn/bleeding_edge", "hash1"),
["svn find-rev r56789 svn/bleeding_edge", "hash5"], Git("svn find-rev r56789 svn/bleeding_edge", "hash5"),
["log -1 --format=%s hash4", "Title4"], Git("log -1 --format=%s hash4", "Title4"),
["log -1 --format=%s hash2", "Title2"], Git("log -1 --format=%s hash2", "Title2"),
["log -1 --format=%s hash3", "Title3"], Git("log -1 --format=%s hash3", "Title3"),
["log -1 --format=%s hash1", "Title1"], Git("log -1 --format=%s hash1", "Title1"),
["log -1 --format=%s hash5", "Title5"], Git("log -1 --format=%s hash5", "Title5"),
["log -1 hash4", "Title4\nBUG=123\nBUG=234"], Git("log -1 hash4", "Title4\nBUG=123\nBUG=234"),
["log -1 hash2", "Title2\n BUG = v8:123,345"], Git("log -1 hash2", "Title2\n BUG = v8:123,345"),
["log -1 hash3", "Title3\nLOG=n\nBUG=567, 456"], Git("log -1 hash3", "Title3\nLOG=n\nBUG=567, 456"),
["log -1 hash1", "Title1"], Git("log -1 hash1", "Title1"),
["log -1 hash5", "Title5"], Git("log -1 hash5", "Title5"),
["log -1 -p hash4", "patch4"], Git("log -1 -p hash4", "patch4"),
["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
"", VerifyPatch("patch4")], "", cb=VerifyPatch("patch4")),
["log -1 -p hash2", "patch2"], Git("log -1 -p hash2", "patch2"),
["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
"", VerifyPatch("patch2")], "", cb=VerifyPatch("patch2")),
["log -1 -p hash3", "patch3"], Git("log -1 -p hash3", "patch3"),
["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
"", VerifyPatch("patch3")], "", cb=VerifyPatch("patch3")),
["log -1 -p hash1", "patch1"], Git("log -1 -p hash1", "patch1"),
["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
"", VerifyPatch("patch1")], "", cb=VerifyPatch("patch1")),
["log -1 -p hash5", "patch5\n"], Git("log -1 -p hash5", "patch5\n"),
["apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE], Git("apply --index --reject \"%s\"" % TEST_CONFIG[TEMPORARY_PATCH_FILE],
"", VerifyPatch("patch5\n")], "", cb=VerifyPatch("patch5\n")),
["apply --index --reject \"%s\"" % extra_patch, ""], Git("apply --index --reject \"%s\"" % extra_patch, ""),
["commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""], Git("commit -aF \"%s\"" % TEST_CONFIG[COMMITMSG_FILE], ""),
["cl upload --send-mail -r \"reviewer@chromium.org\"", ""], Git("cl upload --send-mail -r \"reviewer@chromium.org\"", ""),
["checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""], Git("checkout -f %s" % TEST_CONFIG[BRANCHNAME], ""),
["cl presubmit", "Presubmit successfull\n"], Git("cl presubmit", "Presubmit successfull\n"),
["cl dcommit -f --bypass-hooks", "Closing issue\n", VerifySVNCommit], Git("cl dcommit -f --bypass-hooks", "Closing issue\n", cb=VerifySVNCommit),
["svn fetch", ""], Git("svn fetch", ""),
["log -1 --format=%%H --grep=\"%s\" svn/trunk" % msg, "hash6"], Git("log -1 --format=%%H --grep=\"%s\" svn/trunk" % msg, "hash6"),
["svn find-rev hash6", "1324"], Git("svn find-rev hash6", "1324"),
[("copy -r 1324 https://v8.googlecode.com/svn/trunk " Git(("copy -r 1324 https://v8.googlecode.com/svn/trunk "
"https://v8.googlecode.com/svn/tags/3.22.5.1 -m " "https://v8.googlecode.com/svn/tags/3.22.5.1 -m "
"\"Tagging version 3.22.5.1\""), ""], "\"Tagging version 3.22.5.1\""), ""),
["checkout -f some_branch", ""], Git("checkout -f some_branch", ""),
["branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""], Git("branch -D %s" % TEST_CONFIG[TEMP_BRANCH], ""),
["branch -D %s" % TEST_CONFIG[BRANCHNAME], ""], Git("branch -D %s" % TEST_CONFIG[BRANCHNAME], ""),
]) ])
self.ExpectReadline([ self.ExpectReadline([
"Y", # Automatically add corresponding ports (34567, 56789)? RL("Y"), # Automatically add corresponding ports (34567, 56789)?
"Y", # Automatically increment patch level? RL("Y"), # Automatically increment patch level?
"reviewer@chromium.org", # V8 reviewer. RL("reviewer@chromium.org"), # V8 reviewer.
"LGTM", # Enter LGTM for V8 CL. RL("LGTM"), # Enter LGTM for V8 CL.
]) ])
# r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS # r12345 and r34567 are patches. r23456 (included) and r45678 are the MIPS
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment