⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 160083 in webkit


Ignore:
Timestamp:
Dec 4, 2013, 3:08:56 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

style-bot should reject Committer additions to committers.py
https://bugs.webkit.org/show_bug.cgi?id=107574

Patch by Tamas Gergely <gertom@inf.u-szeged.hu> on 2013-12-04
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):

Location:
trunk/Tools
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r160075 r160083  
     12013-12-04  Tamas Gergely  <gertom@inf.u-szeged.hu>
     2
     3        style-bot should reject Committer additions to committers.py
     4        https://bugs.webkit.org/show_bug.cgi?id=107574
     5
     6        Reviewed by Zoltan Herczeg.
     7
     8        The style check when executed in non-interactive mode (probably by a
     9        bot) will raise an additional error if the contributors.json file is
     10        modified. Non-interactive mode information is propagated to the
     11        Dispatcher, which creates a special JSON checker for the
     12        contributors.json file.
     13
     14        * Scripts/webkitpy/style/checker.py:
     15        (check_webkit_style_configuration):
     16        (CheckerDispatcher._create_checker):
     17        (CheckerDispatcher.dispatch):
     18        (StyleProcessorConfiguration.__init__):
     19        (StyleProcessor.process):
     20        * Scripts/webkitpy/style/checker_unittest.py:
     21        (CheckerDispatcherSkipTest._assert_should_skip_without_warning):
     22        (CheckerDispatcherDispatchTest.dispatch):
     23        (StyleProcessorConfigurationTest._style_checker_configuration):
     24        (StyleProcessor_EndToEndTest.test_init):
     25        (StyleProcessor_EndToEndTest.test_process):
     26        (StyleProcessor_CodeCoverageTest.MockDispatcher.dispatch):
     27        (StyleProcessor_CodeCoverageTest.setUp):
     28        * Scripts/webkitpy/style/checkers/jsonchecker.py:
     29        (JSONChecker.line_number_from_json_exception):
     30        (JSONContributorsChecker):
     31        (JSONContributorsChecker.check):
     32        * Scripts/webkitpy/style/error_handlers_unittest.py:
     33        (DefaultStyleErrorHandlerTest._style_checker_configuration):
     34        * Scripts/webkitpy/style/optparser.py:
     35        (CommandOptionValues.__init__):
     36        (ArgumentParser._create_option_parser):
     37        (ArgumentParser.parse):
     38        * Scripts/webkitpy/tool/commands/upload_unittest.py:
     39        (test_post):
     40        (test_upload):
     41        * Scripts/webkitpy/tool/steps/checkstyle.py:
     42        (CheckStyle.run):
     43
    1442013-12-04  Nick Diego Yamane  <nick.yamane@openbossa.org>
    245
  • trunk/Tools/Scripts/webkitpy/style/checker.py

    r159977 r160083  
    4444from checkers.js import JSChecker
    4545from checkers.jsonchecker import JSONChecker
     46from checkers.jsonchecker import JSONContributorsChecker
    4647from checkers.png import PNGChecker
    4748from checkers.python import PythonChecker
     
    399400               max_reports_per_category=_MAX_REPORTS_PER_CATEGORY,
    400401               min_confidence=options.min_confidence,
    401                output_format=options.output_format)
     402               output_format=options.output_format,
     403               commit_queue=options.commit_queue)
    402404
    403405
     
    594596
    595597    def _create_checker(self, file_type, file_path, handle_style_error,
    596                         min_confidence):
     598                        min_confidence, commit_queue):
    597599        """Instantiate and return a style checker based on file type."""
    598600        if file_type == FileType.NONE:
     
    614616                checker = TextChecker(file_path, handle_style_error)
    615617        elif file_type == FileType.JSON:
    616             checker = JSONChecker(file_path, handle_style_error)
     618            basename = os.path.basename(file_path)
     619            if commit_queue and basename == 'contributors.json':
     620                checker = JSONContributorsChecker(file_path, handle_style_error)
     621            else:
     622                checker = JSONChecker(file_path, handle_style_error)
    617623        elif file_type == FileType.PYTHON:
    618624            checker = PythonChecker(file_path, handle_style_error)
     
    643649        return checker
    644650
    645     def dispatch(self, file_path, handle_style_error, min_confidence):
     651    def dispatch(self, file_path, handle_style_error, min_confidence, commit_queue):
    646652        """Instantiate and return a style checker based on file path."""
    647653        file_type = self._file_type(file_path)
     
    650656                                       file_path,
    651657                                       handle_style_error,
    652                                        min_confidence)
     658                                       min_confidence,
     659                                       commit_queue)
    653660        return checker
    654661
     
    671678                 max_reports_per_category,
    672679                 min_confidence,
    673                  output_format):
     680                 output_format,
     681                 commit_queue):
    674682        """Create a StyleProcessorConfiguration instance.
    675683
     
    690698                         and "vs7" which Microsoft Visual Studio 7 can parse.
    691699
     700          commit_queue: A bool indicating whether the style check is performed
     701                        by the commit queue or not.
     702
    692703        """
    693704        self._filter_configuration = filter_configuration
     
    696707        self.max_reports_per_category = max_reports_per_category
    697708        self.min_confidence = min_confidence
     709        self.commit_queue = commit_queue
    698710
    699711    def is_reportable(self, category, confidence_in_error, file_path):
     
    865877        checker = self._dispatcher.dispatch(file_path,
    866878                                            style_error_handler,
    867                                             min_confidence)
     879                                            min_confidence,
     880                                            self._configuration.commit_queue)
    868881
    869882        if checker is None:
  • trunk/Tools/Scripts/webkitpy/style/checker_unittest.py

    r159977 r160083  
    310310        checker = self._dispatcher.dispatch(file_path=path,
    311311                                            handle_style_error=None,
    312                                             min_confidence=3)
     312                                            min_confidence=3,
     313                                            commit_queue=False)
    313314        message = 'while checking: %s' % path
    314315        self.assertEqual(checker is None, is_checker_none, message)
     
    368369        checker = dispatcher.dispatch(file_path,
    369370                                      self.mock_handle_style_error,
    370                                       min_confidence=3)
     371                                      min_confidence=3,
     372                                      commit_queue=False)
    371373        return checker
    372374
     
    610612                   max_reports_per_category={"whitespace/newline": 1},
    611613                   min_confidence=3,
    612                    output_format=output_format)
     614                   output_format=output_format,
     615                   commit_queue=False)
    613616
    614617    def test_init(self):
     
    662665                            max_reports_per_category={},
    663666                            min_confidence=3,
    664                             output_format="vs7")
     667                            output_format="vs7",
     668                            commit_queue=False)
    665669        processor = StyleProcessor(configuration)
    666670
     
    672676                            max_reports_per_category={},
    673677                            min_confidence=3,
    674                             output_format="vs7")
     678                            output_format="vs7",
     679                            commit_queue=False)
    675680        processor = StyleProcessor(configuration)
    676681
     
    720725            return not file_path.endswith('carriage_returns_allowed.txt')
    721726
    722         def dispatch(self, file_path, style_error_handler, min_confidence):
     727        def dispatch(self, file_path, style_error_handler, min_confidence, commit_queue):
    723728            if file_path.endswith('do_not_process.txt'):
    724729                return None
     
    743748                            max_reports_per_category={"whitespace/newline": 1},
    744749                            min_confidence=3,
    745                             output_format="vs7")
     750                            output_format="vs7",
     751                            commit_queue=False)
    746752
    747753        mock_carriage_checker_class = self._create_carriage_checker_class()
  • trunk/Tools/Scripts/webkitpy/style/checkers/jsonchecker.py

    r107139 r160083  
    4848            return 0
    4949        return int(match.group('line'))
     50
     51
     52class JSONContributorsChecker(JSONChecker):
     53    """Processes contributors.json lines"""
     54
     55    def check(self, lines):
     56        super(JSONContributorsChecker, self).check(lines)
     57        self._handle_style_error(0, 'json/syntax', 5, 'contributors.json should not be modified through the commit queue')
  • trunk/Tools/Scripts/webkitpy/style/error_handlers_unittest.py

    r159977 r160083  
    5858                   max_reports_per_category={"whitespace/tab": 2},
    5959                   min_confidence=3,
    60                    output_format="vs7")
     60                   output_format="vs7",
     61                   commit_queue=False)
    6162
    6263    def _error_handler(self, configuration, line_numbers=None):
  • trunk/Tools/Scripts/webkitpy/style/optparser.py

    r134371 r160083  
    149149                 is_verbose=False,
    150150                 min_confidence=1,
    151                  output_format="emacs"):
     151                 output_format="emacs",
     152                 commit_queue=False):
    152153        if filter_rules is None:
    153154            filter_rules = []
     
    169170        self.min_confidence = min_confidence
    170171        self.output_format = output_format
     172        self.commit_queue = commit_queue
    171173
    172174    # Useful for unit testing.
     
    338340                          action="store_true", help=verbose_help)
    339341
     342        commit_queue_help = "force commit queue to check contributors.json change"
     343        parser.add_option("--commit-queue", action="store_true", dest="commit_queue", default=False, help=commit_queue_help)
     344
    340345        # Override OptionParser's error() method so that option help will
    341346        # also display when an error occurs.  Normally, just the usage
     
    423428        min_confidence = options.min_confidence
    424429        output_format = options.output_format
     430        commit_queue = options.commit_queue
    425431
    426432        if filter_value is not None and not filter_value:
     
    452458                                      is_verbose=is_verbose,
    453459                                      min_confidence=min_confidence,
    454                                       output_format=output_format)
     460                                      output_format=output_format,
     461                                      commit_queue=commit_queue)
    455462
    456463        return (paths, options)
  • trunk/Tools/Scripts/webkitpy/tool/commands/upload_unittest.py

    r135912 r160083  
    6464        options.comment = None
    6565        options.description = "MOCK description"
     66        options.non_interactive = False
    6667        options.request_commit = False
    6768        options.review = True
     
    115116        options.comment = None
    116117        options.description = "MOCK description"
     118        options.non_interactive = False
    117119        options.request_commit = False
    118120        options.review = True
  • trunk/Tools/Scripts/webkitpy/tool/steps/checkstyle.py

    r157682 r160083  
    5757            args.append(self._options.check_style_filter)
    5858
     59        if self._options.non_interactive:
     60            # We assume that only bots run this script in non interactive mode
     61            # in which case we perform additional style check
     62            args.append("--commit-queue")
     63
    5964        try:
    6065            self._tool.executive.run_and_throw_if_fail(self._tool.deprecated_port().check_webkit_style_command() + args, cwd=self._tool.scm().checkout_root)
Note: See TracChangeset for help on using the changeset viewer.