summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xPRESUBMIT.py2
-rwxr-xr-xPRESUBMIT_unittest.py21
2 files changed, 19 insertions, 4 deletions
diff --git a/PRESUBMIT.py b/PRESUBMIT.py
index 5744641..b86bc14 100755
--- a/PRESUBMIT.py
+++ b/PRESUBMIT.py
@@ -69,7 +69,7 @@ def LocalChecks(input_api, output_api, max_cols=80):
eof_files = []
results = []
excluded_paths = [input_api.re.compile(x) for x in EXCLUDED_PATHS]
- files = input_api.AffectedFiles()
+ files = input_api.AffectedFiles(include_deletes=False)
for f in files:
path = f.LocalPath()
root, ext = input_api.os_path.splitext(path)
diff --git a/PRESUBMIT_unittest.py b/PRESUBMIT_unittest.py
index 6f2ff00..5910213 100755
--- a/PRESUBMIT_unittest.py
+++ b/PRESUBMIT_unittest.py
@@ -19,16 +19,23 @@ class MockInputApi(object):
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 @@ class PresubmitUnittest(unittest.TestCase):
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()