Title: [220158] trunk/Tools
Revision
220158
Author
[email protected]
Date
2017-08-02 15:35:44 -0700 (Wed, 02 Aug 2017)

Log Message

check-webkit-style: deleting lines in a file runs the linter on the whole file
https://bugs.webkit.org/show_bug.cgi?id=175078

Reviewed by David Kilzer.

Deleting lines in a file should not cause linter errors to be blamed on the patch.
<https://bugs.webkit.org/show_bug.cgi?id=86142> is an example of this happening.

* Scripts/webkitpy/style/checkers/test_expectations.py:
(TestExpectationsChecker._should_log_linter_warning): Do not log a linter error if the file it is associated with only has deleted lines
* Scripts/webkitpy/style/main_unittest.py:
(ExpectationLinterInStyleCheckerTest.test_linter_duplicate_line): Added files should have every line number in the file when processing.
(ExpectationLinterInStyleCheckerTest.test_linter_duplicate_line_only_deletes): Test case where the file with the linter errors only contained deletes.
(ExpectationLinterInStyleCheckerTest.test_linter_added_file_with_error): Added files should have every line number in the file when processing.

Modified Paths

Diff

Modified: trunk/Tools/ChangeLog (220157 => 220158)


--- trunk/Tools/ChangeLog	2017-08-02 22:31:49 UTC (rev 220157)
+++ trunk/Tools/ChangeLog	2017-08-02 22:35:44 UTC (rev 220158)
@@ -1,5 +1,22 @@
 2017-08-02  Jonathan Bedard  <[email protected]>
 
+        check-webkit-style: deleting lines in a file runs the linter on the whole file
+        https://bugs.webkit.org/show_bug.cgi?id=175078
+
+        Reviewed by David Kilzer.
+
+        Deleting lines in a file should not cause linter errors to be blamed on the patch.
+        <https://bugs.webkit.org/show_bug.cgi?id=86142> is an example of this happening.
+
+        * Scripts/webkitpy/style/checkers/test_expectations.py:
+        (TestExpectationsChecker._should_log_linter_warning): Do not log a linter error if the file it is associated with only has deleted lines
+        * Scripts/webkitpy/style/main_unittest.py:
+        (ExpectationLinterInStyleCheckerTest.test_linter_duplicate_line): Added files should have every line number in the file when processing.
+        (ExpectationLinterInStyleCheckerTest.test_linter_duplicate_line_only_deletes): Test case where the file with the linter errors only contained deletes.
+        (ExpectationLinterInStyleCheckerTest.test_linter_added_file_with_error): Added files should have every line number in the file when processing.
+
+2017-08-02  Jonathan Bedard  <[email protected]>
+
         webkitpy: Allow caller to specify response to unicode encode/decode error in filesystem
         https://bugs.webkit.org/show_bug.cgi?id=175075
 

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py (220157 => 220158)


--- trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py	2017-08-02 22:31:49 UTC (rev 220157)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/test_expectations.py	2017-08-02 22:35:44 UTC (rev 220158)
@@ -100,9 +100,10 @@
 
     @staticmethod
     def _should_log_linter_warning(warning, files, cwd, host):
+        abs_filename = host.filesystem.join(cwd, warning.filename)
+
         # Case 1, the line the warning was tied to is in our patch.
-        abs_filename = host.filesystem.join(cwd, warning.filename)
-        if abs_filename in files and (files[abs_filename] is None or warning.line_number in files[abs_filename]):
+        if abs_filename in files and files[abs_filename] and warning.line_number in files[abs_filename]:
             return True
 
         for file, lines in warning.related_files.iteritems():
@@ -115,7 +116,7 @@
 
                 # Case 3, a line associated with the warning is in our patch.
                 for line in lines:
-                    if line in files[abs_filename]:
+                    if files[abs_filename] and line in files[abs_filename]:
                         return True
         return False
 

Modified: trunk/Tools/Scripts/webkitpy/style/main_unittest.py (220157 => 220158)


--- trunk/Tools/Scripts/webkitpy/style/main_unittest.py	2017-08-02 22:31:49 UTC (rev 220157)
+++ trunk/Tools/Scripts/webkitpy/style/main_unittest.py	2017-08-02 22:35:44 UTC (rev 220158)
@@ -130,7 +130,7 @@
         scope = OutputCaptureScope()
         with scope:
             file_reader = self._generate_file_reader(host.filesystem)
-            file_reader.process_paths({'/mock-checkout/LayoutTests/TestExpectations'})
+            file_reader.process_file('/mock-checkout/LayoutTests/TestExpectations', line_numbers=[1, 2, 3])
             file_reader.do_association_check('/mock-checkout', host)
         self.assertEqual(
             scope.captured_output,
@@ -162,6 +162,19 @@
             file_reader.do_association_check('/mock-checkout', host)
         self.assertEqual(scope.captured_output, ('', '', ''))
 
+    def test_linter_duplicate_line_only_deletes(self):
+        files = {
+            '/mock-checkout/LayoutTests/TestExpectations':
+                '# TestExpectations\ncss1/test.html [ Failure ]\ncss1/test.html [ Failure ]\n'}
+        host = self._generate_testing_host(files)
+
+        scope = OutputCaptureScope()
+        with scope:
+            file_reader = self._generate_file_reader(host.filesystem)
+            file_reader.process_file('/mock-checkout/LayoutTests/TestExpectations')
+            file_reader.do_association_check('/mock-checkout', host)
+        self.assertEqual(scope.captured_output, ('', '', ''))
+
     def test_linter_added_file_with_error(self):
         files = {
             '/mock-checkout/LayoutTests/TestExpectations':
@@ -171,7 +184,7 @@
         scope = OutputCaptureScope()
         with scope:
             file_reader = self._generate_file_reader(host.filesystem)
-            file_reader.process_file('/mock-checkout/LayoutTests/TestExpectations', line_numbers=None)
+            file_reader.process_file('/mock-checkout/LayoutTests/TestExpectations', line_numbers=[1, 2, 3])
             file_reader.do_association_check('/mock-checkout', host)
         self.assertEqual(scope.captured_output, ('', '', '/mock-checkout/LayoutTests/TestExpectations:3:  Duplicate or ambiguous entry lines LayoutTests/TestExpectations:2 and LayoutTests/TestExpectations:3.  [test/expectations] [5]\n'))
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to