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

Unified Diff: owners.py

Issue 6639010: Add more tests for owners.py, remove unneeded code, make syntax errors more helpful (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Created 9 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tests/owners_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: owners.py
diff --git a/owners.py b/owners.py
index 780e3c64e3afb64d390ab8984ae5532448b76091..f43deae97b32e0b39896e19d5041044a32673ffa 100644
--- a/owners.py
+++ b/owners.py
@@ -16,17 +16,14 @@ BASIC_EMAIL_REGEXP = r'^[\w\-\+\%\.]+\@[\w\-\+\%\.]+$'
class SyntaxErrorInOwnersFile(Exception):
- def __init__(self, path, line, msg):
- super(SyntaxErrorInOwnersFile, self).__init__((path, line, msg))
+ def __init__(self, path, lineno, msg):
+ super(SyntaxErrorInOwnersFile, self).__init__((path, lineno, msg))
self.path = path
- self.line = line
+ self.lineno = lineno
self.msg = msg
def __str__(self):
- if self.msg:
- return "%s:%d syntax error: %s" % (self.path, self.line, self.msg)
- else:
- return "%s:%d syntax error" % (self.path, self.line)
+ return "%s:%d syntax error: %s" % (self.path, self.lineno, self.msg)
class Database(object):
@@ -141,11 +138,16 @@ class Database(object):
if line == 'set noparent':
self.stop_looking.add(dirpath)
continue
+ if line.startswith('set '):
+ raise SyntaxErrorInOwnersFile(owners_path, lineno,
+ 'unknown option: "%s"' % line[4:].strip())
if self.email_regexp.match(line) or line == EVERYONE:
self.owned_by.setdefault(line, set()).add(dirpath)
self.owners_for.setdefault(dirpath, set()).add(line)
continue
- raise SyntaxErrorInOwnersFile(owners_path, lineno, line)
+ raise SyntaxErrorInOwnersFile(owners_path, lineno,
+ ('line is not a comment, a "set" directive, '
+ 'or an email address: "%s"' % line))
def _covering_set_of_owners_for(self, files):
# TODO(dpranke): implement the greedy algorithm for covering sets, and
« no previous file with comments | « no previous file | tests/owners_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698