diff options
author | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-13 04:35:37 +0000 |
---|---|---|
committer | thestig@chromium.org <thestig@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-03-13 04:35:37 +0000 |
commit | 93372117fd610bcbcada3bb678f334e7840facd1 (patch) | |
tree | 227239a8eedcf1143a0acc92f503a357d0c3ae15 /PRESUBMIT_unittest.py | |
parent | 4862a2759ccc523b35d36b9d921bfc10fb86388a (diff) | |
download | chromium_src-93372117fd610bcbcada3bb678f334e7840facd1.zip chromium_src-93372117fd610bcbcada3bb678f334e7840facd1.tar.gz chromium_src-93372117fd610bcbcada3bb678f334e7840facd1.tar.bz2 |
Allow PRESUBMIT.py to handle deleted files.
This is a follow up to Issue 43098.
Review URL: http://codereview.chromium.org/42086
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@11619 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT_unittest.py')
-rwxr-xr-x | PRESUBMIT_unittest.py | 21 |
1 files changed, 18 insertions, 3 deletions
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() |