diff options
author | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 19:56:49 +0000 |
---|---|---|
committer | enne@chromium.org <enne@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-12-05 19:56:49 +0000 |
commit | b8079ae4a88a75d51a665bcce707de0886c89359 (patch) | |
tree | 6e45fc3fabca13239d7f57a6ffc3a6c1eecaed5e /PRESUBMIT_test.py | |
parent | b3cbad18d0dfda956b782ce575b632f4de785d55 (diff) | |
download | chromium_src-b8079ae4a88a75d51a665bcce707de0886c89359.zip chromium_src-b8079ae4a88a75d51a665bcce707de0886c89359.tar.gz chromium_src-b8079ae4a88a75d51a665bcce707de0886c89359.tar.bz2 |
Add a presubmit check to prevent committing .rej/.orig patch files
This is a follow-up to me having to remove some of these by hand in r171143.
R=maruel@chromium.org
NOTRY=true
BUG=none
Review URL: https://chromiumcodereview.appspot.com/11448014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@171287 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'PRESUBMIT_test.py')
-rwxr-xr-x | PRESUBMIT_test.py | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/PRESUBMIT_test.py b/PRESUBMIT_test.py index 183ec6e..debe33b 100755 --- a/PRESUBMIT_test.py +++ b/PRESUBMIT_test.py @@ -14,6 +14,27 @@ class MockInputApi(object): def __init__(self): self.re = re self.os_path = os.path + self.files = [] + + def AffectedFiles(self): + return self.files + + +class MockOutputApi(object): + class PresubmitResult(object): + def __init__(self, message, items=None, long_text=''): + self.message = message + self.items = items + self.long_text = long_text + + class PresubmitError(PresubmitResult): + pass + + class PresubmitPromptWarning(PresubmitResult): + pass + + class PresubmitNotifyResult(PresubmitResult): + pass class MockFile(object): @@ -201,5 +222,43 @@ class VersionControlerConflictsTest(unittest.TestCase): self.assertTrue('5' in errors[2]) +class BadExtensionsTest(unittest.TestCase): + def testBadRejFile(self): + mock_input_api = MockInputApi() + mock_input_api.files = [ + MockFile('some/path/foo.cc', ''), + MockFile('some/path/foo.cc.rej', ''), + MockFile('some/path2/bar.h.rej', ''), + ] + + results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi()) + self.assertEqual(1, len(results)) + self.assertEqual(2, len(results[0].items)) + self.assertTrue('foo.cc.rej' in results[0].items[0]) + self.assertTrue('bar.h.rej' in results[0].items[1]) + + def testBadOrigFile(self): + mock_input_api = MockInputApi() + mock_input_api.files = [ + MockFile('other/path/qux.h.orig', ''), + MockFile('other/path/qux.h', ''), + MockFile('other/path/qux.cc', ''), + ] + + results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi()) + self.assertEqual(1, len(results)) + self.assertEqual(1, len(results[0].items)) + self.assertTrue('qux.h.orig' in results[0].items[0]) + + def testGoodFiles(self): + mock_input_api = MockInputApi() + mock_input_api.files = [ + MockFile('other/path/qux.h', ''), + MockFile('other/path/qux.cc', ''), + ] + results = PRESUBMIT._CheckPatchFiles(mock_input_api, MockOutputApi()) + self.assertEqual(0, len(results)) + + if __name__ == '__main__': unittest.main() |