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

Unified Diff: tests/presubmit_unittest.py

Issue 7097012: Improve CheckLongLines() to increase the hard limit at 50% when an exception is found. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/tools/depot_tools
Patch Set: Fix regex to work properly, update unit test accordingly Created 9 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
« presubmit_canned_checks.py ('K') | « presubmit_canned_checks.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 5f87a742ecc09a83b232ac5ebd86e7f125a42262..9ef2675b05829c9c4c322a819fb8c88ae4818d57 100755
--- a/tests/presubmit_unittest.py
+++ b/tests/presubmit_unittest.py
@@ -1427,7 +1427,7 @@ class CannedChecksUnittest(PresubmitTestsBase):
file_filter=mox.IgnoreArg()).AndReturn([affected_file])
affected_file.NewContents().AndReturn([
'ahoy',
- 'yo' + content1,
+ content1,
'hay',
'yer',
'ya'])
@@ -1441,12 +1441,15 @@ class CannedChecksUnittest(PresubmitTestsBase):
file_filter=mox.IgnoreArg()).AndReturn([affected_file])
affected_file.NewContents().AndReturn([
'ahoy',
- 'yo' + content2,
+ content2,
'hay',
'yer',
'ya'])
+ # It falls back to ChangedContents when there is a failure. This is an
+ # optimization since NewContents() is much faster to execute than
+ # ChangedContents().
affected_file.ChangedContents().AndReturn([
- (42, 'yo, ' + content2),
+ (42, content2),
(43, 'yer'),
(23, 'ya')])
affected_file.LocalPath().AndReturn('foo.cc')
@@ -1646,12 +1649,41 @@ class CannedChecksUnittest(PresubmitTestsBase):
self.assertEquals(results1[0]._long_text,
'makefile.foo, line 46')
-
def testCannedCheckLongLines(self):
check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
- self.ContentTest(check, '', 'blah blah blah',
+ self.ContentTest(check, '0123456789', '01234567890',
+ presubmit.OutputApi.PresubmitPromptWarning)
+
+ def testCannedCheckLongLinesLF(self):
+ check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
+ self.ContentTest(check, '012345678\n', '0123456789\n',
presubmit.OutputApi.PresubmitPromptWarning)
+ def testCannedCheckLongLinesMacro(self):
+ check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
+ self.ContentTest(
+ check,
+ # Put a space in so it doesn't trigger long symbols. Allow 1/3 more.
+ '#if 56 89 12 45',
+ '#if 56 89 12 456',
+ presubmit.OutputApi.PresubmitPromptWarning)
+
+ def testCannedCheckLongLinesHttp(self):
+ check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
+ self.ContentTest(
+ check,
+ ' http:// 0 23 5',
+ ' http:// 0 23 56',
+ presubmit.OutputApi.PresubmitPromptWarning)
+
+ def testCannedCheckLongLinesLongSymbol(self):
+ check = lambda x, y, z: presubmit_canned_checks.CheckLongLines(x, y, 10, z)
+ self.ContentTest(
+ check,
+ ' TUP5D_LoNG_SY ',
+ ' TUP5D_LoNG_SY5 ',
+ presubmit.OutputApi.PresubmitPromptWarning)
+
def testCheckChangeSvnEolStyleCommit(self):
# Test CheckSvnProperty at the same time.
self.SvnPropertyTest(presubmit_canned_checks.CheckChangeSvnEolStyle,
« presubmit_canned_checks.py ('K') | « presubmit_canned_checks.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698