Diff
Modified: trunk/Tools/ChangeLog (97883 => 97884)
--- trunk/Tools/ChangeLog 2011-10-19 22:30:04 UTC (rev 97883)
+++ trunk/Tools/ChangeLog 2011-10-19 22:31:55 UTC (rev 97884)
@@ -1,3 +1,14 @@
+2011-10-19 David Levin <[email protected]>
+
+ watchlist: Add a stylecheck to do validity checks for the watchlist config.
+ https://bugs.webkit.org/show_bug.cgi?id=69487
+
+ Reviewed by Adam Barth.
+
+ * Scripts/webkitpy/style/checker.py: Add the watchlist file type.
+ * Scripts/webkitpy/style/checkers/watchlist.py: Added.
+ * Scripts/webkitpy/style/checkers/watchlist_unittest.py: Added.
+
2011-10-19 Eric Seidel <[email protected]>
NRWT ServerProcess can't read lines from stderr and stdio separately
Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (97883 => 97884)
--- trunk/Tools/Scripts/webkitpy/style/checker.py 2011-10-19 22:30:04 UTC (rev 97883)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py 2011-10-19 22:31:55 UTC (rev 97884)
@@ -42,6 +42,7 @@
from checkers.python import PythonChecker
from checkers.test_expectations import TestExpectationsChecker
from checkers.text import TextChecker
+from checkers.watchlist import WatchListChecker
from checkers.xcodeproj import XcodeProjectFileChecker
from checkers.xml import XMLChecker
from error_handlers import DefaultStyleErrorHandler
@@ -446,8 +447,9 @@
CPP = 2
PYTHON = 3
TEXT = 4
- XML = 5
- XCODEPROJ = 6
+ WATCHLIST = 5
+ XML = 6
+ XCODEPROJ = 7
class CheckerDispatcher(object):
@@ -516,6 +518,8 @@
return FileType.XML
elif os.path.basename(file_path).startswith('ChangeLog'):
return FileType.CHANGELOG
+ elif os.path.basename(file_path) == 'watchlist':
+ return FileType.WATCHLIST
elif file_extension == _XCODEPROJ_FILE_EXTENSION:
return FileType.XCODEPROJ
elif ((not file_extension and os.path.join("Tools", "Scripts") in file_path) or
@@ -550,6 +554,8 @@
checker = TestExpectationsChecker(file_path, handle_style_error)
else:
checker = TextChecker(file_path, handle_style_error)
+ elif file_type == FileType.WATCHLIST:
+ checker = WatchListChecker(file_path, handle_style_error)
else:
raise ValueError('Invalid file type "%(file_type)s": the only valid file types '
"are %(NONE)s, %(CPP)s, and %(TEXT)s."
Added: trunk/Tools/Scripts/webkitpy/style/checkers/watchlist.py (0 => 97884)
--- trunk/Tools/Scripts/webkitpy/style/checkers/watchlist.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/watchlist.py 2011-10-19 22:31:55 UTC (rev 97884)
@@ -0,0 +1,51 @@
+# Copyright (C) 2011 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
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * 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.
+# * 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+"""Checks WebKit style for the watchlist file."""
+
+
+from webkitpy.common.watchlist.watchlistparser import WatchListParser
+
+
+class WatchListChecker(object):
+
+ """Processes the watch list for checking style."""
+
+ def __init__(self, file_path, handle_style_error):
+ self._handle_style_error = handle_style_error
+ self._handle_style_error.turn_off_line_filtering()
+
+ def check(self, lines):
+ def log_to_style_error(message):
+ # Always report line 0 since we don't have anything better.
+ self._handle_style_error(0,
+ 'watchlist/general', 5,
+ message)
+
+ WatchListParser(log_error=log_to_style_error).parse('\n'.join(lines))
Added: trunk/Tools/Scripts/webkitpy/style/checkers/watchlist_unittest.py (0 => 97884)
--- trunk/Tools/Scripts/webkitpy/style/checkers/watchlist_unittest.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/watchlist_unittest.py 2011-10-19 22:31:55 UTC (rev 97884)
@@ -0,0 +1,66 @@
+#!/usr/bin/env python
+#
+# Copyright (C) 2010 Apple Inc. All rights reserved.
+# Copyright (C) 2011 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
+# met:
+#
+# * Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# * 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.
+# * 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.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+
+'''Unit tests for watchlist.py.'''
+
+
+import unittest
+
+
+import watchlist
+
+
+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)
+
+
+class WatchListTest(unittest.TestCase):
+ def test_basic_error_message(self):
+ def handle_style_error(mock_error_handler, line_number, category, confidence, message):
+ mock_error_handler.had_error = True
+ self.assertEquals(0, line_number)
+ self.assertEquals('watchlist/general', category)
+
+ error_handler = MockErrorHandler(handle_style_error)
+ error_handler.had_error = False
+ checker = watchlist.WatchListChecker('watchlist', error_handler)
+ checker.check(['{"DEFINTIONS": {}}'])
+ self.assertTrue(error_handler.had_error)
+ self.assertTrue(error_handler.turned_off_filtering)