Commit 5fc6c8c0 authored by rmistry@google.com's avatar rmistry@google.com

Skip OWNERS checks for CQ dry runs

The CQ dry run feature was announced in https://groups.google.com/a/chromium.org/forum/#!topic/chromium-dev/G5-X0_tfmok

The primary complain is that the presubmit builders fail because of OWNERS checks or because of "Missing LGTM from someone other than...".
This change skips those checks for dry runs.

BUG=chromium:477190

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@294853 0039d316-1c4b-4281-b951-d872f2087c98
parent 82c0fb12
......@@ -854,7 +854,11 @@ def CheckOwners(input_api, output_api, source_file_filter=None):
if input_api.tbr:
return [output_api.PresubmitNotifyResult(
'--tbr was specified, skipping OWNERS check')]
if not input_api.change.issue:
if input_api.change.issue:
if _GetRietveldIssueProps(input_api, None).get('cq_dry_run', False):
return [output_api.PresubmitNotifyResult(
'This is a CQ dry run, skipping OWNERS check')]
else:
return [output_api.PresubmitError("OWNERS check failed: this change has "
"no Rietveld issue number, so we can't check it for approvals.")]
needed = 'LGTM from an OWNER'
......
......@@ -2570,7 +2570,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
def AssertOwnersWorks(self, tbr=False, issue='1', approvers=None,
reviewers=None, is_committing=True, rietveld_response=None,
uncovered_files=None, expected_output='',
manually_specified_reviewers=None):
manually_specified_reviewers=None, cq_dry_run=False):
if approvers is None:
# The set of people who lgtm'ed a change.
approvers = set()
......@@ -2598,8 +2598,9 @@ class CannedChecksUnittest(PresubmitTestsBase):
input_api.tbr = tbr
if not is_committing or (not tbr and issue):
affected_file.LocalPath().AndReturn('foo/xyz.cc')
change.AffectedFiles(file_filter=None).AndReturn([affected_file])
if not cq_dry_run:
affected_file.LocalPath().AndReturn('foo/xyz.cc')
change.AffectedFiles(file_filter=None).AndReturn([affected_file])
if issue and not rietveld_response:
rietveld_response = {
"owner_email": change.author_email,
......@@ -2612,20 +2613,25 @@ class CannedChecksUnittest(PresubmitTestsBase):
if is_committing:
people = approvers
if issue:
input_api.rietveld.get_issue_properties(
issue=int(input_api.change.issue), messages=None).AndReturn(
rietveld_response)
else:
people = reviewers
if issue:
input_api.rietveld.get_issue_properties(
issue=int(input_api.change.issue), messages=True).AndReturn(
rietveld_response)
if not cq_dry_run:
if issue:
input_api.rietveld.get_issue_properties(
issue=int(input_api.change.issue), messages=True).AndReturn(
rietveld_response)
people.add(change.author_email)
fake_db.files_not_covered_by(set(['foo/xyz.cc']),
people).AndReturn(uncovered_files)
if not is_committing and uncovered_files:
fake_db.reviewers_for(set(['foo']),
change.author_email).AndReturn(change.author_email)
people.add(change.author_email)
fake_db.files_not_covered_by(set(['foo/xyz.cc']),
people).AndReturn(uncovered_files)
if not is_committing and uncovered_files:
fake_db.reviewers_for(set(['foo']),
change.author_email).AndReturn(change.author_email)
self.mox.ReplayAll()
output = presubmit.PresubmitOutput()
......@@ -2635,6 +2641,23 @@ class CannedChecksUnittest(PresubmitTestsBase):
results[0].handle(output)
self.assertEquals(output.getvalue(), expected_output)
def testCannedCheckOwners_DryRun(self):
response = {
"owner_email": "john@example.com",
"cq_dry_run": True,
"reviewers": ["ben@example.com"],
}
self.AssertOwnersWorks(approvers=set(),
cq_dry_run=True,
rietveld_response=response,
reviewers=set(["ben@example.com"]),
expected_output='This is a CQ dry run, skipping OWNERS check\n')
self.AssertOwnersWorks(approvers=set(['ben@example.com']),
is_committing=False,
rietveld_response=response,
expected_output='')
def testCannedCheckOwners_Approved(self):
response = {
"owner_email": "john@example.com",
......
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