Changeset 57870 in webkit


Ignore:
Timestamp:
Apr 19, 2010 10:41:51 PM (14 years ago)
Author:
hamaji@chromium.org
Message:

2010-04-19 Shinichiro Hamaji <hamaji@chromium.org>

Reviewed by David Levin.

check-webkit-style: exits when encountering a deleted file
https://bugs.webkit.org/show_bug.cgi?id=37122

This reverts the quick fix done by r57119 and makes check_patch
not call check_file for deleted files.

Also this change fixes the behavior for "-", which should mean
stdin. Before this change, the style checker just ignored "-"
with a warning message.

  • Scripts/webkitpy/style/checker.py:
  • Scripts/webkitpy/style/checker_unittest.py:
Location:
trunk/WebKitTools
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebKitTools/ChangeLog

    r57869 r57870  
     12010-04-19  Shinichiro Hamaji  <hamaji@chromium.org>
     2
     3        Reviewed by David Levin.
     4
     5        check-webkit-style: exits when encountering a deleted file
     6        https://bugs.webkit.org/show_bug.cgi?id=37122
     7
     8        This reverts the quick fix done by r57119 and makes check_patch
     9        not call check_file for deleted files.
     10
     11        Also this change fixes the behavior for "-", which should mean
     12        stdin.  Before this change, the style checker just ignored "-"
     13        with a warning message.
     14
     15        * Scripts/webkitpy/style/checker.py:
     16        * Scripts/webkitpy/style/checker_unittest.py:
     17
    1182010-04-19  Daniel Bates  <dbates@rim.com>
    219
  • trunk/WebKitTools/Scripts/webkitpy/style/checker.py

    r57803 r57870  
    691691                             class.
    692692
     693        Raises:
     694          SystemExit: if the file does not exist.
     695
    693696        """
    694697        if mock_handle_style_error is None:
     
    707710                        mock_process_file)
    708711
    709         if not os_path_exists(file_path):
    710             _log.warn("Skipping non-existent file: %s" % file_path)
    711             return
     712        if not os_path_exists(file_path) and file_path != "-":
     713            _log.error("File does not exist: %s" % file_path)
     714            sys.exit(1)
    712715
    713716        _log.debug("Checking: " + file_path)
     
    767770                       % (len(line_numbers), path))
    768771
    769             self._file_checker.check_file(file_path=path,
    770                                           line_numbers=line_numbers)
     772            # If line_numbers is empty, the file has no new or
     773            # modified lines.  In this case, we don't check the file
     774            # because we'll never output errors for the file.
     775            # This optimization also prevents the program from exiting
     776            # due to a deleted file.
     777            if line_numbers:
     778                self._file_checker.check_file(file_path=path,
     779                                              line_numbers=line_numbers)
  • trunk/WebKitTools/Scripts/webkitpy/style/checker_unittest.py

    r57467 r57870  
    632632            mock_process_file=self.mock_process_file)
    633633
    634         file_count = 1 if self.mock_os_path_exists(file_path) else 0
    635 
    636         self.assertEquals(file_count, style_checker.file_count)
     634        self.assertEquals(style_checker.file_count, 1)
    637635
    638636    def test_check_file_does_not_exist(self):
     
    643641
    644642        # Check the outcome.
     643        self.assertRaises(SystemExit, self.call_check_file, file_path)
     644        self.assertLog(["ERROR: File does not exist: "
     645                        "file_does_not_exist.txt\n"])
     646
     647    def test_check_file_stdin(self):
     648        file_path = "-"
     649
     650        # Confirm that the file does not exist.
     651        self.assertFalse(self.mock_os_path_exists(file_path))
     652
     653        # Check the outcome.
    645654        self.call_check_file(file_path)
    646         self.assert_attributes(None, None, None, "")
    647         self.assertLog(['WARNING: Skipping non-existent file: '
    648                         'file_does_not_exist.txt\n'])
     655        expected_processor = CppProcessor(file_path,
     656                                          "",
     657                                          self.mock_handle_style_error, 3)
     658        self.assert_attributes(file_path,
     659                               self.mock_handle_style_error,
     660                               expected_processor,
     661                               "")
    649662
    650663    def test_check_file_on_skip_without_warning(self):
     
    783796""")
    784797        self._assert_checked([("__init__.py", set([2]))])
     798
     799    def test_check_patch_with_deletion(self):
     800        self._call_check_patch("""Index: __init__.py
     801===================================================================
     802--- __init__.py  (revision 3593)
     803+++ __init__.py  (working copy)
     804@@ -1 +0,0 @@
     805-foobar
     806""")
     807        # _mock_check_file should not be called for the deletion patch.
     808        self._assert_checked([])
Note: See TracChangeset for help on using the changeset viewer.