summaryrefslogtreecommitdiffstats
path: root/WebKitTools/Scripts/webkitpy
diff options
context:
space:
mode:
Diffstat (limited to 'WebKitTools/Scripts/webkitpy')
-rw-r--r--WebKitTools/Scripts/webkitpy/committers.py6
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py6
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py6
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream.py4
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py6
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py4
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_files.py6
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py6
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/port/__init__.py (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils.py)12
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/port/apache_http_server.py (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/apache_http_server.py)10
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_linux.py)10
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_mac.py)6
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_win.py)8
-rwxr-xr-xWebKitTools/Scripts/webkitpy/layout_tests/port/http_server.py (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/http_server.py)4
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/port/http_server_base.py (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/http_server_base.py)4
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/port/httpd2.pem (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/httpd2.pem)0
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/port/lighttpd.conf (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/lighttpd.conf)0
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/port/path_utils.py (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/path_utils.py)64
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py (renamed from WebKitTools/Scripts/webkitpy/layout_tests/layout_package/websocket_server.py)8
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py6
-rwxr-xr-xWebKitTools/Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py18
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py6
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py6
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py6
-rw-r--r--WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py6
-rw-r--r--WebKitTools/Scripts/webkitpy/style/checker.py168
-rwxr-xr-xWebKitTools/Scripts/webkitpy/style/checker_unittest.py80
-rw-r--r--WebKitTools/Scripts/webkitpy/style/error_handlers.py44
-rw-r--r--WebKitTools/Scripts/webkitpy/style/error_handlers_unittest.py62
-rw-r--r--WebKitTools/Scripts/webkitpy/style/filter.py97
-rw-r--r--WebKitTools/Scripts/webkitpy/style/filter_unittest.py84
-rw-r--r--WebKitTools/Scripts/webkitpy/style/processors/common.py59
-rw-r--r--WebKitTools/Scripts/webkitpy/style/processors/common_unittest.py82
-rw-r--r--WebKitTools/Scripts/webkitpy/style/unittests.py2
34 files changed, 601 insertions, 295 deletions
diff --git a/WebKitTools/Scripts/webkitpy/committers.py b/WebKitTools/Scripts/webkitpy/committers.py
index 73e4172..0efb4e7 100644
--- a/WebKitTools/Scripts/webkitpy/committers.py
+++ b/WebKitTools/Scripts/webkitpy/committers.py
@@ -80,6 +80,8 @@ committers_unable_to_review = [
Committer("Brett Wilson", "brettw@chromium.org"),
Committer("Brian Weinstein", "bweinstein@apple.com"),
Committer("Cameron McCormack", "cam@webkit.org"),
+ Committer("Carol Szabo", "carol.szabo@nokia.com"),
+ Committer("Chang Shu", "chang.shu@nokia.com"),
Committer("Chris Fleizach", "cfleizach@apple.com"),
Committer("Chris Jerdonek", "cjerdonek@webkit.org"),
Committer("Chris Marrin", "cmarrin@apple.com"),
@@ -131,7 +133,7 @@ committers_unable_to_review = [
Committer("Mike Belshe", ["mbelshe@chromium.org", "mike@belshe.com"]),
Committer("Mike Fenton", ["mike.fenton@torchmobile.com", "mifenton@rim.com"]),
Committer("Mike Thole", ["mthole@mikethole.com", "mthole@apple.com"]),
- Committer("Nate Chapin", "japhet@chromium.org"),
+ Committer("Mikhail Naganov", "mnaganov@chromium.org"),
Committer("Ojan Vafai", "ojan@chromium.org"),
Committer("Pam Greene", "pam@chromium.org"),
Committer("Peter Kasting", ["pkasting@google.com", "pkasting@chromium.org"]),
@@ -153,6 +155,7 @@ committers_unable_to_review = [
Committer("Yong Li", ["yong.li@torchmobile.com", "yong.li.webkit@gmail.com"]),
Committer("Yongjun Zhang", "yongjun.zhang@nokia.com"),
Committer("Yury Semikhatsky", "yurys@chromium.org"),
+ Committer("Yuzo Fujishima", "yuzo@google.com"),
Committer("Zoltan Herczeg", "zherczeg@webkit.org"),
Committer("Zoltan Horvath", "zoltan@webkit.org"),
]
@@ -211,6 +214,7 @@ reviewers_list = [
Reviewer("Laszlo Gombos", "laszlo.1.gombos@nokia.com"),
Reviewer("Maciej Stachowiak", "mjs@apple.com"),
Reviewer("Mark Rowe", "mrowe@apple.com"),
+ Reviewer("Nate Chapin", "japhet@chromium.org"),
Reviewer("Nikolas Zimmermann", ["zimmermann@kde.org", "zimmermann@physik.rwth-aachen.de", "zimmermann@webkit.org"]),
Reviewer("Oliver Hunt", "oliver@apple.com"),
Reviewer("Pavel Feldman", "pfeldman@chromium.org"),
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py
index b7b26e9..f38a7ab 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_layout_results_generator.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -31,7 +31,7 @@ import logging
import os
from layout_package import json_results_generator
-from layout_package import path_utils
+from port import path_utils
from layout_package import test_expectations
from layout_package import test_failures
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py
index 596e1e4..dc24ade 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/json_results_generator.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -35,7 +35,7 @@ import time
import urllib2
import xml.dom.minidom
-from layout_package import path_utils
+from port import path_utils
from layout_package import test_expectations
sys.path.append(path_utils.path_from_base('third_party', 'WebKit',
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream.py
index 6c094e3..72b30a1 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/metered_stream.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
index f1647f7..5b0d186 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_expectations.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -36,7 +36,7 @@ import os
import re
import sys
import time
-import path_utils
+from port import path_utils
sys.path.append(path_utils.path_from_base('third_party', 'WebKit',
'WebKitTools'))
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py
index 6957dea..56d7b5a 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_failures.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_files.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_files.py
index 91fe136..b7e620d 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_files.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_files.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -36,7 +36,7 @@ under that directory."""
import glob
import os
-import path_utils
+from port import path_utils
# When collecting test cases, we include any file with these extensions.
_supported_file_extensions = set(['.html', '.shtml', '.xml', '.xhtml', '.pl',
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py
index 10d0509..9f52686 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/test_shell_thread.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -46,7 +46,7 @@ import thread
import threading
import time
-import path_utils
+from port import path_utils
import test_failures
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/__init__.py
index 09e7b4b..1730085 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/__init__.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -30,7 +30,7 @@
"""Platform-specific utilities and pseudo-constants
Any functions whose implementations or values differ from one platform to
-another should be defined in their respective platform_utils_<platform>.py
+another should be defined in their respective <platform>.py
modules. The appropriate one of those will be imported into this module to
provide callers with a common, platform-independent interface.
@@ -43,8 +43,8 @@ import sys
# especially has had problems), but we'll allow the platform utils to be
# included in any case so we don't get an import error.
if sys.platform in ('cygwin', 'win32'):
- from platform_utils_win import *
+ from chromium_win import *
elif sys.platform == 'darwin':
- from platform_utils_mac import *
+ from chromium_mac import *
elif sys.platform in ('linux', 'linux2', 'freebsd7', 'openbsd4'):
- from platform_utils_linux import *
+ from chromium_linux import *
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/apache_http_server.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/apache_http_server.py
index 15f2065..1fb0367 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/apache_http_server.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/apache_http_server.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -38,7 +38,7 @@ import sys
import http_server_base
import path_utils
-import platform_utils
+import port
class LayoutTestApacheHttpd(http_server_base.HttpServerBase):
@@ -78,7 +78,7 @@ class LayoutTestApacheHttpd(http_server_base.HttpServerBase):
error_log = self._cygwin_safe_join(output_dir, "error_log.txt")
document_root = self._cygwin_safe_join(test_dir, "http", "tests")
- executable = platform_utils.apache_executable_path()
+ executable = port.apache_executable_path()
if self._is_cygwin():
executable = self._get_cygwin_path(executable)
@@ -146,7 +146,7 @@ class LayoutTestApacheHttpd(http_server_base.HttpServerBase):
test_dir: absolute path to the LayoutTests directory.
output_dir: absolute path to the layout test results directory.
"""
- httpd_config = platform_utils.apache_config_file_path()
+ httpd_config = port.apache_config_file_path()
httpd_config_copy = os.path.join(output_dir, "httpd.conf")
httpd_conf = open(httpd_config).read()
if self._is_cygwin():
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_linux.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py
index 87b27c7..9ffc401 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_linux.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_linux.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -27,7 +27,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"""This is the Linux implementation of the layout_package.platform_utils
+"""This is the Linux implementation of the port
package. This file should only be imported by that package."""
import os
@@ -36,8 +36,8 @@ import subprocess
import sys
import logging
+import chromium_win
import path_utils
-import platform_utils_win
def platform_name():
@@ -75,7 +75,7 @@ def baseline_search_path(platform=None):
"""Returns the list of directories to search for baselines/results, in
order of preference. Paths are relative to the top of the source tree."""
return [baseline_path(platform),
- platform_utils_win.baseline_path('chromium-win'),
+ chromium_win.baseline_path('chromium-win'),
path_utils.webkit_baseline_path('win'),
path_utils.webkit_baseline_path('mac')]
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_mac.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py
index 1eaa10c..d0fbc01 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_mac.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_mac.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -27,7 +27,7 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"""This is the Mac implementation of the layout_package.platform_utils
+"""This is the Mac implementation of the port interface
package. This file should only be imported by that package."""
import os
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_win.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py
index 3cbbec3..1e0b212 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/platform_utils_win.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/chromium_win.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -27,14 +27,14 @@
# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-"""This is the Linux implementation of the layout_package.platform_utils
+"""This is the Linux implementation of the port
package. This file should only be imported by that package."""
import os
-import path_utils
import subprocess
import sys
+import path_utils
def platform_name():
"""Returns the name of the platform we're currently running on."""
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/http_server.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/http_server.py
index dfcb44f..99e2ea1 100755
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/http_server.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/http_server.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/http_server_base.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/http_server_base.py
index 2720486..026e070 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/http_server_base.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/http_server_base.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/httpd2.pem b/WebKitTools/Scripts/webkitpy/layout_tests/port/httpd2.pem
index 6349b78..6349b78 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/httpd2.pem
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/httpd2.pem
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/lighttpd.conf b/WebKitTools/Scripts/webkitpy/layout_tests/port/lighttpd.conf
index d3150dd..d3150dd 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/lighttpd.conf
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/lighttpd.conf
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/path_utils.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/path_utils.py
index 26d062b..70b8c03 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/path_utils.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/path_utils.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -29,9 +29,9 @@
"""This package contains utility methods for manipulating paths and
filenames for test results and baselines. It also contains wrappers
-of a few routines in platform_utils.py so that platform_utils.py can
+of a few routines in port/ so that the port package can
be considered a 'protected' package - i.e., this file should be
-the only file that ever includes platform_utils. This leads to
+the only file that ever includes port. This leads to
us including a few things that don't really have anything to do
with paths, unfortunately."""
@@ -40,10 +40,10 @@ import os
import stat
import sys
-import platform_utils
-import platform_utils_win
-import platform_utils_mac
-import platform_utils_linux
+import port
+import chromium_win
+import chromium_mac
+import chromium_linux
# Cache some values so we don't have to recalculate them. _basedir is
# used by PathFromBase() and caches the full (native) path to the top
@@ -69,20 +69,20 @@ def chromium_baseline_path(platform=None):
baseline results from chromium ports. If |platform| is None, the
currently executing platform is used.
- Note: although directly referencing individual platform_utils_* files is
+ Note: although directly referencing individual port/* files is
usually discouraged, we allow it here so that the rebaselining tool can
pull baselines for platforms other than the host platform."""
# Normalize the platform string.
platform = platform_name(platform)
if platform.startswith('chromium-mac'):
- return platform_utils_mac.baseline_path(platform)
+ return chromium_mac.baseline_path(platform)
elif platform.startswith('chromium-win'):
- return platform_utils_win.baseline_path(platform)
+ return chromium_win.baseline_path(platform)
elif platform.startswith('chromium-linux'):
- return platform_utils_linux.baseline_path(platform)
+ return chromium_linux.baseline_path(platform)
- return platform_utils.baseline_path()
+ return port.baseline_path()
def webkit_baseline_path(platform):
@@ -98,19 +98,19 @@ def baseline_search_path(platform=None):
the source tree. If parameter platform is None, returns the list for the
current platform that the script is running on.
- Note: although directly referencing individual platform_utils_* files is
+ Note: although directly referencing individual port/* files is
usually discouraged, we allow it here so that the rebaselining tool can
pull baselines for platforms other than the host platform."""
# Normalize the platform name.
platform = platform_name(platform)
if platform.startswith('chromium-mac'):
- return platform_utils_mac.baseline_search_path(platform)
+ return chromium_mac.baseline_search_path(platform)
elif platform.startswith('chromium-win'):
- return platform_utils_win.baseline_search_path(platform)
+ return chromium_win.baseline_search_path(platform)
elif platform.startswith('chromium-linux'):
- return platform_utils_linux.baseline_search_path(platform)
- return platform_utils.baseline_search_path()
+ return chromium_linux.baseline_search_path(platform)
+ return port.baseline_search_path()
def expected_baselines(filename, suffix, platform=None, all_baselines=False):
@@ -200,7 +200,7 @@ def _win_path_to_unix(path):
#
# Routines that are arguably platform-specific but have been made
-# generic for now (they used to be in platform_utils_*)
+# generic for now
#
@@ -335,7 +335,7 @@ def remove_directory(*path):
remove_with_retry(os.rmdir, file_path)
#
-# Wrappers around platform_utils
+# Wrappers around port/
#
@@ -345,51 +345,51 @@ def platform_name(platform=None):
currently running system. If |platform| is of the form 'chromium-*',
it is returned unchanged, otherwise 'chromium-' is prepended."""
if platform == None:
- return platform_utils.platform_name()
+ return port.platform_name()
if not platform.startswith('chromium-'):
platform = "chromium-" + platform
return platform
def platform_version():
- return platform_utils.platform_version()
+ return port.platform_version()
def lighttpd_executable_path():
- return platform_utils.lighttpd_executable_path()
+ return port.lighttpd_executable_path()
def lighttpd_module_path():
- return platform_utils.lighttpd_module_path()
+ return port.lighttpd_module_path()
def lighttpd_php_path():
- return platform_utils.lighttpd_php_path()
+ return port.lighttpd_php_path()
def wdiff_path():
- return platform_utils.wdiff_path()
+ return port.wdiff_path()
def test_shell_path(target):
- return platform_utils.test_shell_path(target)
+ return port.test_shell_path(target)
def image_diff_path(target):
- return platform_utils.image_diff_path(target)
+ return port.image_diff_path(target)
def layout_test_helper_path(target):
- return platform_utils.layout_test_helper_path(target)
+ return port.layout_test_helper_path(target)
def fuzzy_match_path():
- return platform_utils.fuzzy_match_path()
+ return port.fuzzy_match_path()
def shut_down_http_server(server_pid):
- return platform_utils.shut_down_http_server(server_pid)
+ return port.shut_down_http_server(server_pid)
def kill_all_test_shells():
- platform_utils.kill_all_test_shells()
+ port.kill_all_test_shells()
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/websocket_server.py b/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py
index 7fc47a0..c6c7527 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/layout_package/websocket_server.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/port/websocket_server.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -40,7 +40,7 @@ import time
import urllib
import path_utils
-import platform_utils
+import port
import http_server
_WS_LOG_PREFIX = 'pywebsocket.ws.log-'
@@ -255,7 +255,7 @@ class PyWebSocket(http_server.Lighttpd):
'Failed to find %s server pid.' % self._server_name)
logging.debug('Shutting down %s server %d.' % (self._server_name, pid))
- platform_utils.kill_process(pid)
+ port.kill_process(pid)
if self._process:
self._process.wait()
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py b/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py
index 1db811f..414baaf 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/rebaseline_chromium_webkit_tests.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -54,7 +54,7 @@ import urllib
import webbrowser
import zipfile
-from layout_package import path_utils
+from port import path_utils
from layout_package import test_expectations
from test_types import image_diff
from test_types import text_diff
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py b/WebKitTools/Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py
index 88b97f8..571ae3f 100755
--- a/WebKitTools/Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/run_chromium_webkit_tests.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -59,17 +59,19 @@ import sys
import time
import traceback
-from layout_package import apache_http_server
from layout_package import test_expectations
-from layout_package import http_server
from layout_package import json_layout_results_generator
from layout_package import metered_stream
-from layout_package import path_utils
-from layout_package import platform_utils
from layout_package import test_failures
from layout_package import test_shell_thread
from layout_package import test_files
-from layout_package import websocket_server
+
+import port
+from port import apache_http_server
+from port import http_server
+from port import path_utils
+from port import websocket_server
+
from test_types import fuzzy_image_diff
from test_types import image_diff
from test_types import test_type_base
@@ -1469,7 +1471,7 @@ def main(options, args):
if not options.num_test_shells:
# TODO(ojan): Investigate perf/flakiness impact of using numcores + 1.
- options.num_test_shells = platform_utils.get_num_cores()
+ options.num_test_shells = port.get_num_cores()
write = create_logging_writer(options, 'config')
write("Running %s test_shells in parallel" % options.num_test_shells)
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py
index 134b507..100fd0d 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/fuzzy_image_diff.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -37,7 +37,7 @@ import os
import shutil
import subprocess
-from layout_package import path_utils
+from port import path_utils
from layout_package import test_failures
from test_types import test_type_base
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
index b0bf189..86b9659 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/image_diff.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -40,7 +40,7 @@ import os
import shutil
import subprocess
-from layout_package import path_utils
+from port import path_utils
from layout_package import test_failures
from test_types import test_type_base
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py
index 334ae70..79b7e34 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/test_type_base.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -39,7 +39,7 @@ import logging
import os.path
import subprocess
-from layout_package import path_utils
+from port import path_utils
class TestArguments(object):
diff --git a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py
index 8cff9e6..3c895af 100644
--- a/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py
+++ b/WebKitTools/Scripts/webkitpy/layout_tests/test_types/text_diff.py
@@ -1,5 +1,5 @@
#!/usr/bin/env python
-# Copyright (C) 2010 The Chromium Authors. All rights reserved.
+# Copyright (C) 2010 Google Inc. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are
@@ -11,7 +11,7 @@
# copyright notice, this list of conditions and the following disclaimer
# in the documentation and/or other materials provided with the
# distribution.
-# * Neither the Chromium name nor the names of its
+# * Neither the name of Google Inc. nor the names of its
# contributors may be used to endorse or promote products derived from
# this software without specific prior written permission.
#
@@ -37,7 +37,7 @@ import errno
import logging
import os.path
-from layout_package import path_utils
+from port import path_utils
from layout_package import test_failures
from test_types import test_type_base
diff --git a/WebKitTools/Scripts/webkitpy/style/checker.py b/WebKitTools/Scripts/webkitpy/style/checker.py
index faf954f..dc14ea3 100644
--- a/WebKitTools/Scripts/webkitpy/style/checker.py
+++ b/WebKitTools/Scripts/webkitpy/style/checker.py
@@ -37,6 +37,9 @@ import sys
from .. style_references import parse_patch
from error_handlers import DefaultStyleErrorHandler
from error_handlers import PatchStyleErrorHandler
+from filter import CategoryFilter
+from processors.common import check_no_carriage_return
+from processors.common import categories as CommonCategories
from processors.cpp import CppProcessor
from processors.text import TextProcessor
@@ -106,10 +109,17 @@ SKIPPED_FILES_WITHOUT_WARNING = [
]
+# The maximum number of errors to report per file, per category.
+# If a category is not a key, then it has no maximum.
+MAX_REPORTS_PER_CATEGORY = {
+ "whitespace/carriage_return": 1
+}
+
+
def style_categories():
"""Return the set of all categories used by check-webkit-style."""
- # If other processors had categories, we would take their union here.
- return CppProcessor.categories
+ # Take the union across all processors.
+ return CommonCategories.union(CppProcessor.categories)
def webkit_argument_defaults():
@@ -191,79 +201,6 @@ Syntax: %(program_name)s [--verbose=#] [--git-commit=<SingleCommit>] [--output=v
return usage
-class CategoryFilter(object):
-
- """Filters whether to check style categories."""
-
- def __init__(self, filter_rules=None):
- """Create a category filter.
-
- This method performs argument validation but does not strip
- leading or trailing white space.
-
- Args:
- filter_rules: A list of strings that are filter rules, which
- are strings beginning with the plus or minus
- symbol (+/-). The list should include any
- default filter rules at the beginning.
- Defaults to the empty list.
-
- Raises:
- ValueError: Invalid filter rule if a rule does not start with
- plus ("+") or minus ("-").
-
- """
- if filter_rules is None:
- filter_rules = []
-
- for rule in filter_rules:
- if not (rule.startswith('+') or rule.startswith('-')):
- raise ValueError('Invalid filter rule "%s": every rule '
- 'rule in the --filter flag must start '
- 'with + or -.' % rule)
-
- self._filter_rules = filter_rules
- self._should_check_category = {} # Cached dictionary of category to True/False
-
- def __str__(self):
- return ",".join(self._filter_rules)
-
- # Useful for unit testing.
- def __eq__(self, other):
- """Return whether this CategoryFilter instance is equal to another."""
- return self._filter_rules == other._filter_rules
-
- # Useful for unit testing.
- def __ne__(self, other):
- # Python does not automatically deduce from __eq__().
- return not (self == other)
-
- def should_check(self, category):
- """Return whether the category should be checked.
-
- The rules for determining whether a category should be checked
- are as follows. By default all categories should be checked.
- Then apply the filter rules in order from first to last, with
- later flags taking precedence.
-
- A filter rule applies to a category if the string after the
- leading plus/minus (+/-) matches the beginning of the category
- name. A plus (+) means the category should be checked, while a
- minus (-) means the category should not be checked.
-
- """
- if category in self._should_check_category:
- return self._should_check_category[category]
-
- should_check = True # All categories checked by default.
- for rule in self._filter_rules:
- if not category.startswith(rule[1:]):
- continue
- should_check = rule.startswith('+')
- self._should_check_category[category] = should_check # Update cache.
- return should_check
-
-
# This class should not have knowledge of the flag key names.
class ProcessorOptions(object):
@@ -290,12 +227,19 @@ class ProcessorOptions(object):
"""
- def __init__(self, output_format="emacs", verbosity=1, filter=None,
- git_commit=None, extra_flag_values=None):
- if filter is None:
- filter = CategoryFilter()
+ def __init__(self,
+ output_format="emacs",
+ verbosity=1,
+ filter=None,
+ max_reports_per_category=None,
+ git_commit=None,
+ extra_flag_values=None):
if extra_flag_values is None:
extra_flag_values = {}
+ if filter is None:
+ filter = CategoryFilter()
+ if max_reports_per_category is None:
+ max_reports_per_category = {}
if output_format not in ("emacs", "vs7"):
raise ValueError('Invalid "output_format" parameter: '
@@ -307,24 +251,27 @@ class ProcessorOptions(object):
"value must be an integer between 1-5 inclusive. "
'Value given: "%s".' % verbosity)
- self.output_format = output_format
- self.verbosity = verbosity
+ self.extra_flag_values = extra_flag_values
self.filter = filter
self.git_commit = git_commit
- self.extra_flag_values = extra_flag_values
+ self.max_reports_per_category = max_reports_per_category
+ self.output_format = output_format
+ self.verbosity = verbosity
# Useful for unit testing.
def __eq__(self, other):
"""Return whether this ProcessorOptions instance is equal to another."""
- if self.output_format != other.output_format:
- return False
- if self.verbosity != other.verbosity:
+ if self.extra_flag_values != other.extra_flag_values:
return False
if self.filter != other.filter:
return False
if self.git_commit != other.git_commit:
return False
- if self.extra_flag_values != other.extra_flag_values:
+ if self.max_reports_per_category != other.max_reports_per_category:
+ return False
+ if self.output_format != other.output_format:
+ return False
+ if self.verbosity != other.verbosity:
return False
return True
@@ -568,8 +515,12 @@ class ArgumentParser(object):
filter = CategoryFilter(filter_rules)
- options = ProcessorOptions(output_format, verbosity, filter,
- git_commit, extra_flag_values)
+ options = ProcessorOptions(extra_flag_values=extra_flag_values,
+ filter=filter,
+ git_commit=git_commit,
+ max_reports_per_category=MAX_REPORTS_PER_CATEGORY,
+ output_format=output_format,
+ verbosity=verbosity)
return (filenames, options)
@@ -720,35 +671,36 @@ class StyleChecker(object):
# '\r\n' as in Windows), a warning is issued below if this file
# is processed.
if file_path == '-':
- lines = codecs.StreamReaderWriter(sys.stdin,
- codecs.getreader('utf8'),
- codecs.getwriter('utf8'),
- 'replace').read().split('\n')
+ file = codecs.StreamReaderWriter(sys.stdin,
+ codecs.getreader('utf8'),
+ codecs.getwriter('utf8'),
+ 'replace')
else:
- lines = codecs.open(file_path, 'r', 'utf8', 'replace').read().split('\n')
+ file = codecs.open(file_path, 'r', 'utf8', 'replace')
- carriage_return_found = False
- # Remove trailing '\r'.
- for line_number in range(len(lines)):
- if lines[line_number].endswith('\r'):
- lines[line_number] = lines[line_number].rstrip('\r')
- carriage_return_found = True
+ contents = file.read()
except IOError:
self._stderr_write("Skipping input '%s': Can't open for reading\n" % file_path)
return
- processor.process(lines)
+ lines = contents.split("\n")
- if carriage_return_found and os.linesep != '\r\n':
- # FIXME: Make sure this error also shows up when checking
- # patches, if appropriate.
+ for line_number in range(len(lines)):
+ # FIXME: We should probably use the SVN "eol-style" property
+ # or a white list to decide whether or not to do
+ # the carriage-return check. Originally, we did the
+ # check only if (os.linesep != '\r\n').
#
- # Use 0 for line_number since outputting only one error for
- # potentially several lines.
- handle_style_error(file_path, 0, 'whitespace/newline', 1,
- 'One or more unexpected \\r (^M) found;'
- 'better to use only a \\n')
+ # FIXME: As a minor optimization, we can have
+ # check_no_carriage_return() return whether
+ # the line ends with "\r".
+ check_no_carriage_return(lines[line_number], line_number,
+ handle_style_error)
+ if lines[line_number].endswith("\r"):
+ lines[line_number] = lines[line_number].rstrip("\r")
+
+ processor.process(lines)
def check_file(self, file_path, handle_style_error=None, process_file=None):
"""Check style in the given file.
diff --git a/WebKitTools/Scripts/webkitpy/style/checker_unittest.py b/WebKitTools/Scripts/webkitpy/style/checker_unittest.py
index 4d6b2e7..814bd41 100755
--- a/WebKitTools/Scripts/webkitpy/style/checker_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/style/checker_unittest.py
@@ -37,67 +37,13 @@
import unittest
import checker as style
-from checker import CategoryFilter
from checker import ProcessorDispatcher
from checker import ProcessorOptions
from checker import StyleChecker
+from filter import CategoryFilter
from processors.cpp import CppProcessor
from processors.text import TextProcessor
-class CategoryFilterTest(unittest.TestCase):
-
- """Tests CategoryFilter class."""
-
- def test_init(self):
- """Test __init__ constructor."""
- self.assertRaises(ValueError, CategoryFilter, ["no_prefix"])
- CategoryFilter() # No ValueError: works
- CategoryFilter(["+"]) # No ValueError: works
- CategoryFilter(["-"]) # No ValueError: works
-
- def test_str(self):
- """Test __str__ "to string" operator."""
- filter = CategoryFilter(["+a", "-b"])
- self.assertEquals(str(filter), "+a,-b")
-
- def test_eq(self):
- """Test __eq__ equality function."""
- filter1 = CategoryFilter(["+a", "+b"])
- filter2 = CategoryFilter(["+a", "+b"])
- filter3 = CategoryFilter(["+b", "+a"])
-
- # == calls __eq__.
- self.assertTrue(filter1 == filter2)
- self.assertFalse(filter1 == filter3) # Cannot test with assertNotEqual.
-
- def test_ne(self):
- """Test __ne__ inequality function."""
- # != calls __ne__.
- # By default, __ne__ always returns true on different objects.
- # Thus, just check the distinguishing case to verify that the
- # code defines __ne__.
- self.assertFalse(CategoryFilter() != CategoryFilter())
-
- def test_should_check(self):
- """Test should_check() method."""
- filter = CategoryFilter()
- self.assertTrue(filter.should_check("everything"))
- # Check a second time to exercise cache.
- self.assertTrue(filter.should_check("everything"))
-
- filter = CategoryFilter(["-"])
- self.assertFalse(filter.should_check("anything"))
- # Check a second time to exercise cache.
- self.assertFalse(filter.should_check("anything"))
-
- filter = CategoryFilter(["-", "+ab"])
- self.assertTrue(filter.should_check("abc"))
- self.assertFalse(filter.should_check("a"))
-
- filter = CategoryFilter(["+", "-ab"])
- self.assertFalse(filter.should_check("abc"))
- self.assertTrue(filter.should_check("a"))
-
class ProcessorOptionsTest(unittest.TestCase):
@@ -110,6 +56,7 @@ class ProcessorOptionsTest(unittest.TestCase):
self.assertEquals(options.extra_flag_values, {})
self.assertEquals(options.filter, CategoryFilter())
self.assertEquals(options.git_commit, None)
+ self.assertEquals(options.max_reports_per_category, {})
self.assertEquals(options.output_format, "emacs")
self.assertEquals(options.verbosity, 1)
@@ -126,11 +73,13 @@ class ProcessorOptionsTest(unittest.TestCase):
options = ProcessorOptions(extra_flag_values={"extra_value" : 2},
filter=CategoryFilter(["+"]),
git_commit="commit",
+ max_reports_per_category={"category": 3},
output_format="vs7",
verbosity=3)
self.assertEquals(options.extra_flag_values, {"extra_value" : 2})
self.assertEquals(options.filter, CategoryFilter(["+"]))
self.assertEquals(options.git_commit, "commit")
+ self.assertEquals(options.max_reports_per_category, {"category": 3})
self.assertEquals(options.output_format, "vs7")
self.assertEquals(options.verbosity, 3)
@@ -143,11 +92,14 @@ class ProcessorOptionsTest(unittest.TestCase):
options = ProcessorOptions(extra_flag_values={"extra_value" : 1},
filter=CategoryFilter(["+"]),
git_commit="commit",
+ max_reports_per_category={"category": 3},
output_format="vs7",
verbosity=1)
self.assertFalse(options == ProcessorOptions(extra_flag_values={"extra_value" : 2}))
self.assertFalse(options == ProcessorOptions(filter=CategoryFilter(["-"])))
self.assertFalse(options == ProcessorOptions(git_commit="commit2"))
+ self.assertFalse(options == ProcessorOptions(max_reports_per_category=
+ {"category": 2}))
self.assertFalse(options == ProcessorOptions(output_format="emacs"))
self.assertFalse(options == ProcessorOptions(verbosity=2))
@@ -173,9 +125,9 @@ class ProcessorOptionsTest(unittest.TestCase):
self.assertFalse(options.is_reportable("xyz", 3))
-class WebKitArgumentDefaultsTest(unittest.TestCase):
+class GlobalVariablesTest(unittest.TestCase):
- """Tests validity of default arguments used by check-webkit-style."""
+ """Tests validity of the global variables."""
def defaults(self):
return style.webkit_argument_defaults()
@@ -206,6 +158,13 @@ class WebKitArgumentDefaultsTest(unittest.TestCase):
# on valid arguments elsewhere.
parser.parse([]) # arguments valid: no error or SystemExit
+ def test_max_reports_per_category(self):
+ """Check that MAX_REPORTS_PER_CATEGORY is valid."""
+ categories = style.style_categories()
+ for category in style.MAX_REPORTS_PER_CATEGORY.iterkeys():
+ self.assertTrue(category in categories,
+ 'Key "%s" is not a category' % category)
+
class ArgumentPrinterTest(unittest.TestCase):
@@ -217,8 +176,11 @@ class ArgumentPrinterTest(unittest.TestCase):
filter_rules=[], git_commit=None,
extra_flag_values={}):
filter = CategoryFilter(filter_rules)
- return style.ProcessorOptions(output_format, verbosity, filter,
- git_commit, extra_flag_values)
+ return style.ProcessorOptions(extra_flag_values=extra_flag_values,
+ filter=filter,
+ git_commit=git_commit,
+ output_format=output_format,
+ verbosity=verbosity)
def test_to_flag_string(self):
options = self._create_options('vs7', 5, ['+foo', '-bar'], 'git',
diff --git a/WebKitTools/Scripts/webkitpy/style/error_handlers.py b/WebKitTools/Scripts/webkitpy/style/error_handlers.py
index 54b1d76..31140de 100644
--- a/WebKitTools/Scripts/webkitpy/style/error_handlers.py
+++ b/WebKitTools/Scripts/webkitpy/style/error_handlers.py
@@ -32,7 +32,9 @@ Methods:
Handle the occurrence of a style error.
- Check whether the error is reportable. If so, report the details.
+ Check whether the error is reportable. If so, increment the total
+ error count and report the details. Note that error reporting can
+ be suppressed after reaching a certain number of reports.
Args:
line_number: The integer line number of the line containing the error.
@@ -79,6 +81,28 @@ class DefaultStyleErrorHandler(object):
self._options = options
self._stderr_write = stderr_write
+ # A string to integer dictionary cache of the number of reportable
+ # errors per category passed to this instance.
+ self._category_totals = { }
+
+ def _add_reportable_error(self, category):
+ """Increment the error count and return the new category total."""
+ self._increment_error_count() # Increment the total.
+
+ # Increment the category total.
+ if not category in self._category_totals:
+ self._category_totals[category] = 1
+ else:
+ self._category_totals[category] += 1
+
+ return self._category_totals[category]
+
+ def _max_reports(self, category):
+ """Return the maximum number of errors to report."""
+ if not category in self._options.max_reports_per_category:
+ return None
+ return self._options.max_reports_per_category[category]
+
def __call__(self, line_number, category, confidence, message):
"""Handle the occurrence of a style error.
@@ -88,13 +112,23 @@ class DefaultStyleErrorHandler(object):
if not self._options.is_reportable(category, confidence):
return
- self._increment_error_count()
+ category_total = self._add_reportable_error(category)
+
+ max_reports = self._max_reports(category)
+
+ if (max_reports is not None) and (category_total > max_reports):
+ # Then suppress displaying the error.
+ return
if self._options.output_format == 'vs7':
format_string = "%s(%s): %s [%s] [%d]\n"
else:
format_string = "%s:%s: %s [%s] [%d]\n"
+ if category_total == max_reports:
+ format_string += ("Suppressing further [%s] reports for this "
+ "file.\n" % category)
+
self._stderr_write(format_string % (self._file_path,
line_number,
message,
@@ -130,7 +164,7 @@ class PatchStyleErrorHandler(object):
if not self._line_numbers:
for line in self._diff.lines:
# When deleted line is not set, it means that
- # the line is newly added.
+ # the line is newly added (or modified).
if not line[0]:
self._line_numbers.add(line[1])
@@ -140,9 +174,9 @@ class PatchStyleErrorHandler(object):
"""Handle the occurrence of a style error.
This function does not report errors occurring in lines not
- modified or added.
+ marked as modified or added in the patch.
- Args: see the DefaultStyleErrorHandler.__call__() documentation.
+ See the docstring of this module for more information.
"""
if line_number not in self._get_line_numbers():
diff --git a/WebKitTools/Scripts/webkitpy/style/error_handlers_unittest.py b/WebKitTools/Scripts/webkitpy/style/error_handlers_unittest.py
index 6a91ff2..83bdbb9 100644
--- a/WebKitTools/Scripts/webkitpy/style/error_handlers_unittest.py
+++ b/WebKitTools/Scripts/webkitpy/style/error_handlers_unittest.py
@@ -50,9 +50,6 @@ class DefaultStyleErrorHandlerTest(StyleErrorHandlerTestBase):
_category = "whitespace/tab"
- def _options(self, output_format):
- return ProcessorOptions(verbosity=3, output_format=output_format)
-
def _error_handler(self, options):
file_path = "foo.h"
return DefaultStyleErrorHandler(file_path,
@@ -60,29 +57,28 @@ class DefaultStyleErrorHandlerTest(StyleErrorHandlerTestBase):
self._mock_increment_error_count,
self._mock_stderr_write)
- def _prepare_call(self, output_format="emacs"):
- """Return options after initializing."""
- options = self._options(output_format)
-
- # Test that count is initialized to zero.
+ def _check_initialized(self):
+ """Check that count and error messages are initialized."""
self.assertEquals(0, self._error_count)
self.assertEquals("", self._error_messages)
- return options
-
- def _call_error_handler(self, options, confidence):
- """Handle an error with given confidence."""
- handle_error = self._error_handler(options)
-
+ def _call(self, handle_error, options, confidence):
+ """Handle an error with the given error handler."""
line_number = 100
message = "message"
handle_error(line_number, self._category, confidence, message)
+ def _call_error_handler(self, options, confidence):
+ """Handle an error using a new error handler."""
+ handle_error = self._error_handler(options)
+ self._call(handle_error, options, confidence)
+
def test_call_non_reportable(self):
"""Test __call__() method with a non-reportable error."""
confidence = 1
- options = self._prepare_call()
+ options = ProcessorOptions(verbosity=3)
+ self._check_initialized()
# Confirm the error is not reportable.
self.assertFalse(options.is_reportable(self._category, confidence))
@@ -95,7 +91,8 @@ class DefaultStyleErrorHandlerTest(StyleErrorHandlerTestBase):
def test_call_reportable_emacs(self):
"""Test __call__() method with a reportable error and emacs format."""
confidence = 5
- options = self._prepare_call("emacs")
+ options = ProcessorOptions(verbosity=3, output_format="emacs")
+ self._check_initialized()
self._call_error_handler(options, confidence)
@@ -106,7 +103,8 @@ class DefaultStyleErrorHandlerTest(StyleErrorHandlerTestBase):
def test_call_reportable_vs7(self):
"""Test __call__() method with a reportable error and vs7 format."""
confidence = 5
- options = self._prepare_call("vs7")
+ options = ProcessorOptions(verbosity=3, output_format="vs7")
+ self._check_initialized()
self._call_error_handler(options, confidence)
@@ -114,6 +112,36 @@ class DefaultStyleErrorHandlerTest(StyleErrorHandlerTestBase):
self.assertEquals(self._error_messages,
"foo.h(100): message [whitespace/tab] [5]\n")
+ def test_call_max_reports_per_category(self):
+ """Test error report suppression in __call__() method."""
+ confidence = 5
+ options = ProcessorOptions(verbosity=3,
+ max_reports_per_category={self._category: 2})
+ error_handler = self._error_handler(options)
+
+ self._check_initialized()
+
+ # First call: usual reporting.
+ self._call(error_handler, options, confidence)
+ self.assertEquals(1, self._error_count)
+ self.assertEquals(self._error_messages,
+ "foo.h:100: message [whitespace/tab] [5]\n")
+
+ # Second call: suppression message reported.
+ self._error_messages = ""
+ self._call(error_handler, options, confidence)
+ self.assertEquals(2, self._error_count)
+ self.assertEquals(self._error_messages,
+ "foo.h:100: message [whitespace/tab] [5]\n"
+ "Suppressing further [%s] reports for this file.\n"
+ % self._category)
+
+ # Third call: no report.
+ self._error_messages = ""
+ self._call(error_handler, options, confidence)
+ self.assertEquals(3, self._error_count)
+ self.assertEquals(self._error_messages, "")
+
class PatchStyleErrorHandlerTest(StyleErrorHandlerTestBase):
diff --git a/WebKitTools/Scripts/webkitpy/style/filter.py b/WebKitTools/Scripts/webkitpy/style/filter.py
new file mode 100644
index 0000000..1b41424
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/style/filter.py
@@ -0,0 +1,97 @@
+# Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com)
+#
+# 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+
+"""Contains filter-related code."""
+
+
+class CategoryFilter(object):
+
+ """Filters whether to check style categories."""
+
+ def __init__(self, filter_rules=None):
+ """Create a category filter.
+
+ This method performs argument validation but does not strip
+ leading or trailing white space.
+
+ Args:
+ filter_rules: A list of strings that are filter rules, which
+ are strings beginning with the plus or minus
+ symbol (+/-). The list should include any
+ default filter rules at the beginning.
+ Defaults to the empty list.
+
+ Raises:
+ ValueError: Invalid filter rule if a rule does not start with
+ plus ("+") or minus ("-").
+
+ """
+ if filter_rules is None:
+ filter_rules = []
+
+ for rule in filter_rules:
+ if not (rule.startswith('+') or rule.startswith('-')):
+ raise ValueError('Invalid filter rule "%s": every rule '
+ 'rule in the --filter flag must start '
+ 'with + or -.' % rule)
+
+ self._filter_rules = filter_rules
+ self._should_check_category = {} # Cached dictionary of category to True/False
+
+ def __str__(self):
+ return ",".join(self._filter_rules)
+
+ # Useful for unit testing.
+ def __eq__(self, other):
+ """Return whether this CategoryFilter instance is equal to another."""
+ return self._filter_rules == other._filter_rules
+
+ # Useful for unit testing.
+ def __ne__(self, other):
+ # Python does not automatically deduce from __eq__().
+ return not (self == other)
+
+ def should_check(self, category):
+ """Return whether the category should be checked.
+
+ The rules for determining whether a category should be checked
+ are as follows. By default all categories should be checked.
+ Then apply the filter rules in order from first to last, with
+ later flags taking precedence.
+
+ A filter rule applies to a category if the string after the
+ leading plus/minus (+/-) matches the beginning of the category
+ name. A plus (+) means the category should be checked, while a
+ minus (-) means the category should not be checked.
+
+ """
+ if category in self._should_check_category:
+ return self._should_check_category[category]
+
+ should_check = True # All categories checked by default.
+ for rule in self._filter_rules:
+ if not category.startswith(rule[1:]):
+ continue
+ should_check = rule.startswith('+')
+ self._should_check_category[category] = should_check # Update cache.
+ return should_check
+
diff --git a/WebKitTools/Scripts/webkitpy/style/filter_unittest.py b/WebKitTools/Scripts/webkitpy/style/filter_unittest.py
new file mode 100644
index 0000000..0b12123
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/style/filter_unittest.py
@@ -0,0 +1,84 @@
+# Copyright (C) 2010 Chris Jerdonek (chris.jerdonek@gmail.com)
+#
+# 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 tests for filter.py."""
+
+
+import unittest
+
+from filter import CategoryFilter
+
+
+class CategoryFilterTest(unittest.TestCase):
+
+ """Tests CategoryFilter class."""
+
+ def test_init(self):
+ """Test __init__ constructor."""
+ self.assertRaises(ValueError, CategoryFilter, ["no_prefix"])
+ CategoryFilter() # No ValueError: works
+ CategoryFilter(["+"]) # No ValueError: works
+ CategoryFilter(["-"]) # No ValueError: works
+
+ def test_str(self):
+ """Test __str__ "to string" operator."""
+ filter = CategoryFilter(["+a", "-b"])
+ self.assertEquals(str(filter), "+a,-b")
+
+ def test_eq(self):
+ """Test __eq__ equality function."""
+ filter1 = CategoryFilter(["+a", "+b"])
+ filter2 = CategoryFilter(["+a", "+b"])
+ filter3 = CategoryFilter(["+b", "+a"])
+
+ # == calls __eq__.
+ self.assertTrue(filter1 == filter2)
+ self.assertFalse(filter1 == filter3) # Cannot test with assertNotEqual.
+
+ def test_ne(self):
+ """Test __ne__ inequality function."""
+ # != calls __ne__.
+ # By default, __ne__ always returns true on different objects.
+ # Thus, just check the distinguishing case to verify that the
+ # code defines __ne__.
+ self.assertFalse(CategoryFilter() != CategoryFilter())
+
+ def test_should_check(self):
+ """Test should_check() method."""
+ filter = CategoryFilter()
+ self.assertTrue(filter.should_check("everything"))
+ # Check a second time to exercise cache.
+ self.assertTrue(filter.should_check("everything"))
+
+ filter = CategoryFilter(["-"])
+ self.assertFalse(filter.should_check("anything"))
+ # Check a second time to exercise cache.
+ self.assertFalse(filter.should_check("anything"))
+
+ filter = CategoryFilter(["-", "+ab"])
+ self.assertTrue(filter.should_check("abc"))
+ self.assertFalse(filter.should_check("a"))
+
+ filter = CategoryFilter(["+", "-ab"])
+ self.assertFalse(filter.should_check("abc"))
+ self.assertTrue(filter.should_check("a"))
+
diff --git a/WebKitTools/Scripts/webkitpy/style/processors/common.py b/WebKitTools/Scripts/webkitpy/style/processors/common.py
new file mode 100644
index 0000000..dbf4bea
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/style/processors/common.py
@@ -0,0 +1,59 @@
+# Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org)
+#
+# 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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.
+
+"""Supports style checking not specific to any one processor."""
+
+
+# FIXME: Test this list in the same way that the list of CppProcessor
+# categories is tested, for example by checking that all of its
+# elements appear in the unit tests. This should probably be done
+# after moving the relevant cpp_unittest.ErrorCollector code
+# into a shared location and refactoring appropriately.
+categories = set([
+ "whitespace/carriage_return",
+])
+
+
+def check_no_carriage_return(line, line_number, error):
+ """Check that a line does not end with a carriage return.
+
+ Returns true if the check is successful (i.e. if the line does not
+ end with a carriage return), and false otherwise.
+
+ Args:
+ line: A string that is the line to check.
+ line_number: The line number.
+ error: The function to call with any errors found.
+
+ """
+
+ if line.endswith("\r"):
+ error(line_number,
+ "whitespace/carriage_return",
+ 1,
+ "One or more unexpected \\r (^M) found; "
+ "better to use only a \\n")
+ return False
+
+ return True
+
+
diff --git a/WebKitTools/Scripts/webkitpy/style/processors/common_unittest.py b/WebKitTools/Scripts/webkitpy/style/processors/common_unittest.py
new file mode 100644
index 0000000..9362b65
--- /dev/null
+++ b/WebKitTools/Scripts/webkitpy/style/processors/common_unittest.py
@@ -0,0 +1,82 @@
+# Copyright (C) 2010 Chris Jerdonek (cjerdonek@webkit.org)
+#
+# 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 APPLE INC. AND ITS 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 APPLE INC. OR ITS 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 tests for common.py."""
+
+
+import unittest
+
+from common import check_no_carriage_return
+
+
+# FIXME: The unit tests for the cpp, text, and common processors should
+# share supporting test code. This can include, for example, the
+# mock style error handling code and the code to check that all
+# of a processor's categories are covered by the unit tests.
+# Such shared code can be located in a shared test file, perhaps
+# ilke this one.
+class CarriageReturnTest(unittest.TestCase):
+
+ """Tests check_no_carriage_return()."""
+
+ _category = "whitespace/carriage_return"
+ _confidence = 1
+
+ def setUp(self):
+ self._style_errors = [] # The list of accumulated style errors.
+
+ def _mock_style_error_handler(self, line_number, category, confidence,
+ message):
+ """Append the error information to the list of style errors."""
+ error = (line_number, category, confidence, message)
+ self._style_errors.append(error)
+
+ def assert_carriage_return(self, line, is_error):
+ """Call check_no_carriage_return() and assert the result."""
+ line_number = 100
+ handle_style_error = self._mock_style_error_handler
+
+ check_no_carriage_return(line, line_number, handle_style_error)
+
+ expected_message = ("One or more unexpected \\r (^M) found; "
+ "better to use only a \\n")
+
+ if is_error:
+ expected_errors = [(line_number, self._category, self._confidence,
+ expected_message)]
+ self.assertEquals(self._style_errors, expected_errors)
+ else:
+ self.assertEquals(self._style_errors, [])
+
+ def test_ends_with_carriage(self):
+ self.assert_carriage_return("carriage return\r", is_error=True)
+
+ def test_ends_with_nothing(self):
+ self.assert_carriage_return("no carriage return", is_error=False)
+
+ def test_ends_with_newline(self):
+ self.assert_carriage_return("no carriage return\n", is_error=False)
+
+ def test_ends_with_carriage_newline(self):
+ # Check_no_carriage_return only() checks the final character.
+ self.assert_carriage_return("carriage\r in a string", is_error=False)
+
diff --git a/WebKitTools/Scripts/webkitpy/style/unittests.py b/WebKitTools/Scripts/webkitpy/style/unittests.py
index 11c10e7..f8e3f71 100644
--- a/WebKitTools/Scripts/webkitpy/style/unittests.py
+++ b/WebKitTools/Scripts/webkitpy/style/unittests.py
@@ -37,5 +37,7 @@ import unittest
from checker_unittest import *
from error_handlers_unittest import *
+from filter_unittest import *
+from processors.common_unittest import *
from processors.cpp_unittest import *
from processors.text_unittest import *