Add more tests for owners.py, remove unneeded code, make syntax errors more helpful

Review URL: http://codereview.chromium.org/6639010

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@77522 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/owners.py b/owners.py
index 780e3c6..f43deae 100644
--- a/owners.py
+++ b/owners.py
@@ -16,17 +16,14 @@
 
 
 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 @@
       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