Diff
Modified: trunk/Tools/ChangeLog (172520 => 172521)
--- trunk/Tools/ChangeLog 2014-08-13 13:12:57 UTC (rev 172520)
+++ trunk/Tools/ChangeLog 2014-08-13 14:31:27 UTC (rev 172521)
@@ -1,3 +1,32 @@
+2014-08-13 Renato Nagy <nagy.ren...@stud.u-szeged.hu>
+
+ Make check-webkit-style run sort-export-file
+ https://bugs.webkit.org/show_bug.cgi?id=135877
+
+ Reviewed by Csaba Osztrogonác.
+
+ * Scripts/webkitpy/style/checker.py:
+ (_all_categories):
+ (FileType):
+ (CheckerDispatcher._file_type):
+ (CheckerDispatcher._create_checker):
+ * Scripts/webkitpy/style/checkers/exportfile.py: Added.
+ (ExportFileChecker):
+ (ExportFileChecker.__init__):
+ (ExportFileChecker.check):
+ * Scripts/webkitpy/style/checkers/exportfile_unittest.py: Added.
+ (handle_style_error):
+ (MockErrorHandler):
+ (MockErrorHandler.__init__):
+ (MockErrorHandler.turn_off_line_filtering):
+ (MockErrorHandler.__call__):
+ (ExportFileTest):
+ (ExportFileTest.setUp):
+ (ExportFileTest.tearDown):
+ (ExportFileTest.test_sorted):
+ (ExportFileTest.test_non_sorted):
+ (ExportFileTest.test_parse_error):
+
2014-08-13 Jinwoo Song <jinwoo7.s...@samsung.com>
[EFL] Sets the persistent storage for cookies in MiniBrowser
Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (172520 => 172521)
--- trunk/Tools/Scripts/webkitpy/style/checker.py 2014-08-13 13:12:57 UTC (rev 172520)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py 2014-08-13 14:31:27 UTC (rev 172521)
@@ -47,6 +47,7 @@
from checkers.jsonchecker import JSONContributorsChecker
from checkers.messagesin import MessagesInChecker
from checkers.png import PNGChecker
+from checkers.exportfile import ExportFileChecker
from checkers.python import PythonChecker
from checkers.test_expectations import TestExpectationsChecker
from checkers.text import TextChecker
@@ -306,6 +307,12 @@
_PNG_FILE_EXTENSION = 'png'
+_EXPORT_FILE_PATH = [
+ 'Source/WebCore/WebCore.exp.in',
+ 'Source/WebKit/mac/WebKit.exp',
+ 'Source/WebKit/mac/WebKit.mac.exp',
+ ]
+
_CMAKE_FILE_EXTENSION = 'cmake'
# Files to skip that are less obvious.
@@ -356,6 +363,7 @@
categories = categories.union(ChangeLogChecker.categories)
categories = categories.union(PNGChecker.categories)
categories = categories.union(FeatureDefinesChecker.categories)
+ categories = categories.union(ExportFileChecker.categories)
# FIXME: Consider adding all of the pep8 categories. Since they
# are not too meaningful for documentation purposes, for
@@ -506,6 +514,7 @@
XCODEPROJ = 10
CMAKE = 11
FEATUREDEFINES = 12
+ EXPORTFILE = 13
class CheckerDispatcher(object):
@@ -585,6 +594,8 @@
return FileType.XCODEPROJ
elif file_extension == _PNG_FILE_EXTENSION:
return FileType.PNG
+ elif file_path in _EXPORT_FILE_PATH:
+ return FileType.EXPORTFILE
elif ((file_extension == _CMAKE_FILE_EXTENSION) or os.path.basename(file_path) == 'CMakeLists.txt'):
return FileType.CMAKE
elif ((not file_extension and os.path.join("Tools", "Scripts") in file_path) or
@@ -629,6 +640,8 @@
checker = XcodeProjectFileChecker(file_path, handle_style_error)
elif file_type == FileType.PNG:
checker = PNGChecker(file_path, handle_style_error)
+ elif file_type == FileType.EXPORTFILE:
+ checker = ExportFileChecker(file_path, handle_style_error)
elif file_type == FileType.CMAKE:
checker = CMakeChecker(file_path, handle_style_error)
elif file_type == FileType.TEXT:
Added: trunk/Tools/Scripts/webkitpy/style/checkers/exportfile.py (0 => 172521)
--- trunk/Tools/Scripts/webkitpy/style/checkers/exportfile.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/exportfile.py 2014-08-13 14:31:27 UTC (rev 172521)
@@ -0,0 +1,52 @@
+# Copyright (C) 2014 University of Szeged
+#
+# 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.
+
+"""Call Tools/Scripts/sort-export-file with --dry-run for checking style"""
+
+import os
+import subprocess
+import os.path
+from webkitpy.common.system.filesystem import FileSystem
+from webkitpy.common.webkit_finder import WebKitFinder
+
+
+class ExportFileChecker(object):
+
+ categories = set(['list/order'])
+
+ def __init__(self, file_path, handle_style_error):
+ self._filesystem = FileSystem()
+ self._webkit_base = WebKitFinder(self._filesystem).webkit_base()
+ self._file_path = file_path
+ self._handle_style_error = handle_style_error
+ self._handle_style_error.turn_off_line_filtering()
+
+ def check(self, inline=None):
+ os.chdir(self._webkit_base)
+ retcode = subprocess.call(["Tools/Scripts/sort-export-file", self._file_path, "--verbose", "--dry-run"], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ if retcode == 1:
+ self._handle_style_error(0, 'list/order', 5, "Parse error during processing %s, use Tools/Scripts/sort-export-files for details" % self._file_path)
+ elif retcode == 2:
+ self._handle_style_error(0, 'list/order', 5, "%s should be sorted, use Tools/Scripts/sort-export-file script" % self._file_path)
+ elif retcode != 0:
+ self._handle_style_error(0, 'list/order', 5, "Unexpected error during processing %s, please file a bug report against Tools/Scripts/sort-export-file" % self._file_path)
Added: trunk/Tools/Scripts/webkitpy/style/checkers/exportfile_unittest.py (0 => 172521)
--- trunk/Tools/Scripts/webkitpy/style/checkers/exportfile_unittest.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/exportfile_unittest.py 2014-08-13 14:31:27 UTC (rev 172521)
@@ -0,0 +1,115 @@
+# Copyright (C) 2014 University of Szeged
+#
+# 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.
+
+import os
+import unittest2 as unittest
+from webkitpy.style.checkers.exportfile import ExportFileChecker
+from webkitpy.common.system.filesystem import FileSystem
+
+_sorted_file_contents = u""".objc_class_name_WebTextIterator
+.objc_class_name_WebUserContentURLPattern
+.objc_class_name_WebView
+_WebActionButtonKey
+_WebActionElementKey
+_WebActionFormKey
+"""
+
+_non_sorted_file_contents = u""".objc_class_name_WebTextIterator
+.objc_class_name_WebUserContentURLPattern
+_WebActionElementKey
+.objc_class_name_WebView
+_WebActionButtonKey
+_WebActionFormKey
+"""
+
+_parse_error_file_contents = u""".objc_class_name_WebTextIterator.objc_class_name_WebUserContentURLPattern_WebActionElementKey"""
+
+
+def handle_style_error(mock_error_handler, line_number, category, confidence, message):
+ mock_error_handler.had_error = True
+ error = (line_number, category, confidence, message)
+ mock_error_handler.errors.append(error)
+
+
+class MockErrorHandler(object):
+ def __init__(self, handle_style_error):
+ self.turned_off_filtering = False
+ self._handle_style_error = handle_style_error
+
+ def turn_off_line_filtering(self):
+ self.turned_off_filtering = True
+
+ def __call__(self, line_number, category, confidence, message):
+ self._handle_style_error(self, line_number, category, confidence, message)
+ return True
+
+
+class ExportFileTest(unittest.TestCase):
+
+ def setUp(self):
+ self._filesystem = FileSystem()
+ self._temp_dir = str(self._filesystem.mkdtemp(suffix="exportfiles"))
+ self._old_cwd = self._filesystem.getcwd()
+ self._filesystem.chdir(self._temp_dir)
+ self._filesystem.write_text_file(os.path.join(self._temp_dir, "sorted_file.exp.in"), _sorted_file_contents)
+ self._filesystem.write_text_file(os.path.join(self._temp_dir, "non_sorted_file.exp.in"), _non_sorted_file_contents)
+ self._filesystem.write_text_file(os.path.join(self._temp_dir, "parse_error_file.exp.in"), _parse_error_file_contents)
+
+ def tearDown(self):
+ self._filesystem.rmtree(self._temp_dir)
+ self._filesystem.chdir(self._old_cwd)
+
+ def test_sorted(self):
+ """ Test sorted file. """
+
+ file_path = os.path.join(self._temp_dir, "sorted_file.exp.in")
+ error_handler = MockErrorHandler(handle_style_error)
+ error_handler.errors = []
+ error_handler.had_error = False
+ checker = ExportFileChecker(file_path, error_handler)
+ checker.check()
+ self.assertFalse(error_handler.had_error)
+
+ def test_non_sorted(self):
+ """ Test non sorted file. """
+
+ file_path = os.path.join(self._temp_dir, "non_sorted_file.exp.in")
+ error_handler = MockErrorHandler(handle_style_error)
+ error_handler.errors = []
+ error_handler.had_error = False
+ checker = ExportFileChecker(file_path, error_handler)
+ checker.check()
+ self.assertTrue(error_handler.had_error)
+ self.assertEqual(error_handler.errors[0], (0, 'list/order', 5, file_path + " should be sorted, use Tools/Scripts/sort-export-file script"))
+
+ def test_parse_error(self):
+ """ Test parse error file. """
+
+ file_path = os.path.join(self._temp_dir, "parse_error_file.exp.in")
+ error_handler = MockErrorHandler(handle_style_error)
+ error_handler.errors = []
+ error_handler.had_error = False
+ checker = ExportFileChecker(file_path, error_handler)
+ checker.check()
+ self.assertTrue(error_handler.had_error)
+ self.assertEqual(error_handler.errors[0], (0, 'list/order', 5, "Parse error during processing " + file_path + ", use Tools/Scripts/sort-export-files for details"))