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

Unified Diff: tests/presubmit_unittest.py

Issue 119421: Add CheckChangeSvnEolStyle presubmit canned check. (Closed)
Patch Set: version Created 11 years, 6 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_support.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tests/presubmit_unittest.py
diff --git a/tests/presubmit_unittest.py b/tests/presubmit_unittest.py
index f0ea1d587a143a878fea8856c98c5742f8b8de88..25e484bafeb535edab70f4d3130ef8e52b593831 100755
--- a/tests/presubmit_unittest.py
+++ b/tests/presubmit_unittest.py
@@ -831,6 +831,7 @@ class AffectedFileUnittest(PresubmitTestsBase):
members = [
'AbsoluteLocalPath', 'Action', 'IsDirectory', 'IsTextFile', 'LocalPath',
'NewContents', 'OldContents', 'OldFileTempPath', 'Property', 'ServerPath',
+ 'scm',
]
# If this test fails, you should add the relevant test.
self.compareMembers(presubmit.AffectedFile('a', 'b'), members)
@@ -936,7 +937,8 @@ class CannedChecksUnittest(PresubmitTestsBase):
members = [
'CheckChangeHasBugField', 'CheckChangeHasNoCR', 'CheckChangeHasNoTabs',
'CheckChangeHasQaField', 'CheckChangeHasTestedField',
- 'CheckChangeHasTestField', 'CheckDoNotSubmit',
+ 'CheckChangeHasTestField', 'CheckChangeSvnEolStyle',
+ 'CheckDoNotSubmit',
'CheckDoNotSubmitInDescription', 'CheckDoNotSubmitInFiles',
'CheckLongLines', 'CheckTreeIsOpen', 'RunPythonUnitTests',
]
@@ -1049,6 +1051,38 @@ class CannedChecksUnittest(PresubmitTestsBase):
self.TestContent(check, '', 'blah blah blah',
presubmit.OutputApi.PresubmitPromptWarning)
+
+ def testCheckChangeSvnEolStyle(self):
+ input_api1 = self.MockInputApi()
+ files1 = [
+ presubmit.SvnAffectedFile('foo/bar.cc', 'A'),
+ presubmit.SvnAffectedFile('foo.cc', 'M'),
+ ]
+ input_api1.AffectedSourceFiles(None).AndReturn(files1)
+ presubmit.gcl.GetSVNFileProperty(presubmit.normpath('foo/bar.cc'),
+ 'svn:eol-style').AndReturn('LF')
+ presubmit.gcl.GetSVNFileProperty(presubmit.normpath('foo.cc'),
+ 'svn:eol-style').AndReturn('LF')
+ input_api2 = self.MockInputApi()
+ files2 = [
+ presubmit.SvnAffectedFile('foo/bar.cc', 'A'),
+ presubmit.SvnAffectedFile('foo.cc', 'M'),
+ ]
+ input_api2.AffectedSourceFiles(None).AndReturn(files2)
+ presubmit.gcl.GetSVNFileProperty(presubmit.normpath('foo/bar.cc'),
+ 'svn:eol-style').AndReturn('native')
+ presubmit.gcl.GetSVNFileProperty(presubmit.normpath('foo.cc'),
+ 'svn:eol-style').AndReturn('CRLF')
+ self.mox.ReplayAll()
+
+ results1 = presubmit_canned_checks.CheckChangeSvnEolStyle(
+ input_api1, presubmit.OutputApi, None)
+ self.assertEquals(results1, [])
+ results2 = presubmit_canned_checks.CheckChangeSvnEolStyle(
+ input_api2, presubmit.OutputApi, None)
+ self.assertEquals(len(results2), 1)
+ self.assertEquals(results2[0].__class__, presubmit.OutputApi.PresubmitError)
+
def testCannedCheckTreeIsOpenOpen(self):
input_api = self.MockInputApi()
input_api.is_committing = True
« no previous file with comments | « presubmit_support.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698