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

Unified Diff: tests/owners_unittest.py

Issue 9621012: Show a list of directories missing OWNER reviewers on upload, and show directories rather than file… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools/
Patch Set: Created 8 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 | « presubmit_canned_checks.py ('k') | tests/presubmit_unittest.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/owners_unittest.py
===================================================================
--- tests/owners_unittest.py (revision 125361)
+++ tests/owners_unittest.py (working copy)
@@ -44,6 +44,9 @@
'/chrome/renderer/safe_browsing/scorer.h': '',
'/content/OWNERS': owners_file(john, darin, comment='foo', noparent=True),
'/content/content.gyp': '',
+ '/content/bar/foo.cc': '',
+ '/content/baz/OWNERS': owners_file(brett),
+ '/content/baz/froboz.h': '',
'/content/views/OWNERS': owners_file(ben, john, owners.EVERYONE,
noparent=True),
})
@@ -65,70 +68,68 @@
def test_constructor(self):
self.assertNotEquals(self.db(), None)
- def assert_covered_by(self, files, reviewers):
+ def test_dirs_not_covered_by__valid_inputs(self):
db = self.db()
- self.assertTrue(db.files_are_covered_by(set(files), set(reviewers)))
- def test_covered_by__everyone(self):
- self.assert_covered_by(['DEPS'], [john])
- self.assert_covered_by(['DEPS'], [darin])
+ # Check that we're passed in a sequence that isn't a string.
+ self.assertRaises(AssertionError, db.directories_not_covered_by, 'foo', [])
+ if hasattr(owners.collections, 'Iterable'):
+ self.assertRaises(AssertionError, db.directories_not_covered_by,
+ (f for f in ['x', 'y']), [])
- def test_covered_by__explicit(self):
- self.assert_covered_by(['content/content.gyp'], [john])
- self.assert_covered_by(['chrome/gpu/OWNERS'], [ken])
+ # Check that the files are under the root.
+ db.root = '/checkout'
+ self.assertRaises(AssertionError, db.directories_not_covered_by,
+ ['/OWNERS'], [])
+ db.root = '/'
- def test_covered_by__owners_plus_everyone(self):
- self.assert_covered_by(['/content/views/OWNERS'], [ben])
- self.assert_covered_by(['/content/views/OWNERS'], [ken])
+ # Check invalid email address.
+ self.assertRaises(AssertionError, db.directories_not_covered_by,
+ ['OWNERS'], ['foo'])
- def test_covered_by__owners_propagates_down(self):
- self.assert_covered_by(['chrome/gpu/OWNERS'], [ben])
-
- def test_covered_by__no_file_in_dir(self):
- self.assert_covered_by(['/chrome/renderer/gpu/gpu_channel_host.h'], [peter])
-
- def assert_not_covered_by(self, files, reviewers, unreviewed_files):
+ def assert_dirs_not_covered_by(self, files, reviewers, unreviewed_dirs):
db = self.db()
- self.assertEquals(db.files_not_covered_by(set(files), set(reviewers)),
- set(unreviewed_files))
+ self.assertEquals(
+ db.directories_not_covered_by(set(files), set(reviewers)),
+ set(unreviewed_dirs))
- def test_not_covered_by__need_at_least_one_reviewer(self):
- self.assert_not_covered_by(['DEPS'], [], ['DEPS'])
-
- def test_not_covered_by__owners_propagates_down(self):
- self.assert_not_covered_by(
+ def test_dirs_not_covered_by__owners_propagates_down(self):
+ self.assert_dirs_not_covered_by(
['chrome/gpu/gpu_channel.h', 'chrome/renderer/gpu/gpu_channel_host.h'],
[ben], [])
- def test_not_covered_by__partial_covering(self):
- self.assert_not_covered_by(
+ def test_dirs_not_covered_by__partial_covering(self):
+ self.assert_dirs_not_covered_by(
['content/content.gyp', 'chrome/renderer/gpu/gpu_channel_host.h'],
- [peter], ['content/content.gyp'])
+ [peter], ['content'])
- def test_not_covered_by__set_noparent_works(self):
- self.assert_not_covered_by(['content/content.gyp'], [ben],
- ['content/content.gyp'])
+ def test_dirs_not_covered_by__set_noparent_works(self):
+ self.assert_dirs_not_covered_by(['content/content.gyp'], [ben],
+ ['content'])
- def test_not_covered_by__valid_inputs(self):
- db = self.db()
+ def test_dirs_not_covered_by__no_reviewer(self):
+ self.assert_dirs_not_covered_by(
+ ['content/content.gyp', 'chrome/renderer/gpu/gpu_channel_host.h'],
+ [], ['content'])
- # Check that we're passed in a sequence that isn't a string.
- self.assertRaises(AssertionError, db.files_not_covered_by, 'foo', [])
- if hasattr(owners.collections, 'Iterable'):
- self.assertRaises(AssertionError, db.files_not_covered_by,
- (f for f in ['x', 'y']), [])
+ def test_dirs_not_covered_by__combines_directories(self):
+ self.assert_dirs_not_covered_by(['content/content.gyp',
+ 'content/bar/foo.cc',
+ 'chrome/renderer/gpu/gpu_channel_host.h'],
+ [peter],
+ ['content'])
- # Check that the files are under the root.
- db.root = '/checkout'
- self.assertRaises(AssertionError, db.files_not_covered_by, ['/OWNERS'],
- [])
- db.root = '/'
+ def test_dirs_not_covered_by__multiple_directories(self):
+ self.assert_dirs_not_covered_by(
+ ['content/content.gyp', # Not covered
+ 'content/bar/foo.cc', # Not covered (combines in)
+ 'content/baz/froboz.h', # Not covered
+ 'chrome/gpu/gpu_channel.h', # Owned by ken
+ 'chrome/renderer/gpu/gpu_channel_host.h' # Owned by * via parent
+ ],
+ [ken],
+ ['content', 'content/baz'])
- # Check invalid email address.
- self.assertRaises(AssertionError, db.files_not_covered_by, ['OWNERS'],
- ['foo'])
-
-
def assert_reviewers_for(self, files, expected_reviewers):
db = self.db()
self.assertEquals(db.reviewers_for(set(files)), set(expected_reviewers))
« no previous file with comments | « presubmit_canned_checks.py ('k') | tests/presubmit_unittest.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698