Suppress error handling for test coverage in push and merge scripts.

- This adds a suppression of lines concerning error handling for the test coverage analysis
- Fixes also calling push-to-trunk from auto-roll

TEST=tools/push-to-trunk/script_test.py
TBR=ulan@chromium.org

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

git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@19838 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 3aac1d3c
......@@ -82,7 +82,7 @@ class FetchLatestRevision(Step):
def RunStep(self):
match = re.match(r"^r(\d+) ", self.GitSVNLog())
if not match:
if not match: # pragma: no cover
self.Die("Could not extract current svn revision from log.")
self["latest"] = match.group(1)
......@@ -96,7 +96,7 @@ class CheckLastPush(Step):
# TODO(machenbach): This metric counts all revisions. It could be
# improved by counting only the revisions on bleeding_edge.
if int(self["latest"]) - last_push < 10:
if int(self["latest"]) - last_push < 10: # pragma: no cover
# This makes sure the script doesn't push twice in a row when the cron
# job retries several times.
self.Die("Last push too recently: %d" % last_push)
......@@ -138,8 +138,9 @@ class PushToTrunk(Step):
# TODO(machenbach): Update the script before calling it.
try:
if self._options.push:
P = push_to_trunk.PushToTrunk
self._side_effect_handler.Call(
PushToTrunk(push_to_trunk.CONFIG, self._side_effect_handler).Run,
P(push_to_trunk.CONFIG, self._side_effect_handler).Run,
["-a", self._options.author,
"-c", self._options.chromium,
"-r", self._options.reviewer,
......@@ -163,7 +164,7 @@ class AutoRoll(ScriptsBase):
help="A file with the password to the status app.")
def _ProcessOptions(self, options):
if not options.author or not options.reviewer:
if not options.author or not options.reviewer: # pragma: no cover
print "You need to specify author and reviewer."
return False
options.requires_editor = False
......@@ -181,5 +182,5 @@ class AutoRoll(ScriptsBase):
]
if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
sys.exit(AutoRoll(CONFIG).Run())
......@@ -192,7 +192,7 @@ def Command(cmd, args="", prefix="", pipe=True):
# Wrapper for side effects.
class SideEffectHandler(object):
class SideEffectHandler(object): # pragma: no cover
def Call(self, fun, *args, **kwargs):
return fun(*args, **kwargs)
......@@ -270,7 +270,7 @@ class Step(GitRecipesMixin):
# Persist state.
TextToFile(json.dumps(self._state), state_file)
def RunStep(self):
def RunStep(self): # pragma: no cover
raise NotImplementedError
def Retry(self, cb, retry_on=None, wait_plan=None):
......@@ -295,7 +295,7 @@ class Step(GitRecipesMixin):
except Exception:
got_exception = True
if got_exception or retry_on(result):
if not wait_plan:
if not wait_plan: # pragma: no cover
raise Exception("Retried too often. Giving up.")
wait_time = wait_plan.pop()
print "Waiting for %f seconds." % wait_time
......@@ -343,7 +343,7 @@ class Step(GitRecipesMixin):
raise Exception(msg)
def DieNoManualMode(self, msg=""):
if not self._options.manual:
if not self._options.manual: # pragma: no cover
msg = msg or "Only available in manual mode."
self.Die(msg)
......@@ -365,17 +365,17 @@ class Step(GitRecipesMixin):
def InitialEnvironmentChecks(self):
# Cancel if this is not a git checkout.
if not os.path.exists(self._config[DOT_GIT_LOCATION]):
if not os.path.exists(self._config[DOT_GIT_LOCATION]): # pragma: no cover
self.Die("This is not a git checkout, this script won't work for you.")
# Cancel if EDITOR is unset or not executable.
if (self._options.requires_editor and (not os.environ.get("EDITOR") or
Command("which", os.environ["EDITOR"]) is None)):
Command("which", os.environ["EDITOR"]) is None)): # pragma: no cover
self.Die("Please set your EDITOR environment variable, you'll need it.")
def CommonPrepare(self):
# Check for a clean workdir.
if not self.GitIsWorkdirClean():
if not self.GitIsWorkdirClean(): # pragma: no cover
self.Die("Workspace is not clean. Please commit or undo your changes.")
# Persist current branch.
......@@ -507,7 +507,7 @@ class ScriptsBase(object):
def _ProcessOptions(self, options):
return True
def _Steps(self):
def _Steps(self): # pragma: no cover
raise Exception("Not implemented.")
def MakeOptions(self, args=None):
......@@ -522,13 +522,13 @@ class ScriptsBase(object):
self._PrepareOptions(parser)
if args is None:
if args is None: # pragma: no cover
options = parser.parse_args()
else:
options = parser.parse_args(args)
# Process common options.
if options.step < 0:
if options.step < 0: # pragma: no cover
print "Bad step number %d" % options.step
parser.print_help()
return None
......
......@@ -68,7 +68,7 @@ class GitRecipesMixin(object):
for line in self.Git("status -s -b -uno").strip().splitlines():
match = re.match(r"^## (.+)", line)
if match: return match.group(1)
raise Exception("Couldn't find curent branch.")
raise Exception("Couldn't find curent branch.") # pragma: no cover
@Strip
def GitLog(self, n=0, format="", grep="", git_hash="", parent_hash="",
......
......@@ -57,7 +57,7 @@ class Preparation(Step):
if os.path.exists(self.Config(ALREADY_MERGING_SENTINEL_FILE)):
if self._options.force:
os.remove(self.Config(ALREADY_MERGING_SENTINEL_FILE))
elif self._options.step == 0:
elif self._options.step == 0: # pragma: no cover
self.Die("A merge is already in progress")
open(self.Config(ALREADY_MERGING_SENTINEL_FILE), "a").close()
......@@ -66,7 +66,7 @@ class Preparation(Step):
self["merge_to_branch"] = "bleeding_edge"
elif self._options.branch:
self["merge_to_branch"] = self._options.branch
else:
else: # pragma: no cover
self.Die("Please specify a branch to merge to")
self.CommonPrepare()
......@@ -95,7 +95,7 @@ class SearchArchitecturePorts(Step):
branch="svn/bleeding_edge")
for git_hash in git_hashes.splitlines():
svn_revision = self.GitSVNFindSVNRev(git_hash, "svn/bleeding_edge")
if not svn_revision:
if not svn_revision: # pragma: no cover
self.Die("Cannot determine svn revision for %s" % git_hash)
revision_title = self.GitLog(n=1, format="%s", git_hash=git_hash)
......@@ -123,7 +123,7 @@ class FindGitRevisions(Step):
self["patch_commit_hashes"] = []
for revision in self["full_revision_list"]:
next_hash = self.GitSVNFindGitHash(revision, "svn/bleeding_edge")
if not next_hash:
if not next_hash: # pragma: no cover
self.Die("Cannot determine git hash for r%s" % revision)
self["patch_commit_hashes"].append(next_hash)
......@@ -131,7 +131,7 @@ class FindGitRevisions(Step):
self["revision_list"] = ", ".join(map(lambda s: "r%s" % s,
self["full_revision_list"]))
if not self["revision_list"]:
if not self["revision_list"]: # pragma: no cover
self.Die("Revision list is empty.")
if self._options.revert:
......@@ -232,7 +232,7 @@ class PrepareSVN(Step):
self.GitSVNFetch()
commit_hash = self.GitLog(n=1, format="%H", grep=self["new_commit_msg"],
branch="svn/%s" % self["merge_to_branch"])
if not commit_hash:
if not commit_hash: # pragma: no cover
self.Die("Unable to map git commit to svn revision.")
self["svn_revision"] = self.GitSVNFindSVNRev(commit_hash)
print "subversion revision number is r%s" % self["svn_revision"]
......@@ -327,5 +327,5 @@ class MergeToBranch(ScriptsBase):
]
if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
sys.exit(MergeToBranch(CONFIG).Run())
......@@ -95,11 +95,11 @@ class DetectLastPush(Step):
# the push commit message.
last_push_title = self.GitLog(n=1, format="%s", git_hash=last_push)
last_push_be_svn = PUSH_MESSAGE_RE.match(last_push_title).group(1)
if not last_push_be_svn:
if not last_push_be_svn: # pragma: no cover
self.Die("Could not retrieve bleeding edge revision for trunk push %s"
% last_push)
last_push_bleeding_edge = self.GitSVNFindGitHash(last_push_be_svn)
if not last_push_bleeding_edge:
if not last_push_bleeding_edge: # pragma: no cover
self.Die("Could not retrieve bleeding edge git hash for trunk push %s"
% last_push)
......@@ -129,7 +129,7 @@ class PrepareChangeLog(Step):
# Fetch from Rietveld but only retry once with one second delay since
# there might be many revisions.
body = self.ReadURL(cl_url, wait_plan=[1])
except urllib2.URLError:
except urllib2.URLError: # pragma: no cover
pass
return body
......@@ -186,7 +186,7 @@ class EditChangeLog(Step):
changelog_entry = "\n".join(map(Fill80, changelog_entry.splitlines()))
changelog_entry = changelog_entry.lstrip()
if changelog_entry == "":
if changelog_entry == "": # pragma: no cover
self.Die("Empty ChangeLog entry.")
# Safe new change log for adding it later to the trunk patch.
......@@ -290,7 +290,7 @@ class SquashCommits(Step):
strip = lambda line: line.strip()
text = SplitMapJoin("\n\n", SplitMapJoin("\n", strip, " "), "\n\n")(text)
if not text:
if not text: # pragma: no cover
self.Die("Commit message editing failed.")
TextToFile(text, self.Config(COMMITMSG_FILE))
os.remove(self.Config(CHANGELOG_ENTRY_FILE))
......@@ -347,7 +347,7 @@ class SanityCheck(Step):
if not self.Confirm("Please check if your local checkout is sane: Inspect "
"%s, compile, run tests. Do you want to commit this new trunk "
"revision to the repository?" % self.Config(VERSION_FILE)):
self.Die("Execution canceled.")
self.Die("Execution canceled.") # pragma: no cover
class CommitSVN(Step):
......@@ -355,7 +355,7 @@ class CommitSVN(Step):
def RunStep(self):
result = self.GitSVNDCommit()
if not result:
if not result: # pragma: no cover
self.Die("'git svn dcommit' failed.")
result = filter(lambda x: re.search(r"^Committed r[0-9]+", x),
result.splitlines())
......@@ -405,10 +405,10 @@ class SwitchChromium(Step):
os.chdir(self["chrome_path"])
self.InitialEnvironmentChecks()
# Check for a clean workdir.
if not self.GitIsWorkdirClean():
if not self.GitIsWorkdirClean(): # pragma: no cover
self.Die("Workspace is not clean. Please commit or undo your changes.")
# Assert that the DEPS file is there.
if not os.path.exists(self.Config(DEPS_FILE)):
if not os.path.exists(self.Config(DEPS_FILE)): # pragma: no cover
self.Die("DEPS file not present.")
......@@ -468,7 +468,7 @@ class CleanUp(Step):
print("Congratulations, you have successfully created the trunk "
"revision %s and rolled it into Chromium. Please don't forget to "
"update the v8rel spreadsheet:" % self["version"])
else:
else: # pragma: no cover
print("Congratulations, you have successfully created the trunk "
"revision %s. Please don't forget to roll this new version into "
"Chromium, and to update the v8rel spreadsheet:"
......@@ -500,7 +500,7 @@ class PushToTrunk(ScriptsBase):
parser.add_argument("-l", "--last-push",
help="The git commit ID of the last push to trunk.")
def _ProcessOptions(self, options):
def _ProcessOptions(self, options): # pragma: no cover
if not options.manual and not options.reviewer:
print "A reviewer (-r) is required in (semi-)automatic mode."
return False
......@@ -543,5 +543,5 @@ class PushToTrunk(ScriptsBase):
]
if __name__ == "__main__":
if __name__ == "__main__": # pragma: no cover
sys.exit(PushToTrunk(CONFIG).Run())
......@@ -802,7 +802,7 @@ Performance and stability improvements on all platforms.""", commit)
])
auto_roll.AutoRoll(TEST_CONFIG, self).Run(
AUTO_ROLL_ARGS + ["--status-password", password])
AUTO_ROLL_ARGS + ["--status-password", password, "--push"])
state = json.loads(FileToText("%s-state.json"
% TEST_CONFIG[PERSISTFILE_BASENAME]))
......
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