Diff
Modified: trunk/Tools/ChangeLog (90196 => 90197)
--- trunk/Tools/ChangeLog 2011-07-01 02:55:49 UTC (rev 90196)
+++ trunk/Tools/ChangeLog 2011-07-01 02:59:43 UTC (rev 90197)
@@ -1,3 +1,16 @@
+2011-06-30 Kenichi Ishibashi <[email protected]>
+
+ Reviewed by Darin Adler.
+
+ Style Checker should flag removal of "developmentRegion = English;" from project.pbxproj.
+ https://bugs.webkit.org/show_bug.cgi?id=62022
+
+ Adds XcodeProjectFileChecker to check removal of "developmentRegion".
+
+ * Scripts/webkitpy/style/checker.py: Added XcodeProjectFileChecker as a checker for *.pbxproj.
+ * Scripts/webkitpy/style/checkers/xcodeproj.py: Added.
+ * Scripts/webkitpy/style/checkers/xcodeproj_unittest.py: Added.
+
2011-06-30 Dirk Pranke <[email protected]>
Reviewed by Ojan Vafai.
Modified: trunk/Tools/Scripts/webkitpy/style/checker.py (90196 => 90197)
--- trunk/Tools/Scripts/webkitpy/style/checker.py 2011-07-01 02:55:49 UTC (rev 90196)
+++ trunk/Tools/Scripts/webkitpy/style/checker.py 2011-07-01 02:59:43 UTC (rev 90197)
@@ -41,6 +41,7 @@
from checkers.python import PythonChecker
from checkers.test_expectations import TestExpectationsChecker
from checkers.text import TextChecker
+from checkers.xcodeproj import XcodeProjectFileChecker
from checkers.xml import XMLChecker
from error_handlers import DefaultStyleErrorHandler
from filter import FilterConfiguration
@@ -254,6 +255,8 @@
'y',
]
+_XCODEPROJ_FILE_EXTENSION = 'pbxproj'
+
_XML_FILE_EXTENSIONS = [
'vcproj',
'vsprops',
@@ -444,6 +447,7 @@
PYTHON = 3
TEXT = 4
XML = 5
+ XCODEPROJ = 6
class CheckerDispatcher(object):
@@ -504,6 +508,8 @@
return FileType.XML
elif os.path.basename(file_path).startswith('ChangeLog'):
return FileType.CHANGELOG
+ elif file_extension == _XCODEPROJ_FILE_EXTENSION:
+ return FileType.XCODEPROJ
elif ((not file_extension and os.path.join("Tools", "Scripts") in file_path) or
file_extension in _TEXT_FILE_EXTENSIONS):
return FileType.TEXT
@@ -528,6 +534,8 @@
checker = PythonChecker(file_path, handle_style_error)
elif file_type == FileType.XML:
checker = XMLChecker(file_path, handle_style_error)
+ elif file_type == FileType.XCODEPROJ:
+ checker = XcodeProjectFileChecker(file_path, handle_style_error)
elif file_type == FileType.TEXT:
basename = os.path.basename(file_path)
if basename == 'test_expectations.txt' or basename == 'drt_expectations.txt':
Added: trunk/Tools/Scripts/webkitpy/style/checkers/xcodeproj.py (0 => 90197)
--- trunk/Tools/Scripts/webkitpy/style/checkers/xcodeproj.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/xcodeproj.py 2011-07-01 02:59:43 UTC (rev 90197)
@@ -0,0 +1,61 @@
+#!/usr/bin/env python
+#
+# 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:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Checks Xcode project files."""
+
+import re
+
+
+class XcodeProjectFileChecker(object):
+
+ """Processes Xcode project file lines for checking style."""
+
+ def __init__(self, file_path, handle_style_error):
+ self.file_path = file_path
+ self.handle_style_error = handle_style_error
+ self.handle_style_error.turn_off_line_filtering()
+ self._development_region_regex = re.compile('developmentRegion = (?P<region>.+);')
+
+ def _check_development_region(self, line_index, line):
+ """Returns True when developmentRegion is detected."""
+ matched = self._development_region_regex.search(line)
+ if not matched:
+ return False
+ if matched.group('region') != 'English':
+ self.handle_style_error(line_index,
+ 'xcodeproj/settings', 5,
+ 'developmentRegion is not English.')
+ return True
+
+ def check(self, lines):
+ development_region_is_detected = False
+ for line_index, line in enumerate(lines):
+ if self._check_development_region(line_index, line):
+ development_region_is_detected = True
+
+ if not development_region_is_detected:
+ self.handle_style_error(len(lines),
+ 'xcodeproj/settings', 5,
+ 'Missing "developmentRegion = English".')
Property changes on: trunk/Tools/Scripts/webkitpy/style/checkers/xcodeproj.py
___________________________________________________________________
Added: svn:eol-style
Added: trunk/Tools/Scripts/webkitpy/style/checkers/xcodeproj_unittest.py (0 => 90197)
--- trunk/Tools/Scripts/webkitpy/style/checkers/xcodeproj_unittest.py (rev 0)
+++ trunk/Tools/Scripts/webkitpy/style/checkers/xcodeproj_unittest.py 2011-07-01 02:59:43 UTC (rev 90197)
@@ -0,0 +1,73 @@
+#!/usr/bin/env python
+#
+# 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:
+# 1. Redistributions of source code must retain the above copyright
+# notice, this list of conditions and the following disclaimer.
+# 2. Redistributions in binary form must reproduce the above copyright
+# notice, this list of conditions and the following disclaimer in the
+# documentation and/or other materials provided with the distribution.
+#
+# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+# A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+# OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
+# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
+# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
+# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
+# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+"""Unit test for xcodeproj.py."""
+
+import xcodeproj
+import unittest
+
+
+class TestErrorHandler(object):
+ """Error handler for XcodeProjectFileChecker unittests"""
+ def __init__(self, handler):
+ self.handler = handler
+
+ def turn_off_line_filtering(self):
+ pass
+
+ def __call__(self, line_number, category, confidence, message):
+ self.handler(self, line_number, category, confidence, message)
+
+
+class XcodeProjectFileCheckerTest(unittest.TestCase):
+ """Tests XcodeProjectFileChecker class."""
+
+ def assert_no_error(self, lines):
+ def handler(error_handler, line_number, category, confidence, message):
+ self.fail('Unexpected error: %d %s %d %s' % (line_number, category, confidence, message))
+
+ error_handler = TestErrorHandler(handler)
+ checker = xcodeproj.XcodeProjectFileChecker('', error_handler)
+ checker.check(lines)
+
+ def assert_error(self, lines, expected_message):
+ self.had_error = False
+
+ def handler(error_handler, line_number, category, confidence, message):
+ self.assertEqual(expected_message, message)
+ self.had_error = True
+ error_handler = TestErrorHandler(handler)
+ checker = xcodeproj.XcodeProjectFileChecker('', error_handler)
+ checker.check(lines)
+ self.assert_(self.had_error, '%s should have error: %s.' % (lines, expected_message))
+
+ def test_detect_development_region(self):
+ self.assert_no_error(['developmentRegion = English;'])
+ self.assert_error([''], 'Missing "developmentRegion = English".')
+ self.assert_error(['developmentRegion = Japanese;'],
+ 'developmentRegion is not English.')
+
+if __name__ == '__main__':
+ unittest.main()
Property changes on: trunk/Tools/Scripts/webkitpy/style/checkers/xcodeproj_unittest.py
___________________________________________________________________
Added: svn:eol-style