<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[159977] trunk/Tools</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/159977">159977</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2013-12-02 15:52:34 -0800 (Mon, 02 Dec 2013)</dd>
</dl>
<h3>Log Message</h3>
<pre>Remove the stderr_write attribute from StyleProcessorConfiguration
https://bugs.webkit.org/show_bug.cgi?id=124703
Patch by László Langó <lango@inf.u-szeged.hu> on 2013-12-02
Reviewed by Ryosuke Niwa.
Remove the stderr_write attribute from this class in checker and
replace its use with calls to a logging module logger. We Should
use logging module instead of writing to stderr directly.
* Scripts/webkitpy/style/checker.py: Change stderr_write attribute to logging module logger.
(check_webkit_style_configuration):
(CheckerDispatcher.dispatch): Remove FIXME comment.
(StyleProcessorConfiguration):
(StyleProcessorConfiguration.__init__):
(StyleProcessorConfiguration.write_style_error):
* Scripts/webkitpy/style/checker_unittest.py: Update test to the modification.
There is an "ERROR" prefix in log messiges from now.
(StyleProcessorConfigurationTest):
(StyleProcessorConfigurationTest._style_checker_configuration):
(StyleProcessorConfigurationTest.test_init):
(StyleProcessorConfigurationTest.test_write_style_error_emacs):
(StyleProcessorConfigurationTest.test_write_style_error_vs7):
(StyleProcessor_EndToEndTest.with):
(StyleProcessor_EndToEndTest.test_init):
(StyleProcessor_EndToEndTest.test_process):
(StyleProcessor_CodeCoverageTest.setUp):
* Scripts/webkitpy/style/error_handlers.py: Remove stderr_write usage and replace with logging module logger.
(DefaultStyleErrorHandler.__call__):
* Scripts/webkitpy/style/error_handlers_unittest.py: Update test to the modification.
There is an "ERROR" prefix in log messiges from now.
(DefaultStyleErrorHandlerTest):
(DefaultStyleErrorHandlerTest.setUp):
(DefaultStyleErrorHandlerTest._mock_increment_error_count):
(DefaultStyleErrorHandlerTest._style_checker_configuration):
(DefaultStyleErrorHandlerTest._check_initialized):
(DefaultStyleErrorHandlerTest.test_non_reportable_error):
(DefaultStyleErrorHandlerTest.test_max_reports_per_category):
(DefaultStyleErrorHandlerTest.test_line_numbers):</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpystylecheckerpy">trunk/Tools/Scripts/webkitpy/style/checker.py</a></li>
<li><a href="#trunkToolsScriptswebkitpystylechecker_unittestpy">trunk/Tools/Scripts/webkitpy/style/checker_unittest.py</a></li>
<li><a href="#trunkToolsScriptswebkitpystyleerror_handlerspy">trunk/Tools/Scripts/webkitpy/style/error_handlers.py</a></li>
<li><a href="#trunkToolsScriptswebkitpystyleerror_handlers_unittestpy">trunk/Tools/Scripts/webkitpy/style/error_handlers_unittest.py</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (159976 => 159977)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2013-12-02 23:48:35 UTC (rev 159976)
+++ trunk/Tools/ChangeLog        2013-12-02 23:52:34 UTC (rev 159977)
</span><span class="lines">@@ -1,3 +1,44 @@
</span><ins>+2013-12-02 László Langó <lango@inf.u-szeged.hu>
+
+ Remove the stderr_write attribute from StyleProcessorConfiguration
+ https://bugs.webkit.org/show_bug.cgi?id=124703
+
+ Reviewed by Ryosuke Niwa.
+
+ Remove the stderr_write attribute from this class in checker and
+ replace its use with calls to a logging module logger. We Should
+ use logging module instead of writing to stderr directly.
+
+ * Scripts/webkitpy/style/checker.py: Change stderr_write attribute to logging module logger.
+ (check_webkit_style_configuration):
+ (CheckerDispatcher.dispatch): Remove FIXME comment.
+ (StyleProcessorConfiguration):
+ (StyleProcessorConfiguration.__init__):
+ (StyleProcessorConfiguration.write_style_error):
+ * Scripts/webkitpy/style/checker_unittest.py: Update test to the modification.
+ There is an "ERROR" prefix in log messiges from now.
+ (StyleProcessorConfigurationTest):
+ (StyleProcessorConfigurationTest._style_checker_configuration):
+ (StyleProcessorConfigurationTest.test_init):
+ (StyleProcessorConfigurationTest.test_write_style_error_emacs):
+ (StyleProcessorConfigurationTest.test_write_style_error_vs7):
+ (StyleProcessor_EndToEndTest.with):
+ (StyleProcessor_EndToEndTest.test_init):
+ (StyleProcessor_EndToEndTest.test_process):
+ (StyleProcessor_CodeCoverageTest.setUp):
+ * Scripts/webkitpy/style/error_handlers.py: Remove stderr_write usage and replace with logging module logger.
+ (DefaultStyleErrorHandler.__call__):
+ * Scripts/webkitpy/style/error_handlers_unittest.py: Update test to the modification.
+ There is an "ERROR" prefix in log messiges from now.
+ (DefaultStyleErrorHandlerTest):
+ (DefaultStyleErrorHandlerTest.setUp):
+ (DefaultStyleErrorHandlerTest._mock_increment_error_count):
+ (DefaultStyleErrorHandlerTest._style_checker_configuration):
+ (DefaultStyleErrorHandlerTest._check_initialized):
+ (DefaultStyleErrorHandlerTest.test_non_reportable_error):
+ (DefaultStyleErrorHandlerTest.test_max_reports_per_category):
+ (DefaultStyleErrorHandlerTest.test_line_numbers):
+
</ins><span class="cx"> 2013-12-02 Brian J. Burg <burg@cs.washington.edu>
</span><span class="cx">
</span><span class="cx"> Add JavaScript style checker and teach checker.py about .js files
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckerpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (159976 => 159977)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checker.py        2013-12-02 23:48:35 UTC (rev 159976)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py        2013-12-02 23:52:34 UTC (rev 159977)
</span><span class="lines">@@ -398,8 +398,7 @@
</span><span class="cx"> return StyleProcessorConfiguration(filter_configuration=filter_configuration,
</span><span class="cx"> max_reports_per_category=_MAX_REPORTS_PER_CATEGORY,
</span><span class="cx"> min_confidence=options.min_confidence,
</span><del>- output_format=options.output_format,
- stderr_write=sys.stderr.write)
</del><ins>+ output_format=options.output_format)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> def _create_log_handlers(stream):
</span><span class="lines">@@ -654,8 +653,6 @@
</span><span class="cx"> return checker
</span><span class="cx">
</span><span class="cx">
</span><del>-# FIXME: Remove the stderr_write attribute from this class and replace
-# its use with calls to a logging module logger.
</del><span class="cx"> class StyleProcessorConfiguration(object):
</span><span class="cx">
</span><span class="cx"> """Stores configuration values for the StyleProcessor class.
</span><span class="lines">@@ -667,17 +664,13 @@
</span><span class="cx"> max_reports_per_category: The maximum number of errors to report
</span><span class="cx"> per category, per file.
</span><span class="cx">
</span><del>- stderr_write: A function that takes a string as a parameter and
- serves as stderr.write.
-
</del><span class="cx"> """
</span><span class="cx">
</span><span class="cx"> def __init__(self,
</span><span class="cx"> filter_configuration,
</span><span class="cx"> max_reports_per_category,
</span><span class="cx"> min_confidence,
</span><del>- output_format,
- stderr_write):
</del><ins>+ output_format):
</ins><span class="cx"> """Create a StyleProcessorConfiguration instance.
</span><span class="cx">
</span><span class="cx"> Args:
</span><span class="lines">@@ -696,16 +689,12 @@
</span><span class="cx"> output formats are "emacs" which emacs can parse
</span><span class="cx"> and "vs7" which Microsoft Visual Studio 7 can parse.
</span><span class="cx">
</span><del>- stderr_write: A function that takes a string as a parameter and
- serves as stderr.write.
-
</del><span class="cx"> """
</span><span class="cx"> self._filter_configuration = filter_configuration
</span><span class="cx"> self._output_format = output_format
</span><span class="cx">
</span><span class="cx"> self.max_reports_per_category = max_reports_per_category
</span><span class="cx"> self.min_confidence = min_confidence
</span><del>- self.stderr_write = stderr_write
</del><span class="cx">
</span><span class="cx"> def is_reportable(self, category, confidence_in_error, file_path):
</span><span class="cx"> """Return whether an error is reportable.
</span><span class="lines">@@ -735,11 +724,11 @@
</span><span class="cx"> message):
</span><span class="cx"> """Write a style error to the configured stderr."""
</span><span class="cx"> if self._output_format == 'vs7':
</span><del>- format_string = "%s(%s): %s [%s] [%d]\n"
</del><ins>+ format_string = "%s(%s): %s [%s] [%d]"
</ins><span class="cx"> else:
</span><del>- format_string = "%s:%s: %s [%s] [%d]\n"
</del><ins>+ format_string = "%s:%s: %s [%s] [%d]"
</ins><span class="cx">
</span><del>- self.stderr_write(format_string % (file_path,
</del><ins>+ _log.error(format_string % (file_path,
</ins><span class="cx"> line_number,
</span><span class="cx"> message,
</span><span class="cx"> category,
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylechecker_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/checker_unittest.py (159976 => 159977)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/checker_unittest.py        2013-12-02 23:48:35 UTC (rev 159976)
+++ trunk/Tools/Scripts/webkitpy/style/checker_unittest.py        2013-12-02 23:52:34 UTC (rev 159977)
</span><span class="lines">@@ -596,17 +596,10 @@
</span><span class="cx"> self.assert_checker_none(path)
</span><span class="cx">
</span><span class="cx">
</span><del>-class StyleProcessorConfigurationTest(unittest.TestCase):
</del><ins>+class StyleProcessorConfigurationTest(LoggingTestCase):
</ins><span class="cx">
</span><span class="cx"> """Tests the StyleProcessorConfiguration class."""
</span><span class="cx">
</span><del>- def setUp(self):
- self._error_messages = []
- """The messages written to _mock_stderr_write() of this class."""
-
- def _mock_stderr_write(self, message):
- self._error_messages.append(message)
-
</del><span class="cx"> def _style_checker_configuration(self, output_format="vs7"):
</span><span class="cx"> """Return a StyleProcessorConfiguration instance for testing."""
</span><span class="cx"> base_rules = ["-whitespace", "+whitespace/tab"]
</span><span class="lines">@@ -616,8 +609,7 @@
</span><span class="cx"> filter_configuration=filter_configuration,
</span><span class="cx"> max_reports_per_category={"whitespace/newline": 1},
</span><span class="cx"> min_confidence=3,
</span><del>- output_format=output_format,
- stderr_write=self._mock_stderr_write)
</del><ins>+ output_format=output_format)
</ins><span class="cx">
</span><span class="cx"> def test_init(self):
</span><span class="cx"> """Test the __init__() method."""
</span><span class="lines">@@ -626,7 +618,6 @@
</span><span class="cx"> # Check that __init__ sets the "public" data attributes correctly.
</span><span class="cx"> self.assertEqual(configuration.max_reports_per_category,
</span><span class="cx"> {"whitespace/newline": 1})
</span><del>- self.assertEqual(configuration.stderr_write, self._mock_stderr_write)
</del><span class="cx"> self.assertEqual(configuration.min_confidence, 3)
</span><span class="cx">
</span><span class="cx"> def test_is_reportable(self):
</span><span class="lines">@@ -652,56 +643,44 @@
</span><span class="cx"> def test_write_style_error_emacs(self):
</span><span class="cx"> """Test the write_style_error() method."""
</span><span class="cx"> self._call_write_style_error("emacs")
</span><del>- self.assertEqual(self._error_messages,
- ["foo.h:100: message [whitespace/tab] [5]\n"])
</del><ins>+ self.assertLog(["ERROR: foo.h:100: message [whitespace/tab] [5]\n"])
</ins><span class="cx">
</span><span class="cx"> def test_write_style_error_vs7(self):
</span><span class="cx"> """Test the write_style_error() method."""
</span><span class="cx"> self._call_write_style_error("vs7")
</span><del>- self.assertEqual(self._error_messages,
- ["foo.h(100): message [whitespace/tab] [5]\n"])
</del><ins>+ self.assertLog(["ERROR: foo.h(100): message [whitespace/tab] [5]\n"])
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> class StyleProcessor_EndToEndTest(LoggingTestCase):
</span><span class="cx">
</span><span class="cx"> """Test the StyleProcessor class with an emphasis on end-to-end tests."""
</span><span class="cx">
</span><del>- def setUp(self):
- LoggingTestCase.setUp(self)
- self._messages = []
-
- def _mock_stderr_write(self, message):
- """Save a message so it can later be asserted."""
- self._messages.append(message)
-
</del><span class="cx"> def test_init(self):
</span><span class="cx"> """Test __init__ constructor."""
</span><span class="cx"> configuration = StyleProcessorConfiguration(
</span><span class="cx"> filter_configuration=FilterConfiguration(),
</span><span class="cx"> max_reports_per_category={},
</span><span class="cx"> min_confidence=3,
</span><del>- output_format="vs7",
- stderr_write=self._mock_stderr_write)
</del><ins>+ output_format="vs7")
</ins><span class="cx"> processor = StyleProcessor(configuration)
</span><span class="cx">
</span><span class="cx"> self.assertEqual(processor.error_count, 0)
</span><del>- self.assertEqual(self._messages, [])
</del><span class="cx">
</span><span class="cx"> def test_process(self):
</span><span class="cx"> configuration = StyleProcessorConfiguration(
</span><span class="cx"> filter_configuration=FilterConfiguration(),
</span><span class="cx"> max_reports_per_category={},
</span><span class="cx"> min_confidence=3,
</span><del>- output_format="vs7",
- stderr_write=self._mock_stderr_write)
</del><ins>+ output_format="vs7")
</ins><span class="cx"> processor = StyleProcessor(configuration)
</span><span class="cx">
</span><span class="cx"> processor.process(lines=['line1', 'Line with tab:\t'],
</span><span class="cx"> file_path='foo.txt')
</span><ins>+
</ins><span class="cx"> self.assertEqual(processor.error_count, 1)
</span><del>- expected_messages = ['foo.txt(2): Line contains tab character. '
</del><ins>+ expected_messages = ['ERROR: foo.txt(2): Line contains tab character. '
</ins><span class="cx"> '[whitespace/tab] [5]\n']
</span><del>- self.assertEqual(self._messages, expected_messages)
</del><ins>+ self.assertLog(expected_messages)
</ins><span class="cx">
</span><span class="cx">
</span><span class="cx"> class StyleProcessor_CodeCoverageTest(LoggingTestCase):
</span><span class="lines">@@ -763,8 +742,7 @@
</span><span class="cx"> filter_configuration=FilterConfiguration(),
</span><span class="cx"> max_reports_per_category={"whitespace/newline": 1},
</span><span class="cx"> min_confidence=3,
</span><del>- output_format="vs7",
- stderr_write=self._swallow_stderr_message)
</del><ins>+ output_format="vs7")
</ins><span class="cx">
</span><span class="cx"> mock_carriage_checker_class = self._create_carriage_checker_class()
</span><span class="cx"> mock_dispatcher = self.MockDispatcher()
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystyleerror_handlerspy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/error_handlers.py (159976 => 159977)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/error_handlers.py        2013-12-02 23:48:35 UTC (rev 159976)
+++ trunk/Tools/Scripts/webkitpy/style/error_handlers.py        2013-12-02 23:52:34 UTC (rev 159977)
</span><span class="lines">@@ -49,9 +49,13 @@
</span><span class="cx"> """
</span><span class="cx">
</span><span class="cx">
</span><ins>+import logging
</ins><span class="cx"> import sys
</span><span class="cx">
</span><span class="cx">
</span><ins>+_log = logging.getLogger(__name__)
+
+
</ins><span class="cx"> class DefaultStyleErrorHandler(object):
</span><span class="cx">
</span><span class="cx"> """The default style error handler."""
</span><span class="lines">@@ -159,6 +163,6 @@
</span><span class="cx"> line_number=line_number,
</span><span class="cx"> message=message)
</span><span class="cx"> if category_total == max_reports:
</span><del>- self._configuration.stderr_write("Suppressing further [%s] reports "
- "for this file.\n" % category)
</del><ins>+ _log.error("Suppressing further [%s] reports "
+ "for this file." % category)
</ins><span class="cx"> return True
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystyleerror_handlers_unittestpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/error_handlers_unittest.py (159976 => 159977)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/Scripts/webkitpy/style/error_handlers_unittest.py        2013-12-02 23:48:35 UTC (rev 159976)
+++ trunk/Tools/Scripts/webkitpy/style/error_handlers_unittest.py        2013-12-02 23:52:34 UTC (rev 159977)
</span><span class="lines">@@ -28,14 +28,15 @@
</span><span class="cx"> from checker import StyleProcessorConfiguration
</span><span class="cx"> from error_handlers import DefaultStyleErrorHandler
</span><span class="cx"> from filter import FilterConfiguration
</span><ins>+from webkitpy.common.system.logtesting import LoggingTestCase
</ins><span class="cx">
</span><span class="cx">
</span><del>-class DefaultStyleErrorHandlerTest(unittest.TestCase):
</del><ins>+class DefaultStyleErrorHandlerTest(LoggingTestCase):
</ins><span class="cx">
</span><span class="cx"> """Tests the DefaultStyleErrorHandler class."""
</span><span class="cx">
</span><span class="cx"> def setUp(self):
</span><del>- self._error_messages = []
</del><ins>+ super(DefaultStyleErrorHandlerTest, self).setUp()
</ins><span class="cx"> self._error_count = 0
</span><span class="cx">
</span><span class="cx"> _category = "whitespace/tab"
</span><span class="lines">@@ -47,9 +48,6 @@
</span><span class="cx"> def _mock_increment_error_count(self):
</span><span class="cx"> self._error_count += 1
</span><span class="cx">
</span><del>- def _mock_stderr_write(self, message):
- self._error_messages.append(message)
-
</del><span class="cx"> def _style_checker_configuration(self):
</span><span class="cx"> """Return a StyleProcessorConfiguration instance for testing."""
</span><span class="cx"> base_rules = ["-whitespace", "+whitespace/tab"]
</span><span class="lines">@@ -59,8 +57,7 @@
</span><span class="cx"> filter_configuration=filter_configuration,
</span><span class="cx"> max_reports_per_category={"whitespace/tab": 2},
</span><span class="cx"> min_confidence=3,
</span><del>- output_format="vs7",
- stderr_write=self._mock_stderr_write)
</del><ins>+ output_format="vs7")
</ins><span class="cx">
</span><span class="cx"> def _error_handler(self, configuration, line_numbers=None):
</span><span class="cx"> return DefaultStyleErrorHandler(configuration=configuration,
</span><span class="lines">@@ -71,7 +68,6 @@
</span><span class="cx"> def _check_initialized(self):
</span><span class="cx"> """Check that count and error messages are initialized."""
</span><span class="cx"> self.assertEqual(0, self._error_count)
</span><del>- self.assertEqual(0, len(self._error_messages))
</del><span class="cx">
</span><span class="cx"> def _call_error_handler(self, handle_error, confidence, line_number=100):
</span><span class="cx"> """Call the given error handler with a test error."""
</span><span class="lines">@@ -132,7 +128,6 @@
</span><span class="cx"> self._call_error_handler(error_handler, confidence)
</span><span class="cx">
</span><span class="cx"> self.assertEqual(0, self._error_count)
</span><del>- self.assertEqual([], self._error_messages)
</del><span class="cx">
</span><span class="cx"> # Also serves as a reportable error test.
</span><span class="cx"> def test_max_reports_per_category(self):
</span><span class="lines">@@ -146,26 +141,21 @@
</span><span class="cx"> # First call: usual reporting.
</span><span class="cx"> self._call_error_handler(error_handler, confidence)
</span><span class="cx"> self.assertEqual(1, self._error_count)
</span><del>- self.assertEqual(1, len(self._error_messages))
- self.assertEqual(self._error_messages,
- ["foo.h(100): message [whitespace/tab] [5]\n"])
</del><ins>+ self.assertLog(["ERROR: foo.h(100): message [whitespace/tab] [5]\n"])
</ins><span class="cx">
</span><span class="cx"> # Second call: suppression message reported.
</span><span class="cx"> self._call_error_handler(error_handler, confidence)
</span><span class="cx"> # The "Suppressing further..." message counts as an additional
</span><span class="cx"> # message (but not as an addition to the error count).
</span><span class="cx"> self.assertEqual(2, self._error_count)
</span><del>- self.assertEqual(3, len(self._error_messages))
- self.assertEqual(self._error_messages[-2],
- "foo.h(100): message [whitespace/tab] [5]\n")
- self.assertEqual(self._error_messages[-1],
- "Suppressing further [whitespace/tab] reports "
- "for this file.\n")
</del><ins>+ expected_message = ["ERROR: foo.h(100): message [whitespace/tab] [5]\n",
+ "ERROR: Suppressing further [whitespace/tab] reports for this file.\n"]
+ self.assertLog(expected_message)
</ins><span class="cx">
</span><span class="cx"> # Third call: no report.
</span><span class="cx"> self._call_error_handler(error_handler, confidence)
</span><span class="cx"> self.assertEqual(3, self._error_count)
</span><del>- self.assertEqual(3, len(self._error_messages))
</del><ins>+ self.assertLog([])
</ins><span class="cx">
</span><span class="cx"> def test_line_numbers(self):
</span><span class="cx"> """Test the line_numbers parameter."""
</span><span class="lines">@@ -178,19 +168,16 @@
</span><span class="cx"> # Error on non-modified line: no error.
</span><span class="cx"> self._call_error_handler(error_handler, confidence, line_number=60)
</span><span class="cx"> self.assertEqual(0, self._error_count)
</span><del>- self.assertEqual([], self._error_messages)
</del><ins>+ self.assertLog([])
</ins><span class="cx">
</span><span class="cx"> # Error on modified line: error.
</span><span class="cx"> self._call_error_handler(error_handler, confidence, line_number=50)
</span><span class="cx"> self.assertEqual(1, self._error_count)
</span><del>- self.assertEqual(self._error_messages,
- ["foo.h(50): message [whitespace/tab] [5]\n"])
</del><ins>+ self.assertLog(["ERROR: foo.h(50): message [whitespace/tab] [5]\n"])
</ins><span class="cx">
</span><span class="cx"> # Error on non-modified line after turning off line filtering: error.
</span><span class="cx"> error_handler.turn_off_line_filtering()
</span><span class="cx"> self._call_error_handler(error_handler, confidence, line_number=60)
</span><span class="cx"> self.assertEqual(2, self._error_count)
</span><del>- self.assertEqual(self._error_messages,
- ['foo.h(50): message [whitespace/tab] [5]\n',
- 'foo.h(60): message [whitespace/tab] [5]\n',
- 'Suppressing further [whitespace/tab] reports for this file.\n'])
</del><ins>+ self.assertLog(['ERROR: foo.h(60): message [whitespace/tab] [5]\n',
+ 'ERROR: Suppressing further [whitespace/tab] reports for this file.\n'])
</ins></span></pre>
</div>
</div>
</body>
</html>