Diff
Modified: trunk/Tools/ChangeLog (160082 => 160083)
--- trunk/Tools/ChangeLog 2013-12-04 09:57:48 UTC (rev 160082)
+++ trunk/Tools/ChangeLog 2013-12-04 11:08:56 UTC (rev 160083)
@@ -1,3 +1,46 @@
+2013-12-04 Tamas Gergely <[email protected]>
+
+ style-bot should reject Committer additions to committers.py
+ https://bugs.webkit.org/show_bug.cgi?id=107574
+
+ Reviewed by Zoltan Herczeg.
+
+ The style check when executed in non-interactive mode (probably by a
+ bot) will raise an additional error if the contributors.json file is
+ modified. Non-interactive mode information is propagated to the
+ Dispatcher, which creates a special JSON checker for the
+ contributors.json file.
+
+ * Scripts/webkitpy/style/checker.py:
+ (check_webkit_style_configuration):
+ (CheckerDispatcher._create_checker):
+ (CheckerDispatcher.dispatch):
+ (StyleProcessorConfiguration.__init__):
+ (StyleProcessor.process):
+ * Scripts/webkitpy/style/checker_unittest.py:
+ (CheckerDispatcherSkipTest._assert_should_skip_without_warning):
+ (CheckerDispatcherDispatchTest.dispatch):
+ (StyleProcessorConfigurationTest._style_checker_configuration):
+ (StyleProcessor_EndToEndTest.test_init):
+ (StyleProcessor_EndToEndTest.test_process):
+ (StyleProcessor_CodeCoverageTest.MockDispatcher.dispatch):
+ (StyleProcessor_CodeCoverageTest.setUp):
+ * Scripts/webkitpy/style/checkers/jsonchecker.py:
+ (JSONChecker.line_number_from_json_exception):
+ (JSONContributorsChecker):
+ (JSONContributorsChecker.check):
+ * Scripts/webkitpy/style/error_handlers_unittest.py:
+ (DefaultStyleErrorHandlerTest._style_checker_configuration):
+ * Scripts/webkitpy/style/optparser.py:
+ (CommandOptionValues.__init__):
+ (ArgumentParser._create_option_parser):
+ (ArgumentParser.parse):
+ * Scripts/webkitpy/tool/commands/upload_unittest.py:
+ (test_post):
+ (test_upload):
+ * Scripts/webkitpy/tool/steps/checkstyle.py:
+ (CheckStyle.run):
+
2013-12-04 Nick Diego Yamane <[email protected]>
[EFL][WK2] Fix build after API::Client changes
Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (160082 => 160083)
--- trunk/Tools/Scripts/webkitpy/style/checker.py 2013-12-04 09:57:48 UTC (rev 160082)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py 2013-12-04 11:08:56 UTC (rev 160083)
@@ -43,6 +43,7 @@
from checkers.cmake import CMakeChecker
from checkers.js import JSChecker
from checkers.jsonchecker import JSONChecker
+from checkers.jsonchecker import JSONContributorsChecker
from checkers.png import PNGChecker
from checkers.python import PythonChecker
from checkers.test_expectations import TestExpectationsChecker
@@ -398,7 +399,8 @@
return StyleProcessorConfiguration(filter_configuration=filter_configuration,
max_reports_per_category=_MAX_REPORTS_PER_CATEGORY,
min_confidence=options.min_confidence,
- output_format=options.output_format)
+ output_format=options.output_format,
+ commit_queue=options.commit_queue)
def _create_log_handlers(stream):
@@ -593,7 +595,7 @@
return FileType.NONE
def _create_checker(self, file_type, file_path, handle_style_error,
- min_confidence):
+ min_confidence, commit_queue):
"""Instantiate and return a style checker based on file type."""
if file_type == FileType.NONE:
checker = None
@@ -613,7 +615,11 @@
else:
checker = TextChecker(file_path, handle_style_error)
elif file_type == FileType.JSON:
- checker = JSONChecker(file_path, handle_style_error)
+ basename = os.path.basename(file_path)
+ if commit_queue and basename == 'contributors.json':
+ checker = JSONContributorsChecker(file_path, handle_style_error)
+ else:
+ checker = JSONChecker(file_path, handle_style_error)
elif file_type == FileType.PYTHON:
checker = PythonChecker(file_path, handle_style_error)
elif file_type == FileType.XML:
@@ -642,14 +648,15 @@
return checker
- def dispatch(self, file_path, handle_style_error, min_confidence):
+ def dispatch(self, file_path, handle_style_error, min_confidence, commit_queue):
"""Instantiate and return a style checker based on file path."""
file_type = self._file_type(file_path)
checker = self._create_checker(file_type,
file_path,
handle_style_error,
- min_confidence)
+ min_confidence,
+ commit_queue)
return checker
@@ -670,7 +677,8 @@
filter_configuration,
max_reports_per_category,
min_confidence,
- output_format):
+ output_format,
+ commit_queue):
"""Create a StyleProcessorConfiguration instance.
Args:
@@ -689,12 +697,16 @@
output formats are "emacs" which emacs can parse
and "vs7" which Microsoft Visual Studio 7 can parse.
+ commit_queue: A bool indicating whether the style check is performed
+ by the commit queue or not.
+
"""
self._filter_configuration = filter_configuration
self._output_format = output_format
self.max_reports_per_category = max_reports_per_category
self.min_confidence = min_confidence
+ self.commit_queue = commit_queue
def is_reportable(self, category, confidence_in_error, file_path):
"""Return whether an error is reportable.
@@ -864,7 +876,8 @@
min_confidence = self._configuration.min_confidence
checker = self._dispatcher.dispatch(file_path,
style_error_handler,
- min_confidence)
+ min_confidence,
+ self._configuration.commit_queue)
if checker is None:
raise AssertionError("File should not be checked: '%s'" % file_path)
Modified: trunk/Tools/Scripts/webkitpy/style/checker_unittest.py (160082 => 160083)
--- trunk/Tools/Scripts/webkitpy/style/checker_unittest.py 2013-12-04 09:57:48 UTC (rev 160082)
+++ trunk/Tools/Scripts/webkitpy/style/checker_unittest.py 2013-12-04 11:08:56 UTC (rev 160083)
@@ -309,7 +309,8 @@
# Check the file type before asserting the return value.
checker = self._dispatcher.dispatch(file_path=path,
handle_style_error=None,
- min_confidence=3)
+ min_confidence=3,
+ commit_queue=False)
message = 'while checking: %s' % path
self.assertEqual(checker is None, is_checker_none, message)
self.assertEqual(self._dispatcher.should_skip_without_warning(path),
@@ -367,7 +368,8 @@
self.mock_handle_style_error = DefaultStyleErrorHandler('', None, None, [])
checker = dispatcher.dispatch(file_path,
self.mock_handle_style_error,
- min_confidence=3)
+ min_confidence=3,
+ commit_queue=False)
return checker
def assert_checker_none(self, file_path):
@@ -609,7 +611,8 @@
filter_configuration=filter_configuration,
max_reports_per_category={"whitespace/newline": 1},
min_confidence=3,
- output_format=output_format)
+ output_format=output_format,
+ commit_queue=False)
def test_init(self):
"""Test the __init__() method."""
@@ -661,7 +664,8 @@
filter_configuration=FilterConfiguration(),
max_reports_per_category={},
min_confidence=3,
- output_format="vs7")
+ output_format="vs7",
+ commit_queue=False)
processor = StyleProcessor(configuration)
self.assertEqual(processor.error_count, 0)
@@ -671,7 +675,8 @@
filter_configuration=FilterConfiguration(),
max_reports_per_category={},
min_confidence=3,
- output_format="vs7")
+ output_format="vs7",
+ commit_queue=False)
processor = StyleProcessor(configuration)
processor.process(lines=['line1', 'Line with tab:\t'],
@@ -719,7 +724,7 @@
def should_check_and_strip_carriage_returns(self, file_path):
return not file_path.endswith('carriage_returns_allowed.txt')
- def dispatch(self, file_path, style_error_handler, min_confidence):
+ def dispatch(self, file_path, style_error_handler, min_confidence, commit_queue):
if file_path.endswith('do_not_process.txt'):
return None
@@ -742,7 +747,8 @@
filter_configuration=FilterConfiguration(),
max_reports_per_category={"whitespace/newline": 1},
min_confidence=3,
- output_format="vs7")
+ output_format="vs7",
+ commit_queue=False)
mock_carriage_checker_class = self._create_carriage_checker_class()
mock_dispatcher = self.MockDispatcher()
Modified: trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py (160082 => 160083)
--- trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py 2013-12-04 09:57:48 UTC (rev 160082)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py 2013-12-04 11:08:56 UTC (rev 160083)
@@ -47,3 +47,11 @@
if not match:
return 0
return int(match.group('line'))
+
+
+class JSONContributorsChecker(JSONChecker):
+ """Processes contributors.json lines"""
+
+ def check(self, lines):
+ super(JSONContributorsChecker, self).check(lines)
+ self._handle_style_error(0, 'json/syntax', 5, 'contributors.json should not be modified through the commit queue')
Modified: trunk/Tools/Scripts/webkitpy/style/error_handlers_unittest.py (160082 => 160083)
--- trunk/Tools/Scripts/webkitpy/style/error_handlers_unittest.py 2013-12-04 09:57:48 UTC (rev 160082)
+++ trunk/Tools/Scripts/webkitpy/style/error_handlers_unittest.py 2013-12-04 11:08:56 UTC (rev 160083)
@@ -57,7 +57,8 @@
filter_configuration=filter_configuration,
max_reports_per_category={"whitespace/tab": 2},
min_confidence=3,
- output_format="vs7")
+ output_format="vs7",
+ commit_queue=False)
def _error_handler(self, configuration, line_numbers=None):
return DefaultStyleErrorHandler(configuration=configuration,
Modified: trunk/Tools/Scripts/webkitpy/style/optparser.py (160082 => 160083)
--- trunk/Tools/Scripts/webkitpy/style/optparser.py 2013-12-04 09:57:48 UTC (rev 160082)
+++ trunk/Tools/Scripts/webkitpy/style/optparser.py 2013-12-04 11:08:56 UTC (rev 160083)
@@ -148,7 +148,8 @@
diff_files=None,
is_verbose=False,
min_confidence=1,
- output_format="emacs"):
+ output_format="emacs",
+ commit_queue=False):
if filter_rules is None:
filter_rules = []
@@ -168,6 +169,7 @@
self.is_verbose = is_verbose
self.min_confidence = min_confidence
self.output_format = output_format
+ self.commit_queue = commit_queue
# Useful for unit testing.
def __eq__(self, other):
@@ -337,6 +339,9 @@
parser.add_option("-v", "--verbose", dest="is_verbose", default=False,
action="" help=verbose_help)
+ commit_queue_help = "force commit queue to check contributors.json change"
+ parser.add_option("--commit-queue", action="" dest="commit_queue", default=False, help=commit_queue_help)
+
# Override OptionParser's error() method so that option help will
# also display when an error occurs. Normally, just the usage
# string displays and not option help.
@@ -422,6 +427,7 @@
is_verbose = options.is_verbose
min_confidence = options.min_confidence
output_format = options.output_format
+ commit_queue = options.commit_queue
if filter_value is not None and not filter_value:
# Then the user explicitly passed no filter, for
@@ -451,7 +457,8 @@
diff_files=diff_files,
is_verbose=is_verbose,
min_confidence=min_confidence,
- output_format=output_format)
+ output_format=output_format,
+ commit_queue=commit_queue)
return (paths, options)
Modified: trunk/Tools/Scripts/webkitpy/tool/commands/upload_unittest.py (160082 => 160083)
--- trunk/Tools/Scripts/webkitpy/tool/commands/upload_unittest.py 2013-12-04 09:57:48 UTC (rev 160082)
+++ trunk/Tools/Scripts/webkitpy/tool/commands/upload_unittest.py 2013-12-04 11:08:56 UTC (rev 160083)
@@ -63,6 +63,7 @@
options.check_style_filter = None
options.comment = None
options.description = "MOCK description"
+ options.non_interactive = False
options.request_commit = False
options.review = True
options.suggest_reviewers = False
@@ -114,6 +115,7 @@
options.check_style_filter = None
options.comment = None
options.description = "MOCK description"
+ options.non_interactive = False
options.request_commit = False
options.review = True
options.suggest_reviewers = False
Modified: trunk/Tools/Scripts/webkitpy/tool/steps/checkstyle.py (160082 => 160083)
--- trunk/Tools/Scripts/webkitpy/tool/steps/checkstyle.py 2013-12-04 09:57:48 UTC (rev 160082)
+++ trunk/Tools/Scripts/webkitpy/tool/steps/checkstyle.py 2013-12-04 11:08:56 UTC (rev 160083)
@@ -56,6 +56,11 @@
args.append("--filter")
args.append(self._options.check_style_filter)
+ if self._options.non_interactive:
+ # We assume that only bots run this script in non interactive mode
+ # in which case we perform additional style check
+ args.append("--commit-queue")
+
try:
self._tool.executive.run_and_throw_if_fail(self._tool.deprecated_port().check_webkit_style_command() + args, cwd=self._tool.scm().checkout_root)
except ScriptError, e: