lint-test-expectations should be run during style checking
authorjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jul 2017 16:33:33 +0000 (16:33 +0000)
committerjbedard@apple.com <jbedard@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 20 Jul 2017 16:33:33 +0000 (16:33 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173559
<rdar://problem/32854941>

Reviewed by Aakash Jain.

* Scripts/webkitpy/layout_tests/models/test_expectations.py:
(TestExpectationsModel._already_seen_better_match): Append returns 'None' when successful,
prevents identifying errors on specific lines in a file.
* Scripts/webkitpy/style/main_unittest.py:
(ExpectationLinterInStyleCheckerTest.test_linter_duplicate_line_edit_in_file): Test for the
case where a linter error is in the file modified, but the line modified is not related to
the linter error.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@219689 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Tools/ChangeLog
Tools/Scripts/webkitpy/layout_tests/models/test_expectations.py
Tools/Scripts/webkitpy/style/main_unittest.py

index 4aae8f3..ac52d40 100644 (file)
@@ -1,3 +1,19 @@
+2017-07-20  Jonathan Bedard  <jbedard@apple.com>
+
+        lint-test-expectations should be run during style checking
+        https://bugs.webkit.org/show_bug.cgi?id=173559
+        <rdar://problem/32854941>
+
+        Reviewed by Aakash Jain.
+
+        * Scripts/webkitpy/layout_tests/models/test_expectations.py:
+        (TestExpectationsModel._already_seen_better_match): Append returns 'None' when successful,
+        prevents identifying errors on specific lines in a file.
+        * Scripts/webkitpy/style/main_unittest.py:
+        (ExpectationLinterInStyleCheckerTest.test_linter_duplicate_line_edit_in_file): Test for the
+        case where a linter error is in the file modified, but the line modified is not related to
+        the linter error.
+
 2017-07-20  Brady Eidson  <beidson@apple.com>
 
         Remove WebIconDatabase from WebKitLegacy/win.
 2017-07-20  Brady Eidson  <beidson@apple.com>
 
         Remove WebIconDatabase from WebKitLegacy/win.
index 047e4ae..afe5ccb 100644 (file)
@@ -744,10 +744,12 @@ class TestExpectationsModel(object):
 
         # Missing files will be 'None'. It should be impossible to have a missing file which also has a line associated with it.
         assert shortened_previous_expectation_filename not in expectation_line.related_files or expectation_line.related_files[shortened_previous_expectation_filename] is not None
 
         # Missing files will be 'None'. It should be impossible to have a missing file which also has a line associated with it.
         assert shortened_previous_expectation_filename not in expectation_line.related_files or expectation_line.related_files[shortened_previous_expectation_filename] is not None
-        expectation_line.related_files[shortened_previous_expectation_filename] = expectation_line.related_files.get(shortened_previous_expectation_filename, []).append(prev_expectation_line.line_number)
+        expectation_line.related_files[shortened_previous_expectation_filename] = expectation_line.related_files.get(shortened_previous_expectation_filename, [])
+        expectation_line.related_files[shortened_previous_expectation_filename].append(prev_expectation_line.line_number)
 
         assert shortened_expectation_filename not in prev_expectation_line.related_files or prev_expectation_line.related_files[shortened_expectation_filename] is not None
 
         assert shortened_expectation_filename not in prev_expectation_line.related_files or prev_expectation_line.related_files[shortened_expectation_filename] is not None
-        prev_expectation_line.related_files[shortened_expectation_filename] = prev_expectation_line.related_files.get(shortened_expectation_filename, []).append(expectation_line.line_number)
+        prev_expectation_line.related_files[shortened_expectation_filename] = prev_expectation_line.related_files.get(shortened_expectation_filename, [])
+        prev_expectation_line.related_files[shortened_expectation_filename].append(expectation_line.line_number)
 
         return True
 
 
         return True
 
index 58d12be..46d7e16 100644 (file)
@@ -149,6 +149,19 @@ class ExpectationLinterInStyleCheckerTest(unittest.TestCase):
             file_reader.do_association_check('/mock-checkout', host)
         self.assertEqual(scope.captured_output, ('', '', ''))
 
             file_reader.do_association_check('/mock-checkout', host)
         self.assertEqual(scope.captured_output, ('', '', ''))
 
+    def test_linter_duplicate_line_edit_in_file(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', line_numbers=[1])
+            file_reader.do_association_check('/mock-checkout', host)
+        self.assertEqual(scope.captured_output, ('', '', ''))
+
     def test_linter_deleted_file(self):
         files = {
             '/mock-checkout/LayoutTests/TestExpectations':
     def test_linter_deleted_file(self):
         files = {
             '/mock-checkout/LayoutTests/TestExpectations':