Update CheckChangeSvnEolStyle() to be upload-friendly.

TEST=unit test
BUG=none

Review URL: http://codereview.chromium.org/118525

git-svn-id: svn://svn.chromium.org/chrome/trunk/tools/depot_tools@18079 0039d316-1c4b-4281-b951-d872f2087c98
experimental/szager/collated-output
maruel@chromium.org 16 years ago
parent 21b893b71c
commit 0874d47499

@ -178,8 +178,12 @@ def CheckChangeSvnEolStyle(input_api, output_api, source_file_filter=None):
bad = filter(lambda f: f.scm == 'svn' and f.Property('svn:eol-style') != 'LF',
input_api.AffectedSourceFiles(source_file_filter))
if bad:
return [output_api.PresubmitError(
"Fix these files with svn svn:eol-style=LF", items=bad)]
if input_api.is_committing:
return [output_api.PresubmitError(
"Fix these files with svn svn:eol-style=LF", items=bad)]
else:
return [output_api.PresubmitNotifyResult(
"Fix these files with svn svn:eol-style=LF", items=bad)]
return []

@ -1013,7 +1013,39 @@ class CannedChecksUnittest(PresubmitTestsBase):
results2 = check(input_api2, presubmit.OutputApi)
self.assertEquals(len(results2), 1)
self.assertEquals(results2[0].__class__, error_type)
def SvnPropertyTest(self, check, property, value1, value2, committing,
error_type):
input_api1 = self.MockInputApi()
input_api1.is_committing = committing
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'),
property).AndReturn(value1)
presubmit.gcl.GetSVNFileProperty(presubmit.normpath('foo.cc'),
property).AndReturn(value1)
input_api2 = self.MockInputApi()
input_api2.is_committing = committing
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'),
property).AndReturn(value2)
presubmit.gcl.GetSVNFileProperty(presubmit.normpath('foo.cc'),
property).AndReturn(value2)
self.mox.ReplayAll()
results1 = check(input_api1, presubmit.OutputApi, None)
self.assertEquals(results1, [])
results2 = check(input_api2, presubmit.OutputApi, None)
self.assertEquals(len(results2), 1)
self.assertEquals(results2[0].__class__, error_type)
def testCannedCheckChangeHasBugField(self):
self.DescriptionTest(presubmit_canned_checks.CheckChangeHasBugField,
'Foo\nBUG=1234', 'Foo\n',
@ -1092,37 +1124,15 @@ class CannedChecksUnittest(PresubmitTestsBase):
self.ContentTest(check, '', 'blah blah blah',
presubmit.OutputApi.PresubmitPromptWarning)
def testCheckChangeSvnEolStyleCommit(self):
self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle,
'svn:eol-style', 'LF', '', True,
presubmit.OutputApi.PresubmitError)
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 testCheckChangeSvnEolStyleUpload(self):
self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle,
'svn:eol-style', 'LF', '', False,
presubmit.OutputApi.PresubmitNotifyResult)
def testCannedCheckTreeIsOpenOpen(self):
input_api = self.MockInputApi()

Loading…
Cancel
Save