Title: [216110] trunk/Tools
Revision
216110
Author
[email protected]
Date
2017-05-02 20:59:24 -0700 (Tue, 02 May 2017)

Log Message

check-webkit-style should also keep js-test-post[-async].js in sync
<https://webkit.org/b/171568>

Reviewed by Joseph Pecoraro.

* Scripts/webkitpy/style/checker.py:
(_NEVER_SKIPPED_JS_FILES): Add new list that just contains
_javascript_ files not to be skipped.
(_NEVER_SKIPPED_FILES): Update to use _NEVER_SKIPPED_JS_FILES.
(CheckerDispatcher._create_checker): Update to use
_NEVER_SKIPPED_JS_FILES.

* Scripts/webkitpy/style/checkers/jstest.py:
(ALL_JS_TEST_FUNCTION_FILES): Rename from ALL_JS_TEST_FILES.
This is the list of files containing functions that need to be
kept in sync.
(KEEP_JS_TEST_FILES_IN_SYNC): Change to list-of-lists format so
we can keep more sets of files in sync between
LayoutTests/resources and LayoutTests/http/tests/resources.
(JSTestChecker.check): Update to use KEEP_JS_TEST_FILES_IN_SYNC
as list of lists.  Update for ALL_JS_TEST_FUNCTION_FILES rename.
(JSTestChecker.check_js_test_files): Add 'file_group' argument
for list of files to check instead of using
KEEP_JS_TEST_FILES_IN_SYNC.
(JSTestChecker.check_js_test_functions): Update for
ALL_JS_TEST_FUNCTION_FILES rename.

* Scripts/webkitpy/style/checkers/jstest_unittest.py:
(JSTestCheckerTestCase):
(JSTestCheckerTestCase.test_map_functions_to_dict):
- Add test case for map_functions_to_dict() in jstest.py.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (216109 => 216110)


--- trunk/Tools/ChangeLog	2017-05-03 02:48:49 UTC (rev 216109)
+++ trunk/Tools/ChangeLog	2017-05-03 03:59:24 UTC (rev 216110)
@@ -1,3 +1,37 @@
+2017-05-02  David Kilzer  <[email protected]>
+
+        check-webkit-style should also keep js-test-post[-async].js in sync
+        <https://webkit.org/b/171568>
+
+        Reviewed by Joseph Pecoraro.
+
+        * Scripts/webkitpy/style/checker.py:
+        (_NEVER_SKIPPED_JS_FILES): Add new list that just contains
+        _javascript_ files not to be skipped.
+        (_NEVER_SKIPPED_FILES): Update to use _NEVER_SKIPPED_JS_FILES.
+        (CheckerDispatcher._create_checker): Update to use
+        _NEVER_SKIPPED_JS_FILES.
+
+        * Scripts/webkitpy/style/checkers/jstest.py:
+        (ALL_JS_TEST_FUNCTION_FILES): Rename from ALL_JS_TEST_FILES.
+        This is the list of files containing functions that need to be
+        kept in sync.
+        (KEEP_JS_TEST_FILES_IN_SYNC): Change to list-of-lists format so
+        we can keep more sets of files in sync between
+        LayoutTests/resources and LayoutTests/http/tests/resources.
+        (JSTestChecker.check): Update to use KEEP_JS_TEST_FILES_IN_SYNC
+        as list of lists.  Update for ALL_JS_TEST_FUNCTION_FILES rename.
+        (JSTestChecker.check_js_test_files): Add 'file_group' argument
+        for list of files to check instead of using
+        KEEP_JS_TEST_FILES_IN_SYNC.
+        (JSTestChecker.check_js_test_functions): Update for
+        ALL_JS_TEST_FUNCTION_FILES rename.
+
+        * Scripts/webkitpy/style/checkers/jstest_unittest.py:
+        (JSTestCheckerTestCase):
+        (JSTestCheckerTestCase.test_map_functions_to_dict):
+        - Add test case for map_functions_to_dict() in jstest.py.
+
 2017-05-02  Aakash Jain  <[email protected]>
 
         ews should indicate in logs when it fails to fetch the attachment

Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (216109 => 216110)


--- trunk/Tools/Scripts/webkitpy/style/checker.py	2017-05-03 02:48:49 UTC (rev 216109)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py	2017-05-03 03:59:24 UTC (rev 216110)
@@ -303,9 +303,14 @@
 #
 # Do not skip these files, even when they appear in
 # _SKIPPED_FILES_WITH_WARNING or _SKIPPED_FILES_WITHOUT_WARNING.
