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

Unified Diff: PRESUBMIT_unittest.py

Issue 42086: Allow PRESUBMIT.py to handle deleted files. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 11 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.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: PRESUBMIT_unittest.py
===================================================================
--- PRESUBMIT_unittest.py (revision 11452)
+++ PRESUBMIT_unittest.py (working copy)
@@ -19,17 +19,24 @@
self.re = re
self.os_path = os.path
- def AffectedFiles(self):
- return self.affected_files
+ def AffectedFiles(self, include_deletes=True):
+ if include_deletes:
+ return self.affected_files
+ else:
+ return filter(lambda x: x.Action() != 'D', self.affected_files)
def AffectedTextFiles(self, include_deletes=True):
return self.affected_files
class MockAffectedFile(object):
- def __init__(self, path):
+ def __init__(self, path, action='A'):
self.path = path
+ self.action = action
+ def Action(self):
+ return self.action
+
def LocalPath(self):
return self.path
@@ -82,6 +89,14 @@
self.file_contents = 'file with\nzero \\t errors \\r\\n\n'
self.failIf(PRESUBMIT.LocalChecks(api, MockOutputApi))
+ def testLocalChecksDeletedFile(self):
+ api = MockInputApi()
+ api.affected_files = [
+ MockAffectedFile('foo/blat/source.py', 'D'),
+ ]
+ self.file_contents = 'file with \n\terror\nhere\r\nyes there'
+ self.failUnless(len(PRESUBMIT.LocalChecks(api, MockOutputApi)) == 0)
+
if __name__ == '__main__':
unittest.main()
« no previous file with comments | « PRESUBMIT.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698