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

Unified Diff: tests/owners_unittest.py

Issue 2148153002: Fix per-file owners check for deleted files. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Rebase! Created 4 years, 5 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 | « tests/owners_finder_test.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/owners_unittest.py
diff --git a/tests/owners_unittest.py b/tests/owners_unittest.py
index 5cc5371e64d80084b3be1ed3544a0d64d109ad4b..0cc6d72979b50e62d19a0251fe9edfad1a40681d 100755
--- a/tests/owners_unittest.py
+++ b/tests/owners_unittest.py
@@ -73,14 +73,12 @@ class _BaseTestCase(unittest.TestCase):
self.files = self.repo.files
self.root = '/'
self.fopen = self.repo.open_for_reading
- self.glob = self.repo.glob
- def db(self, root=None, fopen=None, os_path=None, glob=None):
+ def db(self, root=None, fopen=None, os_path=None):
root = root or self.root
fopen = fopen or self.fopen
os_path = os_path or self.repo
- glob = glob or self.glob
- return owners.Database(root, fopen, os_path, glob)
+ return owners.Database(root, fopen, os_path)
class OwnersDatabaseTest(_BaseTestCase):
@@ -150,9 +148,15 @@ class OwnersDatabaseTest(_BaseTestCase):
['content/content.gyp', 'content/bar/foo.cc', 'content/baz/froboz.h'])
def test_per_file(self):
- # brett isn't allowed to approve ugly.cc
self.files['/content/baz/OWNERS'] = owners_file(brett,
lines=['per-file ugly.*=tom@example.com'])
+
+ # peter isn't allowed to approve ugly.cc
+ self.assert_files_not_covered_by(['content/baz/ugly.cc'],
+ [peter],
+ ['content/baz/ugly.cc'])
+
+ # brett is allowed to approve ugly.cc
self.assert_files_not_covered_by(['content/baz/ugly.cc'],
[brett],
[])
@@ -167,14 +171,22 @@ class OwnersDatabaseTest(_BaseTestCase):
def test_per_file_with_spaces(self):
# This is the same as test_per_file(), except that we include spaces
- # on the per-file line. brett isn't allowed to approve ugly.cc;
+ # on the per-file line.
# tom is allowed to approve ugly.cc, but not froboz.h
self.files['/content/baz/OWNERS'] = owners_file(brett,
lines=['per-file ugly.* = tom@example.com'])
+
+ # peter isn't allowed to approve ugly.cc
+ self.assert_files_not_covered_by(['content/baz/ugly.cc'],
+ [peter],
+ ['content/baz/ugly.cc'])
+
+ # brett is allowed to approve ugly.cc
self.assert_files_not_covered_by(['content/baz/ugly.cc'],
[brett],
[])
+ # tom is allowed to approve ugly.cc, but not froboz.h
self.assert_files_not_covered_by(['content/baz/ugly.cc'],
[tom],
[])
@@ -182,6 +194,21 @@ class OwnersDatabaseTest(_BaseTestCase):
[tom],
['content/baz/froboz.h'])
+ def test_per_file_with_nonexistent_file(self):
+ self.files['/content/baz/OWNERS'] = owners_file(brett,
+ lines=['per-file ugly.*=tom@example.com'])
+
+ # peter isn't allowed to approve ugly.nonexistent.cc, but brett and tom are.
+ self.assert_files_not_covered_by(['content/baz/ugly.nonexistent.cc'],
+ [peter],
+ ['content/baz/ugly.nonexistent.cc'])
+ self.assert_files_not_covered_by(['content/baz/ugly.nonexistent.cc'],
+ [brett],
+ [])
+ self.assert_files_not_covered_by(['content/baz/ugly.nonexistent.cc'],
+ [tom],
+ [])
+
def test_per_file__set_noparent(self):
self.files['/content/baz/OWNERS'] = owners_file(brett,
lines=['per-file ugly.*=tom@example.com',
« no previous file with comments | « tests/owners_finder_test.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698