Title: [95995] trunk/Tools
Revision
95995
Author
[email protected]
Date
2011-09-26 14:39:02 -0700 (Mon, 26 Sep 2011)

Log Message

Add skeleton parsing for a WatchList.
https://bugs.webkit.org/show_bug.cgi?id=68823

Reviewed by Adam Barth.

* Scripts/webkitpy/common/watchlist/watchlistparser.py: Added.
Parses the top level watch list sections -- none are defined yet -- and
throws an exception if an invalid one is listed.
* Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py: Added.
Verify the exception for an invalid section in a watch list.
* Scripts/webkitpy/common/watchlist/watchlist.py: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/Tools/ChangeLog (95994 => 95995)


--- trunk/Tools/ChangeLog	2011-09-26 21:35:31 UTC (rev 95994)
+++ trunk/Tools/ChangeLog	2011-09-26 21:39:02 UTC (rev 95995)
@@ -1,3 +1,17 @@
+2011-09-26  David Levin  <[email protected]>
+
+        Add skeleton parsing for a WatchList.
+        https://bugs.webkit.org/show_bug.cgi?id=68823
+
+        Reviewed by Adam Barth.
+
+        * Scripts/webkitpy/common/watchlist/watchlistparser.py: Added.
+        Parses the top level watch list sections -- none are defined yet -- and
+        throws an exception if an invalid one is listed.
+        * Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py: Added.
+        Verify the exception for an invalid section in a watch list.
+        * Scripts/webkitpy/common/watchlist/watchlist.py: Added.
+
 2011-09-26  Adam Roben  <[email protected]>
 
         Clean up code imported from WebKitAPITest

Added: trunk/Tools/Scripts/webkitpy/common/watchlist/__init__.py (0 => 95995)


--- trunk/Tools/Scripts/webkitpy/common/watchlist/__init__.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/__init__.py	2011-09-26 21:39:02 UTC (rev 95995)
@@ -0,0 +1 @@
+# Required for Python to search this directory for module files
Property changes on: trunk/Tools/Scripts/webkitpy/common/watchlist/__init__.py
___________________________________________________________________

Added: svn:eol-style

Added: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlist.py (0 => 95995)


--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlist.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlist.py	2011-09-26 21:39:02 UTC (rev 95995)
@@ -0,0 +1,32 @@
+# 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.
+
+
+class WatchList(object):
+    def __init__(self):
+        pass
Property changes on: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlist.py
___________________________________________________________________

Added: svn:eol-style

Added: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser.py (0 => 95995)


--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser.py	2011-09-26 21:39:02 UTC (rev 95995)
@@ -0,0 +1,50 @@
+# 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.
+
+from webkitpy.common.watchlist.watchlist import WatchList
+
+
+def _eval_watch_list(watch_list_contents):
+    return eval(watch_list_contents, {'__builtins__': None}, None)
+
+
+def parse_watch_list(watch_list_contents):
+    watch_list = WatchList()
+
+    # Change the watch list text into a dictionary.
+    dictionary = _eval_watch_list(watch_list_contents)
+    parsers = {}
+
+    # Parse the top level sections in the watch list.
+    for section in dictionary:
+        parser = parsers.get(section)
+        if not parser:
+            raise Exception('Unknown section in watch list: %s' % section)
+        parser(dictionary[section], watch_list)
+
+    return watch_list
Property changes on: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser.py
___________________________________________________________________

Added: svn:eol-style

Added: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py (0 => 95995)


--- trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py	                        (rev 0)
+++ trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py	2011-09-26 21:39:02 UTC (rev 95995)
@@ -0,0 +1,52 @@
+# 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 watchlistsparser.py.'''
+
+import re
+import unittest
+from webkitpy.common.watchlist.watchlistparser import parse_watch_list
+
+
+class WatchListParserTest(unittest.TestCase):
+    def setUp(self):
+        # For versions of Python before 2.7.
+        if not 'assertRaisesRegexp' in dir(self):
+            self.assertRaisesRegexp = self._verifyException
+
+    def _verifyException(self, regex_message, callable, *args):
+        try:
+            callable(*args)
+            self.assertTrue(False, 'No assert raised.')
+        except Exception as exception:
+            self.assertTrue(re.match(regex_message, exception.__str__()),
+                            'Expected regex "%s"\nGot "%s"' % (regex_message, exception.__str__()))
+
+    def test_bad_section(self):
+        watch_list_with_bad_section = ('{"FOO": {}}')
+        self.assertRaisesRegexp('Unknown section in watch list: FOO', parse_watch_list, watch_list_with_bad_section)
Property changes on: trunk/Tools/Scripts/webkitpy/common/watchlist/watchlistparser_unittest.py
___________________________________________________________________

Added: svn:eol-style

_______________________________________________
webkit-changes mailing list
[email protected]
http://lists.webkit.org/mailman/listinfo.cgi/webkit-changes

Reply via email to