-_NEVER_SKIPPED_FILES = [
+_NEVER_SKIPPED_JS_FILES = [
     'js-test-pre.js',
+    'js-test-post.js',
+    'js-test-post-async.js',
     'standalone-pre.js',
+]
+
+_NEVER_SKIPPED_FILES = _NEVER_SKIPPED_JS_FILES + [
     'TestExpectations',
 ]
 
@@ -628,7 +633,7 @@
             # Do not attempt to check non-Inspector or 3rd-party _javascript_ files as JS.
             if os.path.join('WebInspectorUI', 'UserInterface') in file_path and (not 'External' in file_path):
                 checker = JSChecker(file_path, handle_style_error)
-            elif basename == 'js-test-pre.js' or basename == 'standalone-pre.js':
+            elif basename in _NEVER_SKIPPED_JS_FILES:
                 checker = JSTestChecker(file_path, handle_style_error)
             else:
                 checker = TextChecker(file_path, handle_style_error)

Modified: trunk/Tools/Scripts/webkitpy/style/checkers/jstest.py (216109 => 216110)


--- trunk/Tools/Scripts/webkitpy/style/checkers/jstest.py	2017-05-03 02:48:49 UTC (rev 216109)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/jstest.py	2017-05-03 03:59:24 UTC (rev 216110)
@@ -27,7 +27,7 @@
 
 from webkitpy.common.system.systemhost import SystemHost
 
-ALL_JS_TEST_FILES = [
+ALL_JS_TEST_FUNCTION_FILES = [
     'JSTests/stress/resources/standalone-pre.js',
     'LayoutTests/http/tests/resources/js-test-pre.js',
     'LayoutTests/resources/js-test-pre.js',
@@ -36,8 +36,12 @@
 ]
 
 KEEP_JS_TEST_FILES_IN_SYNC = [
-    'LayoutTests/http/tests/resources/js-test-pre.js',
-    'LayoutTests/resources/js-test-pre.js',
+    ['LayoutTests/http/tests/resources/js-test-pre.js',
+     'LayoutTests/resources/js-test-pre.js'],
+    ['LayoutTests/http/tests/resources/js-test-post.js',
+     'LayoutTests/resources/js-test-post.js'],
+    ['LayoutTests/http/tests/resources/js-test-post-async.js',
+     'LayoutTests/resources/js-test-post-async.js'],
 ]
 
 KEEP_JS_TEST_FUNCTIONS_IN_SYNC = [
@@ -92,21 +96,19 @@
 
     def check(self, lines):
         """Run all the checks."""
-        if self._file_path not in ALL_JS_TEST_FILES:
-            return
+        for file_group in KEEP_JS_TEST_FILES_IN_SYNC:
+            if self._file_path in file_group:
+                self.check_js_test_files(file_group)
 
-        if self._file_path in KEEP_JS_TEST_FILES_IN_SYNC:
-            self.check_js_test_files()
-
-        if self._file_path in ALL_JS_TEST_FILES:
+        if self._file_path in ALL_JS_TEST_FUNCTION_FILES:
             self.check_js_test_functions()
 
-    def check_js_test_files(self):
-        """Test that files in KEEP_JS_TEST_FILES_IN_SYNC are identical."""
+    def check_js_test_files(self, file_group):
+        """Test that files in 'file_group' are identical."""
         with self._fs.open_binary_file_for_reading(self._file_path) as file_handle:
             baseline_content = file_handle.read()
 
-        other_files = KEEP_JS_TEST_FILES_IN_SYNC
+        other_files = file_group
         other_files.remove(self._file_path)
 
         for path in other_files:
@@ -122,7 +124,7 @@
             baseline_content = file_handle.read()
         baseline_function_map = map_functions_to_dict(baseline_content)
 
-        other_files = ALL_JS_TEST_FILES
+        other_files = ALL_JS_TEST_FUNCTION_FILES
         other_files.remove(self._file_path)
 
         for path in other_files:

Added: trunk/Tools/Scripts/webkitpy/style/checkers/jstest_unittest.py (0 => 216110)


--- trunk/Tools/Scripts/webkitpy/style/checkers/jstest_unittest.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/jstest_unittest.py	2017-05-03 03:59:24 UTC (rev 216110)
@@ -0,0 +1,66 @@
+# Copyright (C) 2017 Apple Inc. All rights reserved.
+#
+# Redistribution and use in source and binary forms, with or without
+# modification, are permitted provided that the following conditions
+# are met:
+# 1.  Redistributions of source code must retain the above copyright
+#     notice, this list of conditions and the following disclaimer.
+# 2.  Redistributions in binary form must reproduce the above copyright
+#     notice, this list of conditions and the following disclaimer in the
+#     documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Unit test for jstest.py."""
+
+import unittest
+
+from jstest import map_functions_to_dict
+
+
+class JSTestCheckerTestCase(unittest.TestCase):
+    """TestCase for jstest.py"""
+
+    def test_map_functions_to_dict(self):
+        """Tests map_functions_to_dict().
+
+        This also implicitly tests strip_trailing_blank_lines_and_comments().
+        """
+        file1 = """
+function shouldBe() {}
+
+// Same as !shouldBe(), but output makes more sense.
+function shouldNotBe() {}
+
+function shouldNotThrow() {
+    return;
+}
+
+// See also shouldNotThrow().
+function shouldThrow() {
+}
+
+"""
+        result1 = map_functions_to_dict(file1)
+
+        file2 = """function shouldBe() {}
+function shouldNotBe() {}
+function shouldThrow() {
+}
+function shouldNotThrow() {
+    return;
+}
+"""
+        result2 = map_functions_to_dict(file2)
+
+        self.assertDictEqual(result1, result2)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to