<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[172521] trunk/Tools</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/172521">172521</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2014-08-13 07:31:27 -0700 (Wed, 13 Aug 2014)</dd>
</dl>

<h3>Log Message</h3>
<pre>Make check-webkit-style run sort-export-file
https://bugs.webkit.org/show_bug.cgi?id=135877

Patch by Renato Nagy &lt;nagy.renato@stud.u-szeged.hu&gt; on 2014-08-13
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):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkToolsChangeLog">trunk/Tools/ChangeLog</a></li>
<li><a href="#trunkToolsScriptswebkitpystylecheckerpy">trunk/Tools/Scripts/webkitpy/style/checker.py</a></li>
</ul>

<h3>Added Paths</h3>
<ul>
<li><a href="#trunkToolsScriptswebkitpystylecheckersexportfilepy">trunk/Tools/Scripts/webkitpy/style/checkers/exportfile.py</a></li>
<li><a href="#trunkToolsScriptswebkitpystylecheckersexportfile_unittestpy">trunk/Tools/Scripts/webkitpy/style/checkers/exportfile_unittest.py</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkToolsChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Tools/ChangeLog (172520 => 172521)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Tools/ChangeLog        2014-08-13 13:12:57 UTC (rev 172520)
+++ trunk/Tools/ChangeLog        2014-08-13 14:31:27 UTC (rev 172521)
</span><span class="lines">@@ -1,3 +1,32 @@
</span><ins>+2014-08-13  Renato Nagy  &lt;nagy.renato@stud.u-szeged.hu&gt;
+
+        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):
+
</ins><span class="cx"> 2014-08-13  Jinwoo Song  &lt;jinwoo7.song@samsung.com&gt;
</span><span class="cx"> 
</span><span class="cx">         [EFL] Sets the persistent storage for cookies in MiniBrowser
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckerpy"></a>
<div class="modfile"><h4>Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (172520 => 172521)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -47,6 +47,7 @@
</span><span class="cx"> from checkers.jsonchecker import JSONContributorsChecker
</span><span class="cx"> from checkers.messagesin import MessagesInChecker
</span><span class="cx"> from checkers.png import PNGChecker
</span><ins>+from checkers.exportfile import ExportFileChecker
</ins><span class="cx"> from checkers.python import PythonChecker
</span><span class="cx"> from checkers.test_expectations import TestExpectationsChecker
</span><span class="cx"> from checkers.text import TextChecker
</span><span class="lines">@@ -306,6 +307,12 @@
</span><span class="cx"> 
</span><span class="cx"> _PNG_FILE_EXTENSION = 'png'
</span><span class="cx"> 
</span><ins>+_EXPORT_FILE_PATH = [
+    'Source/WebCore/WebCore.exp.in',
+    'Source/WebKit/mac/WebKit.exp',
+    'Source/WebKit/mac/WebKit.mac.exp',
+    ]
+
</ins><span class="cx"> _CMAKE_FILE_EXTENSION = 'cmake'
</span><span class="cx"> 
</span><span class="cx"> # Files to skip that are less obvious.
</span><span class="lines">@@ -356,6 +363,7 @@
</span><span class="cx">     categories = categories.union(ChangeLogChecker.categories)
</span><span class="cx">     categories = categories.union(PNGChecker.categories)
</span><span class="cx">     categories = categories.union(FeatureDefinesChecker.categories)
</span><ins>+    categories = categories.union(ExportFileChecker.categories)
</ins><span class="cx"> 
</span><span class="cx">     # FIXME: Consider adding all of the pep8 categories.  Since they
</span><span class="cx">     #        are not too meaningful for documentation purposes, for
</span><span class="lines">@@ -506,6 +514,7 @@
</span><span class="cx">     XCODEPROJ = 10
</span><span class="cx">     CMAKE = 11
</span><span class="cx">     FEATUREDEFINES = 12
</span><ins>+    EXPORTFILE = 13
</ins><span class="cx"> 
</span><span class="cx"> class CheckerDispatcher(object):
</span><span class="cx"> 
</span><span class="lines">@@ -585,6 +594,8 @@
</span><span class="cx">             return FileType.XCODEPROJ
</span><span class="cx">         elif file_extension == _PNG_FILE_EXTENSION:
</span><span class="cx">             return FileType.PNG
</span><ins>+        elif file_path in _EXPORT_FILE_PATH:
+            return FileType.EXPORTFILE
</ins><span class="cx">         elif ((file_extension == _CMAKE_FILE_EXTENSION) or os.path.basename(file_path) == 'CMakeLists.txt'):
</span><span class="cx">             return FileType.CMAKE
</span><span class="cx">         elif ((not file_extension and os.path.join(&quot;Tools&quot;, &quot;Scripts&quot;) in file_path) or
</span><span class="lines">@@ -629,6 +640,8 @@
</span><span class="cx">             checker = XcodeProjectFileChecker(file_path, handle_style_error)
</span><span class="cx">         elif file_type == FileType.PNG:
</span><span class="cx">             checker = PNGChecker(file_path, handle_style_error)
</span><ins>+        elif file_type == FileType.EXPORTFILE:
+            checker = ExportFileChecker(file_path, handle_style_error)
</ins><span class="cx">         elif file_type == FileType.CMAKE:
</span><span class="cx">             checker = CMakeChecker(file_path, handle_style_error)
</span><span class="cx">         elif file_type == FileType.TEXT:
</span></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckersexportfilepy"></a>
<div class="addfile"><h4>Added: trunk/Tools/Scripts/webkitpy/style/checkers/exportfile.py (0 => 172521)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,52 @@
</span><ins>+# 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
+# &quot;AS IS&quot; 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.
+
+&quot;&quot;&quot;Call Tools/Scripts/sort-export-file with --dry-run for checking style&quot;&quot;&quot;
+
+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([&quot;Tools/Scripts/sort-export-file&quot;, self._file_path, &quot;--verbose&quot;, &quot;--dry-run&quot;], stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+        if retcode == 1:
+            self._handle_style_error(0, 'list/order', 5, &quot;Parse error during processing %s, use Tools/Scripts/sort-export-files for details&quot; % self._file_path)
+        elif retcode == 2:
+            self._handle_style_error(0, 'list/order', 5, &quot;%s should be sorted, use Tools/Scripts/sort-export-file script&quot; % self._file_path)
+        elif retcode != 0:
+            self._handle_style_error(0, 'list/order', 5, &quot;Unexpected error during processing %s, please file a bug report against Tools/Scripts/sort-export-file&quot; % self._file_path)
</ins></span></pre></div>
<a id="trunkToolsScriptswebkitpystylecheckersexportfile_unittestpy"></a>
<div class="addfile"><h4>Added: trunk/Tools/Scripts/webkitpy/style/checkers/exportfile_unittest.py (0 => 172521)</h4>
<pre class="diff"><span>
<span class="info">--- 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)
</span><span class="lines">@@ -0,0 +1,115 @@
</span><ins>+# 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
+# &quot;AS IS&quot; 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&quot;&quot;&quot;.objc_class_name_WebTextIterator
+.objc_class_name_WebUserContentURLPattern
+.objc_class_name_WebView
+_WebActionButtonKey
+_WebActionElementKey
+_WebActionFormKey
+&quot;&quot;&quot;
+
+_non_sorted_file_contents = u&quot;&quot;&quot;.objc_class_name_WebTextIterator
+.objc_class_name_WebUserContentURLPattern
+_WebActionElementKey
+.objc_class_name_WebView
+_WebActionButtonKey
+_WebActionFormKey
+&quot;&quot;&quot;
+
+_parse_error_file_contents = u&quot;&quot;&quot;.objc_class_name_WebTextIterator.objc_class_name_WebUserContentURLPattern_WebActionElementKey&quot;&quot;&quot;
+
+
+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=&quot;exportfiles&quot;))
+        self._old_cwd = self._filesystem.getcwd()
+        self._filesystem.chdir(self._temp_dir)
+        self._filesystem.write_text_file(os.path.join(self._temp_dir, &quot;sorted_file.exp.in&quot;), _sorted_file_contents)
+        self._filesystem.write_text_file(os.path.join(self._temp_dir, &quot;non_sorted_file.exp.in&quot;), _non_sorted_file_contents)
+        self._filesystem.write_text_file(os.path.join(self._temp_dir, &quot;parse_error_file.exp.in&quot;), _parse_error_file_contents)
+
+    def tearDown(self):
+        self._filesystem.rmtree(self._temp_dir)
+        self._filesystem.chdir(self._old_cwd)
+
+    def test_sorted(self):
+        &quot;&quot;&quot; Test sorted file. &quot;&quot;&quot;
+
+        file_path = os.path.join(self._temp_dir, &quot;sorted_file.exp.in&quot;)
+        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):
+        &quot;&quot;&quot; Test non sorted file. &quot;&quot;&quot;
+
+        file_path = os.path.join(self._temp_dir, &quot;non_sorted_file.exp.in&quot;)
+        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 + &quot; should be sorted, use Tools/Scripts/sort-export-file script&quot;))
+
+    def test_parse_error(self):
+        &quot;&quot;&quot; Test parse error file. &quot;&quot;&quot;
+
+        file_path = os.path.join(self._temp_dir, &quot;parse_error_file.exp.in&quot;)
+        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, &quot;Parse error during processing &quot; + file_path + &quot;, use Tools/Scripts/sort-export-files for details&quot;))
</ins></span></pre>
</div>
</div>

</body>
</html>